错误:“ NoneType”对象没有属性“ _inbound_nodes”

时间:2019-07-01 09:07:40

标签: python-3.x

我一直在尝试编码使用挤压激励块的模型。

我对错误一无所知。请提出替代方案。

import keras
from keras.models import Sequential,Model
from keras.layers import,Input,Dense,Conv2D,MaxPooling2D,Flatten,GlobalAveragePooling2D,BatchNormalization,Lambda,Conv2DTranspose,Reshape,Add,Multiply
import numpy as np
import io



x_inp=Input(shape=(6,8,128))
print(np.shape(x_inp))

def SEblock(x,cn):
   sh_x=x
   x=GlobalAveragePooling2D()(x)
   x=Dense(cn//16,activation='relu')(x)
   x=Dense(cn,activation='sigmoid')(x)
   x=Reshape((1,1,cn))(x)
   x=sh_x*x
   y=GlobalAveragePooling2D()(x)
   return y
y=SEblock(x_inp,128)

model=Model(inputs=x_inp,outputs=y)

运行以上代码时出现错误消息: 节点= layer._inbound_nodes [node_index]

AttributeError:“ NoneType”对象没有属性“ _inbound_nodes”

1 个答案:

答案 0 :(得分:0)

替换

x=sh_x*x

x = Multiply()([sh_x, x])
相关问题