您能帮我实现这种基于vgg-16的特征提取器吗? 图中显示了此方法背后的想法。 VGG-16 fusion scheme 代码如下:
#spring.profiles.active#
您能帮我解决这类问题吗,目前的问题是这样:
def ChannelPool(x):
return K.max(x, axis=0, keepdims = True)
def ConcatLayer(x):
tensor_1 = x[0]
tensor2 = x[1]
return K.concatenate([tensor_1, tensor2], axis = 1)
N_patches = 9 # local image regions
input_shape_global = Input(shape=(224, 224, 3))
input_shape_local = Input(shape=(N_patches, 50, 50, 3)) # i struggle with this part
Global_Model = VGG16(include_top=False, weights='imagenet', input_tensor=None, input_shape=(224,224,3), pooling='avg')
Local_Model = VGG16(include_top=False, weights='imagenet', input_tensor=input_shape_local[0], input_shape=(50,50,3), pooling='avg')
# Change layer names to avoid confusion
for layer_l in Global_Model.layers:
layer_l.name = layer_l.name + str("_1")
for layer_g in Local_Model.layers:
layer_g.name = layer_g.name + str("_2")
inp1 = Global_Model.input
out1 = Global_Model.output
inp2 = Local_Model.input
out2 = Local_Model.output
image_features = Global_Model(inp1)
patch_features = Local_Model(inp2)
patch_feature = Lambda(ChannelPool, name="Channel_Pool_Layer")(patch_features)
image_features = K.reshape(image_features, (1,512))
patch_feature = K.reshape(patch_feature, (1,512))
merged = Concatenate(axis = 1)([image_features, patch_feature])
merged = Dense(total_features ,activation='softmax', name='Fc1')(merged)
merged = Dense(total_features , activation='relu', name='Fc2')(merged)
final_model = Model(inputs = [inp1,inp2], outputs = merged)
AttributeError:“ NoneType”对象没有属性“ _inbound_nodes”
谢谢。