Commit ef6cea31 authored by Bannier Delphine's avatar Bannier Delphine
Browse files

Merge branch 'master' into 'DelphineBranch'

# Conflicts:
#   .gitignore
#   preprocessing/read_load_data.py
#   processing/models.py
parents 294cc281 911189dd
......@@ -116,6 +116,7 @@ def load_images(input_directory,
images.append(outputImage)
return np.array(images)
def create_dataframe(df):
# new dataframe with one row per patient for training
......
......@@ -17,7 +17,6 @@ from tensorflow import TensorShape
from sklearn.model_selection import train_test_split
def create_cnn(width, height, depth, filters=(32, 64, 128), regress=False):
# initialize the input shape and channel dimension, assuming
# TensorFlow/channels-last ordering
......@@ -87,10 +86,6 @@ def create_hybrid(nb_attributes,shape=(240,240,1)):
return model
def create_hybrid2(nb_attributes,shape=(240,240,1)):
# create cnn and mlp models
mlp = create_mlp2(nb_attributes)
cnn = create_cnn(*shape)
def multify_weights(kernel, out_channels):
......@@ -127,7 +122,7 @@ def weightify(model_orig, custom_model, layer_modify,input_channel):
target_layer= Conv2D(32, (3, 3), activation='relu', padding='valid',use_bias=False)
input_shape = TensorShape([None, 240, 240, 4]) # to define h, w, c based on shape of layer input
input_shape = TensorShape([None, 240, 240, input_channel]) # to define h, w, c based on shape of layer input
target_layer.build(input_shape)
target_layer.set_weights([kernels_extra_channel])
#target_layer.set_weights([kernels_extra_channel, biases])
......@@ -163,6 +158,7 @@ def create_hybrid_transfer(nb_attributes,new_model, custom_model, modify_name,in
model = Model(inputs=[mlp.input, cnn.input], outputs=x)
return model
def fit_and_evaluate(t_x, val_x, t_y, val_y, EPOCHS=30, BATCH_SIZE=8,model = None,es= None,cp=None):
"""
`es`: earlystopping keras object
......@@ -173,4 +169,11 @@ def fit_and_evaluate(t_x, val_x, t_y, val_y, EPOCHS=30, BATCH_SIZE=8,model = Non
results = mod.fit(t_x, t_y, epochs=EPOCHS, batch_size=BATCH_SIZE, callbacks=[es, cp],
verbose=1, validation_split=0.1)
print("Val Score: ", mod.evaluate(val_x, val_y))
return results
\ No newline at end of file
return results
def create_regression(training_df_X, training_df_y, test_df_X, test_df_y, model):
model.fit(training_df_X, training_df_y)
print('Training accuracy :', model.score(training_df_X, training_df_y))
print('Test accuracy :', model.score(test_df_X, test_df_y))
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