added new model, with different hyperparameter from dd3d git
parent
860e797732
commit
bb9a7f549e
|
|
@ -16,7 +16,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -28,8 +28,9 @@
|
|||
"from keras.layers import Dense, Flatten, TimeDistributed, Dropout\n",
|
||||
"from keras import Input, Model\n",
|
||||
"from keras.layers import add, Activation\n",
|
||||
"from keras.layers.advanced_activations import LeakyReLU\n",
|
||||
"#from keras.utils import plot_model # Needs pydot.\n",
|
||||
"from keras.layers import Conv3D, MaxPooling3D"
|
||||
"from keras.layers import Convolution3D, MaxPooling3D"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -162,6 +163,43 @@
|
|||
" return model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def model_new(): # créer un objet modèle\n",
|
||||
" \"\"\"\n",
|
||||
" Return a simple sequentiel model\n",
|
||||
" \n",
|
||||
" Returns :\n",
|
||||
" - model : keras.Model\n",
|
||||
" \"\"\"\n",
|
||||
" inputs = Input(shape=(14,32,32,32))\n",
|
||||
" conv_1 = Convolution3D(filters=64, kernel_size=5, padding=\"valid\", data_format='channels_first')(inputs)\n",
|
||||
" activation_1 = LeakyReLU(alpha = 0.1)(conv_1)\n",
|
||||
" drop_1 = Dropout(0.2)(activation_1)\n",
|
||||
" conv_2 = Convolution3D(filters=64, kernel_size=3, padding=\"valid\", data_format='channels_first')(drop_1)\n",
|
||||
" activation_2 = LeakyReLU(alpha = 0.1)(conv_2)\n",
|
||||
" maxpool = MaxPooling3D(pool_size=(2,2,2),\n",
|
||||
" strides=None,\n",
|
||||
" padding='valid',\n",
|
||||
" data_format='channels_first')(activation_2)\n",
|
||||
" drop_2 = Dropout(0.4)(maxpool)\n",
|
||||
" flatters = Flatten()(drop_2)\n",
|
||||
" dense = Dense(128)(flatters)\n",
|
||||
" activation_3 = LeakyReLU(alpha = 0.1)(dense)\n",
|
||||
" drop_3 = Dropout(0.4)(activation_3)\n",
|
||||
" output = Dense(3, activation='softmax')(drop_3)\n",
|
||||
" model = Model(inputs=inputs, outputs=output)\n",
|
||||
" my_opt = optimizers.Adam(learning_rate=0.000001, beta_1=0.9, beta_2=0.999, amsgrad=False)\n",
|
||||
" print(model.summary)\n",
|
||||
" model.compile(optimizer=my_opt, loss=\"categorical_crossentropy\",\n",
|
||||
" metrics=[\"accuracy\"])\n",
|
||||
" return model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
|
@ -250,7 +288,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"my_model = model_light()"
|
||||
"my_model = model_new()"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -270,7 +308,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"history_mild_2mp = mild_model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=30, batch_size=32)\n",
|
||||
"my_model.save('light_model_2mp_e30_b32.h5')"
|
||||
"my_model.save('new_model_e30_b32_t1000.h5')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
45
DeepDrug.py
45
DeepDrug.py
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# ## Importing library
|
||||
|
||||
# In[ ]:
|
||||
# In[6]:
|
||||
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -16,8 +16,9 @@ from keras import optimizers, callbacks
|
|||
from keras.layers import Dense, Flatten, TimeDistributed, Dropout
|
||||
from keras import Input, Model
|
||||
from keras.layers import add, Activation
|
||||
from keras.layers.advanced_activations import LeakyReLU
|
||||
#from keras.utils import plot_model # Needs pydot.
|
||||
from keras.layers import Conv3D, MaxPooling3D
|
||||
from keras.layers import Convolution3D, MaxPooling3D
|
||||
|
||||
|
||||
# ### used to store model prediction in order to plot roc curve
|
||||
|
|
@ -126,6 +127,40 @@ def model_heavy(): # créer un objet modèle
|
|||
return model
|
||||
|
||||
|
||||
# In[8]:
|
||||
|
||||
|
||||
def model_new(): # créer un objet modèle
|
||||
"""
|
||||
Return a simple sequentiel model
|
||||
|
||||
Returns :
|
||||
- model : keras.Model
|
||||
"""
|
||||
inputs = Input(shape=(14,32,32,32))
|
||||
conv_1 = Convolution3D(filters=64, kernel_size=5, padding="valid", data_format='channels_first')(inputs)
|
||||
activation_1 = LeakyReLU(alpha = 0.1)(conv_1)
|
||||
drop_1 = Dropout(0.2)(activation_1)
|
||||
conv_2 = Convolution3D(filters=64, kernel_size=3, padding="valid", data_format='channels_first')(drop_1)
|
||||
activation_2 = LeakyReLU(alpha = 0.1)(conv_2)
|
||||
maxpool = MaxPooling3D(pool_size=(2,2,2),
|
||||
strides=None,
|
||||
padding='valid',
|
||||
data_format='channels_first')(activation_2)
|
||||
drop_2 = Dropout(0.4)(maxpool)
|
||||
flatters = Flatten()(drop_2)
|
||||
dense = Dense(128)(flatters)
|
||||
activation_3 = LeakyReLU(alpha = 0.1)(dense)
|
||||
drop_3 = Dropout(0.4)(activation_3)
|
||||
output = Dense(3, activation='softmax')(drop_3)
|
||||
model = Model(inputs=inputs, outputs=output)
|
||||
my_opt = optimizers.Adam(learning_rate=0.000001, beta_1=0.9, beta_2=0.999, amsgrad=False)
|
||||
print(model.summary)
|
||||
model.compile(optimizer=my_opt, loss="categorical_crossentropy",
|
||||
metrics=["accuracy"])
|
||||
return model
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
|
|
@ -191,7 +226,7 @@ Y_test = output[1000:,]
|
|||
# In[ ]:
|
||||
|
||||
|
||||
my_model = model_light()
|
||||
my_model = model_new()
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
|
@ -204,8 +239,8 @@ tf.test.is_gpu_available()
|
|||
# In[ ]:
|
||||
|
||||
|
||||
history_mild_2mp = my_model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=30, batch_size=32)
|
||||
my_model.save('light_model_2mp_e30_b32.h5')
|
||||
history_mild_2mp = mild_model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=30, batch_size=32)
|
||||
my_model.save('new_model_e30_b32_t1000.h5')
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
|
|
|||
Loading…
Reference in New Issue