Model.save,错误:conv2d_1层的输入0与该层不兼容:预期ndim = 4,找到的ndim = 5。收到完整形状

时间:2020-04-08 07:48:31

标签: python tensorflow keras

我建立我的模型:

model = Sequential()
...
model.fit(..) #with train data
model.save(..) #and save it

然后我对它进行model.evaluate(),一切都很好。然后,我想用更多数据重新训练它,然后我:

model = keras.models.load_model(name) #load it
model.summary()                       
model.save("1_" + name)               #this is just to test it, and it doesn't work

在重新训练时,.fit()有效,但是我无法进行建模。保存,我得到了错误: conv2d_1层的输入0与该层不兼容:预期ndim = 4,找到的ndim = 5。收到完整形状

模型摘要:


图层(类型)输出形状参数#已连接

time_distributed_1_input(输入[(None,5,240,426,0


time_distributed_1(TimeDistrib(None,5,128)522400 time_distributed_1_input [0] [0]


input_1(InputLayer)[(None,7,81)] 0


gru_1(GRU)(无,64)37056 time_distributed_1 [0] [0]


conv1d_1(Conv1D)(无,3,64)25984 input_1 [0] [0]


dense_2(密集)(无,128)8320 gru_1 [0] [0]


dropout_1(退出)(无,3、64)0 conv1d_1 [0] [0]


dropout_2(Dropout)(None,128)0 density_2 [0] [0]


flatten_1(平坦)(无,192)0 dropout_1 [0] [0]


dense_3(密集)(无,64)8256 dropout_2 [0] [0]


dense_1(密集)(无,32)6176 flatten_1 [0] [0]


dense_4(密集)(无,32)2080 density_3 [0] [0]


concatenate_1(连续)(无,64)0 density_1 [0] [0]
density_4 [0] [0]


dense_5(密集)(无,32)2080 concatenate_1 [0] [0]


dense_6(密集)(无,16)528 density_5 [0] [0]


dense_7(Dense)(None,8)136 density_6 [0] [0]

我在哪里错?我可以输入完整的模型代码,但是为了简单起见,我没有。模型有效,我可以训练它,我可以评估,甚至可以再训练它,但是在加载后无法再次保存。

0 个答案:

没有答案