【发布时间】:2020-09-10 10:11:19
【问题描述】:
我使用的是 Python 3.7.7。和 TensorFlow 2.1.0。
我有这段代码:
class_prototype = tf.math.reduce_mean(support_set_embeddings, axis=0)
print("Embeddings type: ", type(support_set_embeddings))
print("Class prototype type: ", type(class_prototype))
print("Support set embeddings shape: ", support_set_embeddings.shape)
print("Class prototype shape: ", class_prototype.shape)
有了这个输出:
Embeddings type: <class 'tensorflow.python.framework.ops.EagerTensor'>
Class prototype type: <class 'tensorflow.python.framework.ops.EagerTensor'>
Support set embeddings shape: (5, 12, 12, 512)
Class prototype shape: (12, 12, 512)
我得到了这个形状 (12, 12, 512),但我想要一个形状为 (1, 12, 12, 512) 的张量。
为了得到它,我做到了:
tf.expand_dims(class_prototype , axis=0)
但是,如果我添加一个新维度,会修改它的数据吗?
【问题讨论】:
标签: python numpy tensorflow