Kepp在运行model.fit()时获取ValueError错误类型

时间:2020-06-05 10:47:00

标签: python-3.x machine-learning google-colaboratory tensorflow2.0

在我的训练和验证数据集上运行model.fit()方法,我不断收到此错误,而且我不确定这是怎么回事:

ValueError: Could not find matching function to call loaded from the SavedModel. Got:
  Positional arguments (4 total):
    * Tensor("inputs:0", shape=(224, 224, 3), dtype=float32)
    * False
    * False
    * 0.99
  Keyword arguments: {}

Expected these arguments to match one of the following 4 option(s):
  hist = model.fit(x=EXAMPLES_TRAIN,
                   steps_per_epoch=steps_per_epoch,
                   validation_data=EXAMPLES_VALID,
                   validation_steps=validation_steps,
                   epochs=_NUM_EPOCHS,
                   callbacks=
                     tf.keras.callbacks.TensorBoard(s_dir),      # log metrics
                     hp.KerasCallback(s_dir, s_hparams),         # log hparams
                     EarlyStopping(monitor='val_loss', mode='min', baseline=_CHKPT_ES_BASELINE, patience=_CHKPT_ES_PATIENCE, verbose=1),  # early stopping],
                   verbose=1).history

我不介意分享更多细节以提供有关我的问题的更多见解。关于我可能做错了什么的任何想法,因为我有相似的代码,在什么地方可以很好地工作,而不会出现此错误。

1 个答案:

答案 0 :(得分:0)

在加载权重之前尝试对模型进行虚拟调用:

model = build_model(...) # Your model-building code
model(tf.zeros((224, 224, 3), tf.float32)

# load model weights