Tensorflow 如何在tf2.0.0的正式版本中打印该值?
我发现在tf2.0.0的正式版本中无法显示tensor的值。我该怎么办?努比?评估Tensorflow 如何在tf2.0.0的正式版本中打印该值?,tensorflow,python-3.7,Tensorflow,Python 3.7,我发现在tf2.0.0的正式版本中无法显示tensor的值。我该怎么办?努比?评估 print(tf.random.uniform((3, 3))) print(tf.keras.layers.LayerNormalization()(tf.random.uniform((3, 3)))) 结果是: Tensor("random_uniform:0", shape=(3, 3), dtype=float32) Tensor("layer_normalization/batchnorm/a
print(tf.random.uniform((3, 3)))
print(tf.keras.layers.LayerNormalization()(tf.random.uniform((3, 3))))
结果是:
Tensor("random_uniform:0", shape=(3, 3), dtype=float32)
Tensor("layer_normalization/batchnorm/add_1:0", shape=(3, 3), dtype=float32)
你确定你的TF版本吗?以下是我对您的代码的结果:
将tensorflow导入为tf
def main():
打印(“版本:”,tf.Version.Version)
打印(tf.随机.均匀((3,3)))
打印(tf.keras.layers.LayerNormalization()(tf.random.uniform((3,3)))
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
main()
版本:2.0.0
tf张量(
[[0.4394927 0.44767535 0.02136886]
[0.7118287 0.65160227 0.47469318]
[0.7066748 0.130373 0.09051967]],形状=(3,3),数据类型=浮动32)
tf张量(
[[ 0.8090544 -1.4032681 0.5942137 ]
[-1.3625047 0.38342142 0.9790828 ]
[-1.2024965 0.00880218 1.1936939]],形状=(3,3),数据类型=float32)
您还可以选择使用
tf.print
而不是print
,后者只显示值(不显示形状,也不显示数据类型),这与调用print(tensor.numpy())
好的,谢谢,我的版本莫名其妙地更改为1.14.0,但我的pipfile是2.0.0。(#-)