【问题标题】:Layer was called with an input that isn't a symbolic tensor使用不是符号张量的输入调用图层
【发布时间】:2019-11-06 18:03:54
【问题描述】:

我按照在 this page 上找到的代码进行操作。

复制粘贴代码时出现错误:

ValueError: Layer batch_normalization_1 was called with an input that isn't a symbolic tensor.

https://github.com/shantanuo/stack_question/blob/master/haptik_chatbot.ipynb

与博客作者不同,我收到错误的原因是什么?

【问题讨论】:

  • 请将整个回溯和代码放入您的问题中

标签: tensorflow keras


【解决方案1】:

您似乎没有向 Dense 层提供输入。

feature_input = Input(shape=(sentences_features.shape[1],))
dense = Dense(128, activation=activations.relu)
merged = BatchNormalization()(dense)

试试:

dense = Dense(128, activation=activations.relu)(feature_input)

【讨论】:

  • 谢谢。但现在得到不同的错误 - NameError: name 'Model' is not defined。 github.com/shantanuo/stack_question/blob/master/…
  • 你导入模型了吗?我在代码中没有看到,[from keras.models import Model]
  • 仍然报错:ValueError: Input tensors to a Model must come from keras.layers.Input
  • 此行中的 model = Model(inputs=[word_index], outputs=preds) word_index 是外部变量。你不能这样使用它。它必须通过输入层传递给模型。
猜你喜欢
  • 2018-05-29
  • 2019-06-04
  • 2019-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-30
  • 1970-01-01
相关资源
最近更新 更多