Keras AttributeError 'NoneType' object has no attribute '_inbound_nodes'


问题说明:

首先呢,报这个错误的代码是这行代码:

model = Model(inputs=input, outputs=output)

报错:

 AttributeError 'NoneType' object has no attribute '_inbound_nodes'

解决问题:

本人代码整体采用Keras Function API风格,其中使用代码中使用了concatenate以及reshape这两个方法,具体使用:

from keras import backend as K
from keras.layers import Dense, Input

inpt = Input(shape=(224, 224, 3))
x = Conv2d(63, (3,3), padding='same', activation='relu')
...
x = K.concatenate([branch1, branch2, branch3], axis=3)
x = K.reshpe(x, (1000,))
# 上面两行代码并不是连续出现,这里写出来,主要描述使用了“连接”“reshape”两种操作;

或许,在你的代码中也存在这两行代码,又或者使用了类似的一些方法,问题就出在这里:

x = K.concatenate([branch1, branch2, branch3], axis=3)
x = K.reshpe(x, (1000,))

将之修改为:

from keras.layers import Concatenate, Resahpe

x = Concatenate(axis=3)([branch1, branch2, branch3])
x = Resahpe((1000,))(x)

可以想到,直接使用concatenate或者reshape不是作为一层,而Concatenate或者Reshape是一个layer;

那么,类似的错误都可以按照这个思路来检查代码吧。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM