python3 ValueError: The shape of the input to "Flatten" is not fully defined (got (0, 6, 80)

在用keras建立cnn模型时一直报错如下
ValueError: The shape of the input to "Flatten" is not fully defined (got (0, 6, 80). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.

 

代码如下:
model = models.Sequential()
model.add(Reshape([1]+in_shp, input_shape=in_shp))
model.add(Convolution2D(256, 1, 3, border_mode='valid', activation="relu", name="conv1", init='glorot_uniform'))
model.add(Flatten())

Solution: Tips ake sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model. So the model.add (Reshape ([1] + in_shp, input_shape = in_shp)) to model.add (Reshape ((1,2,128)), directly added dimension to your input and output dimensions (none, 1,2,128 ).problem solved

Reference: https://keras.io/zh/layers/core/     Keras Chinese documents

Guess you like

Origin blog.csdn.net/yimixgg/article/details/90679079