【发布时间】:2020-08-07 00:45:53
【问题描述】:
我正在尝试将 pos_ds 数值特征的数据类型从 float32 更改为 float 64,但无法找到正确的方法。有什么建议么。我正在使用 tensorflow 2.2。
def make_ds(features, labels):
ds = tf.data.Dataset.from_tensor_slices((dict(features), labels))#.cache()
ds = ds.shuffle(BUFFER_SIZE).repeat()
return ds
neg_ds = make_ds(neg_features, neg_labels)
pos_ds = make_ds(pos_features, pos_labels)
for features, label in pos_ds.take(1):
print("Features:\n", features.values())
print()
print("Label: ", label.numpy())
输出:
Features:
dict_values([<tf.Tensor: shape=(), dtype=float32, numpy=4.89784>, <tf.Tensor: shape=(), dtype=float32, numpy=4.727388>, <tf.Tensor: shape=(), dtype=float32, numpy=4.6051702>, <tf.Tensor: shape=(), dtype=float32, numpy=4.727388>, <tf.Tensor: shape=(), dtype=float32, numpy=4.804021>, <tf.Tensor: shape=(), dtype=float32, numpy=4.882802>, <tf.Tensor: shape=(), dtype=float32, numpy=4.912655>, <tf.Tensor: shape=(), dtype=string, numpy=b'nan'>, <tf.Tensor: shape=(), dtype=string, numpy=b'nan'>, <tf.Tensor: shape=(), dtype=string, numpy=b'nan'>, <tf.Tensor: shape=(), dtype=string, numpy=b'0.0'>, <tf.Tensor: shape=(), dtype=string, numpy=b'nan'>, <tf.Tensor: shape=(), dtype=string, numpy=b'NO_DCLRD_URL'>, <tf.Tensor: shape=(), dtype=string, numpy=b'nan'>])
Label: 1
【问题讨论】:
标签: python tensorflow machine-learning tensorflow2.0 tensorflow-datasets