对tensfor keras callb有异议

2024-03-28 16:59:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图纠正在tensorflow keras中使用回调时遇到的错误,但错误仍然存在。
下面是我的代码和错误

checkpointer = tf.keras.callbacks.ModelCheckpoint(filepath='bestmodel.h5', verbose=0, save_best_only=True) # model 
earlystopper = tf.keras.callbacks.EarlyStopping(monitor='val_loss', mode='min', min_delta=0.005, patience=20, verbose=0, restore_best_weights=True)

hist = vae.fit(tf_train,
               epochs=max_epochs,
               shuffle=True,
               verbose=0,
               validation_data=tf_val,
               callbacks=[checkpointer, earlystopper])

plot_loss(hist)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-a2fa7b74be4e> in <module>()
      7                verbose=0,
      8                validation_data=tf_val,
----> 9                callbacks=[checkpointer, earlystopper])
     10 
     11 plot_loss(hist)

5 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in set_weights(self, weights)
   1129   def get_input_at(self, node_index):
   1130     """Retrieves the input tensor(s) of a layer at a given node.
-> 1131 
   1132     Arguments:
   1133         node_index: Integer, index of the node

TypeError: object of type 'NoneType' has no len()

Tags: nodetrueinputverboseindextf错误val