我一直在尝试编码使用挤压激励块的模型。
我对错误一无所知。请提出替代方案。
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”
答案 0 :(得分:0)
替换
x=sh_x*x
与
x = Multiply()([sh_x, x])