我想在我的卷积模型中添加一个递归的lstm层,但在尝试添加它时却遇到此错误:
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
p1,p2,p3 .... u3,u4这些功能包括不同的卷积层和最大池层...如果需要,我可以发布更多代码吗?
def UNet():
f = [16, 32, 64, 128, 256]
inputs = keras.layers.Input((image_size, image_size,3))
p0 = inputs
c1, p1 = down_block(p0, f[0],1) #128 -> 64
c2, p2 = down_block(p1, f[1],1) #64 -> 32
c3, p3 = down_block(p2, f[2],1) #32 -> 16
c4, p4 = down_block(p3, f[3],1) #16->8
bn = bottleneck(p4, f[4],1)
u1 = up_block(bn, c4, f[3],1) #8 -> 16
u2 = up_block(u1, c3, f[2],1) #16 -> 32
u3 = up_block(u2, c2, f[1],1) #32 -> 64
u4 = up_block(u3, c1, f[0],1) #64 -> 128
outputs = keras.layers.Conv2D(1, (1, 1), padding="same", activation="sigmoid")(u4)
print('shape',outputs.shape) ##it's output is (?,128,128,1)
outputs=tf.reshape(outputs,[128*128,1,1])
outputs=keras.layers.LSTM(1)(outputs)
outputs=tf.reshape(outputs,[128,128,1])
outputs=keras.layers.Dense(units=1)(outputs)
model = keras.models.Model(inputs, outputs)
return model