I update code as below, no error, however I do not know if the input
is a sum of img_input
and emb
, how to check during training?
def create_model_tl_attn_posInputOnly(input_shape):
print("start creating model - transfer learning ...")
emb = embed_encoding2d(input_shape[0], input_shape[1], input_shape[2]) # this is from another class
img_input = Input(shape=input_shape)
base_model = vgg19.VGG19(include_top=False, input_shape=input_shape, weights="imagenet")
base_model.trainable = False
x = base_model(img_input + emb)
x = base_model.layers[-1].output
flat1 = Flatten()(x)
class1 = Dense(1024, activation='relu')(flat1)
dropout1 = Dropout(0.2)(class1)
class2 = Dense(512, activation='relu')(dropout1)
dropout2 = Dropout(0.2)(class2)
output = Dense(num_classes, activation='softmax')(dropout2)
model = Model(inputs=base_model.inputs, outputs=output)
return model
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…