AttributeError:' nonepy'对象没有属性' _inbound_nodes'当在恒定张量和keras张量之间实现操作时
我正在KERAS中实施Convrnn,并且实现遵循
当类Convrnn返回KERAS模型(输入,输出)时,发生错误:
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
无论如何,我重新检查了我的代码,最后找到了触发问题的代码。但是我不知道如何修改它。他们是:
one = keras.backend.ones_like(z)
h_output = keras.layers.add([keras.layers.multiply([keras.layers.subtract([one, z]), h]), keras.layers.multiply([z, n])]) # h = (1 - z) * h + z * n
# h, z and n are all keras tensors
我想在这里实现的是 h =(1 -z) * h + z * n 。
有人可以给我建议吗?提前致谢。
顺便说一句,KERAS版本为2.3.1,TensorFlow版本为1.14.0。
I'm implementing a ConvRNN in keras, and the implementation follows this which is originally implemented in Pytorch.
When the class ConvRNN is going to return a keras Model(inputs, outputs), then an error occurs:
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
Anyway, I re-checked my code and finally located the code which triggers the problem.But I don't know how to modify it. They are:
one = keras.backend.ones_like(z)
h_output = keras.layers.add([keras.layers.multiply([keras.layers.subtract([one, z]), h]), keras.layers.multiply([z, n])]) # h = (1 - z) * h + z * n
# h, z and n are all keras tensors
What I want to implement here is h = (1 - z) * h + z * n.
Can anyone please give me advice? Thanks in advance.
BTW, the keras version is 2.3.1 and the tensorflow version is 1.14.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

哇..我终于弄清楚了。永远记住要确保应作为keras.layers进行张量的每个操作!
转换:
到:
然后错误消失了!
Whoo.. I finally figured it out. Always remember to make sure EVERY operation on tensors should be done as keras.layers!
Convert:
To:
Then the error is gone!