设置LSTM模型
model=tf.keras.Sequential([
LSTM(80,return_sequences=True),
Dropout(0.2),
LSTM(100),
Dropout(0.2),
Dense(1)
])
model.compile(optimizer=tf.keras.optimizers.Adam(0.001),loss='mean_squared_error'
运行模型
checkpoint_save_path='./checkpoint/stock.ckpt'
if os.path.exists(checkpoint_save_path+'.index'):
print('---------load the model---------')
model.load_weights(checkpoint_save_path)
cp_callback=tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_save_path,
save_weights_only=True,
save_best_only=True,
monitor='val_loss')
history=model.fit(x_train,y_train,batch_size=64,
epochs=50,
validation_data=(x_test,y_test),
validation_freq=1,
callbacks=[cp_callback])
model.summary()
报错
ValueError: Received incompatible tensor with shape (1, 80) when attempting to restore variable with shape (1, 320) and name layer_with_weights-0/cell/kernel/.OPTIMIZER_SLOT/optimizer/m/.ATTRIBUTES/VARIABLE_VALUE.
请问怎么改正?