for i in range(epochs):
gen = data_generator(train_descriptions,encoding_train,word_to_idx,max_len,batch_size)
model.fit(gen,epochs=1,steps_per_epoch=steps,verbose=1)
model.save("best_model.h5")
ValueError:不支持在图形模式下调用 Model.fit Model 实例是在启用 Eager 模式的情况下构建的。请 在图形模式下构造模型实例或调用 Model.fit 已启用急切模式。
如何解决这个错误?
尝试
model.compile(run_eagerly=True)
如果这不起作用,您可以尝试在模型编译后强制执行:
model.compile()
model.run_eagerly = True
问题正如它告诉你的那样。 TensorFlow 从 2.0 版本开始转向 Eager Mode,并在 v1.0 中使用 Graph Mode。 要解决此问题,请检查您是否有调用 TF1.0 行为的模块/函数。