[英]Keras Flatten layer returns output shape (None, None)
So, I noticed this strange behavior of Flatten layer of Keras. I'm using TF1.15 and Keras 2.3.0.所以,我注意到 Keras Flatten 层的这种奇怪行为。我使用的是 TF1.15 和 Keras 2.3.0。
Basically the output of the Flatten layer has an unknown shape.基本上 Flatten 层的 output 形状未知。 It's hard to troubleshoot the model when you can't keep track of the shape.
当您无法跟踪形状时,很难对 model 进行故障排除。 Why is this happening with Flatten layer, and can I do something so it recognizes the shape?
为什么 Flatten 层会发生这种情况,我可以做些什么让它识别形状吗?
from keras.layers import Flatten
inputs = Input(shape=(3,2,4))
prediction = Flatten()(inputs)
print(inputs.shape, prediction.shape)
(?, 3, 2, 4) (?, ?)
Try using tf.keras
instead of just keras
:尝试使用
tf.keras
而不仅仅是keras
:
import tensorflow as tf
print(tf.__version__)
inputs = tf.keras.layers.Input(shape=(3,2,4))
prediction = tf.keras.layers.Flatten()(inputs)
print(inputs.shape, prediction.shape)
1.15.2
(?, 3, 2, 4) (?, 24)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.