嗨,我想在 Dense 层之后重塑一个层,但它返回有趣的错误。这是代码
codings_size=10
decoder_inputs = tf.keras.layers.Input(shape=[codings_size])
# x=tf.keras.layers.Flatten(decoder_inputs)
x=tf.keras.layers.Dense(3 * 3 * 16)(decoder_inputs),
x=tf.keras.layers.Reshape((3, 3, 16))(x),
错误在这里
AttributeError: Exception encountered when calling layer "reshape_28" (type Reshape).
'tuple' object has no attribute 'shape'
Call arguments received by layer "reshape_28" (type Reshape):
• inputs=('tf.Tensor(shape=(None, 144), dtype=float32)',)
错误是你添加了额外的逗号。只需删除它们。像这样:
codings_size=10
decoder_inputs = tf.keras.layers.Input(shape=[codings_size])
# x=tf.keras.layers.Flatten(decoder_inputs)
x=tf.keras.layers.Dense(3 * 3 * 16)(decoder_inputs)
x=tf.keras.layers.Reshape((3, 3, 16))(x)