【问题标题】:ValueError: Calling `Model.fit` in graph mode is not supported when the `Model` instance was constructed with eager mode enabledValueError:在启用了 Eager 模式的情况下构造“Model”实例时,不支持在图形模式下调用“Model.fit”
【发布时间】:2021-09-24 12:58:27
【问题描述】:
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.fit 急切模式已启用。

我该如何解决这个错误?

【问题讨论】:

    标签: deep-learning model valueerror


    【解决方案1】:

    试试

    model.compile(run_eagerly=True)
    

    如果不行,可以在模型编译后尝试强制执行:

    model.compile()
    model.run_eagerly = True
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多