Lin*_*Ina 6 keras tensorflow eager-execution tensorflow2.0
实际上,我在 TensorFlow 1.13.0 中已经发现了这个问题。(tensorflow1.12.0 运行良好)。
我的代码被列为一个简单的例子:
def Lambda layer(temp):
print(temp)
return temp
Run Code Online (Sandbox Code Playgroud)
在我的 Keras 模型中用作 lambda 层。在tensorflow1.12.0中,print(temp)可以输出如下的详细数据
[<tf.Tensor: id=250, shape=(1024, 2, 32), dtype=complex64, numpy=
array([[[ 7.68014073e-01+0.95353246j, 7.01403618e-01+0.64385843j,
8.30483198e-01+1.0340731j , ..., -8.88018191e-01+0.4751519j ,
-1.20197642e+00+0.6313924j , -1.03787208e+00+0.22964947j],
[-7.94382274e-01+0.56390345j, -4.73938555e-01+0.55901265j,
-8.73749971e-01+0.67095983j, ..., -5.81580341e-01-0.91620034j,
-7.04443693e-01-1.2709806j , -3.23135853e-01-1.0887597j ]],
Run Code Online (Sandbox Code Playgroud)
这是因为我使用 1024 作为 batch_size。但是当我更新到 tensorflow1.13.0 或 TensorFlow 2.0 时,同样的代码输出
Tensor("lambda_1/truediv:0", shape=(None, 1), dtype=float32)
Run Code Online (Sandbox Code Playgroud)
这太可怕了,因为我不知道确切的错误。那么,关于如何解决它的任何想法?
您看到该输出是因为 Keras 模型正在转换为其图形表示形式,从而print打印tf.Tensor图形描述。
tf.Tensor要在使用 Tensorflow 2.0 时查看 a 的内容,您应该使用tf.print而不是,print因为前者会转换为其图形表示形式,而后者则不会。
| 归档时间: |
|
| 查看次数: |
2420 次 |
| 最近记录: |