报错信息:AttributeError: 'NoneType' object has no attribute '_inbound_nodes' #11811
解决方案:
1. 原因:keras形成model的流程中必须要全部用开头为大写的层结构。例如:Concatenate(),所有keras.backend下面的功能性function都应该被封装成层结构。
The problem is that squeezed_cat_conv2 is not the output of a keras layer. You should put squeeze in a lambda layer. You can use keras layers on normal tensors, but if you want to make a Model all operations should be in keras layers.
The concatenate() is an operation which can be performed on tensors. The Concatenate() is a layer. Which should be used as such. So I was wrong before, you should use:cat_conv = Concatenate(axis=3)([conv2d_out7,conv2d_out6,conv2d_out5])
Where you first construct the layer with Concatenate(axis=3) and then call it with the inputs of the layer.
2. 方法: 把tensor操作function封装在Lambda自定义层结构中。
you have forgotten to wrap expand_dims inside a Lambda layer as well:
sent_input = Lambda(lambda x: expand_dims(x, axis=3))(sent_embed) # for channels
本文解决了在使用Keras构建深度学习模型时遇到的AttributeError:'NoneType'objecthasnoattribute'_inbound_nodes'错误。详细阐述了问题的根源在于模型构建过程中未正确使用大写开头的层结构,并提供了正确的Concatenate层使用方法,同时建议将自定义的tensor操作封装在Lambda层中。
4741

被折叠的 条评论
为什么被折叠?



