【发布时间】:2020-04-04 06:47:00
【问题描述】:
我正在使用 TF 2.0。
工作:
from tensorflow.keras import layers
inputs = layers.Input(shape=(256,), sparse=False, name='name_sparse')
x = layers.Dense(32, name="my_layer")(inputs)
print(x)
输出:Tensor("my_layer/Identity:0", shape=(None, 32), dtype=float32)
不工作:
如果我在上面的代码中将稀疏更改为True,输出将更改为:
ValueError: The last dimension of the inputs to Dense should be defined. Found None.
如何将稀疏张量传递给 TF2.0 中的 Dense 层。它在 TF1.14 中运行良好。
【问题讨论】:
标签: python tensorflow keras tensorflow2.0 valueerror