【问题标题】:User Warning Form Keras 2用户警告表 Keras 2
【发布时间】:2018-03-07 07:08:11
【问题描述】:

我正在尝试重现 this 的工作,但收到以下警告:

/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py:2: UserWarning: Update your `Model` call to the Keras 2 API: `Model(outputs=Tensor("de..., inputs=Tensor("in...)`

当我运行第 84 行时:

model_final = Model(input = model.input, output = predictions)

我安装了以下软件包:

  • ipython==6.2.1
  • Keras==2.0.8
  • 张量流==1.3.0
  • tensorflow-tensorboard==0.1.5

看起来代码是用旧版本的 Keras 编写的,但在我的 Keras 版本下仍然有效。

任何建议都将不胜感激。

【问题讨论】:

    标签: python python-3.x tensorflow keras keras-2


    【解决方案1】:
    UserWarning: Update your `Model` call to the Keras 2 API:
    `Model(inputs=[<tf.Tenso…, outputs=Tensor(“ma…)`
    model = Model(input=[sentence_input, neg_input], output=loss)
    

    这里我们可以看到keras的新api,inputoutput应该是inputsoutputs

    原代码为:

    model = Model(input=[sentence_input, neg_input], output=loss)
    

    所以如果我们想消除这个警告,我们应该这样写:

    model = Model(inputs=[sentence_input, neg_input], outputs=loss)
    

    这里和那里只有一点点,仅此而已。

    【讨论】:

      猜你喜欢
      • 2018-05-14
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 2022-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-19
      相关资源
      最近更新 更多