Commit 4e913ea3 authored by Billy Amélie's avatar Billy Amélie
Browse files

competition score + transfer learning modification + model retraining

parent 3f0a09d4
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -143,24 +143,26 @@ def weightify(model_orig, custom_model, layer_modify,input_channel): ...@@ -143,24 +143,26 @@ def weightify(model_orig, custom_model, layer_modify,input_channel):
target_layer.trainable = False target_layer.trainable = False
return custom_model return custom_model
def create_transfer_learning(new_model, custom_model, modify_name,input_channel = 4): def create_transfer_learning(new_model, custom_model, modify_name,input_channel = 4, weights = False, hybrid = False):
# create cnn with transfer learning # create cnn with transfer learning
new = weightify(new_model,custom_model,modify_name,input_channel) new = weightify(new_model,custom_model,modify_name,input_channel)
x = new.output x = new.output
x = GlobalAveragePooling2D()(x) x = GlobalAveragePooling2D()(x)
x = Dropout(0.5)(x) x = Dropout(0.5)(x)
#x = Dense(1)(x) if hybrid == False :
x = Dense(1, activation='linear')(x)
model = Model(new.input, x) model = Model(new.input, x)
for layer in new.layers: if weights == True:
layer.trainable = False for layer in new.layers:
layer.trainable = False
return model return model
def create_hybrid_transfer(nb_attributes,new_model, custom_model, modify_name,input_channel): def create_hybrid_transfer(nb_attributes,new_model, custom_model, modify_name,input_channel,weight = False):
# create cnn and mlp models # create cnn and mlp models
mlp = create_mlp(nb_attributes) mlp = create_mlp(nb_attributes)
cnn = create_transfer_learning(new_model, custom_model, modify_name,input_channel) cnn = create_transfer_learning(new_model, custom_model, modify_name,input_channel,weights = weight, hybrid = True)
combinedInput = concatenate([mlp.output, cnn.output]) combinedInput = concatenate([mlp.output, cnn.output])
x = Dense(4, activation="tanh")(combinedInput) x = Dense(4, activation="tanh")(combinedInput)
x = Dropout(0.5)(x) x = Dropout(0.5)(x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment