geoffwoollard / ece1512_project

0 stars 0 forks source link

drop rate #20

Open geoffwoollard opened 5 years ago

geoffwoollard commented 5 years ago

Results from the drop rate on the noise threshold problem at snr=0.1

model = deepconsensus_layers_wrapper(
    input_shape=X_val.shape[1::],
    num_hidden_layers=4,

    conv2d1_k=(30,15,7,3),
    conv2d2_k=(30,15,7,3),
    conv2d1_n=(8,8,32,64),
    conv2d2_n=(8,16,32,64),
    mp_k=(3,3,3,4),
    mp_strides=(4,4,2,2),
  pooling_type=('max','max','max','av'),
  dense13_n=512,
    dropout13_rate=0.25
)
from sklearn.metrics import roc_curve, auc
from keras.models import model_from_yaml

tprs, fprs, thresholds, roc_aucs={}, {}, {}, {}

timestr = time.strftime('%Y%m%d-%H%M')
for epoch in range(0,3):
    print('epoch %i' % epoch)
    model.fit_generator(fit_generator_helper.image_loader(df_train,batch_size=batch_size,nx=nx,ny=ny,crop_n=256),
                    steps_per_epoch=steps_per_epoch, # steps_per_epoch is number of batches per epoch
                    epochs=1,
                   )
    scores = model.evaluate(X_val, Y_val)
    print("%s: %.2f%%" % (model.metrics_names[1], scores[1] * 100))

    roc_aucs[epoch],fprs[epoch], tprs[epoch], thresholds[epoch] = roc_auc(X_val,Y_val,model)
    print('auc=%.2f'%roc_aucs[epoch])

    title='models/model-sc-nt0.1-J159-J160-drop0.25-0.77Mparams-ep-%s-' % epoch
    model_yaml = model.to_yaml()
    with open(title+timestr+'.yaml', "w") as yaml_file:
        yaml_file.write(model_yaml)
    model.save_weights(title+timestr+".h5")
epoch 0
Epoch 1/1
18/18 [==============================] - 152s 8s/step - loss: 0.7650 - categorical_accuracy: 0.5261
200/200 [==============================] - 6s 30ms/step
categorical_accuracy: 46.50%
auc=0.38
epoch 1
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.6429 - categorical_accuracy: 0.6089
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.69
epoch 2
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.4125 - categorical_accuracy: 0.8278
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.77
epoch 3
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.2902 - categorical_accuracy: 0.8828
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.89
epoch 4
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.1968 - categorical_accuracy: 0.9333
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.74
epoch 5
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.1128 - categorical_accuracy: 0.9661
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.72
epoch 6
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0150 - categorical_accuracy: 0.9978
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.87
epoch 7
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0050 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.87
epoch 8
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0032 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.89
epoch 9
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0025 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.90
geoffwoollard commented 5 years ago

0.75

for epoch in range(10):
    print('epoch %i' % epoch)
    model.fit_generator(fit_generator_helper.image_loader(df_train,batch_size=batch_size,nx=nx,ny=ny,crop_n=256),
                    steps_per_epoch=steps_per_epoch, # steps_per_epoch is number of batches per epoch
                    epochs=1,
                   )
    scores = model.evaluate(X_val, Y_val)
    print("%s: %.2f%%" % (model.metrics_names[1], scores[1] * 100))

    roc_aucs[epoch],fprs[epoch], tprs[epoch], thresholds[epoch] = roc_auc(X_val,Y_val,model)
    print('auc=%.2f'%roc_aucs[epoch])

    title='models/model-sc-nt0.1-J159-J160-drop0.75-0.77Mparams-ep-%s-' % epoch
    model_yaml = model.to_yaml()
    with open(title+timestr+'.yaml', "w") as yaml_file:
        yaml_file.write(model_yaml)
    model.save_weights(title+timestr+".h5")

epoch 0
Epoch 1/1
18/18 [==============================] - 153s 9s/step - loss: 0.8318 - categorical_accuracy: 0.5233
200/200 [==============================] - 6s 30ms/step
categorical_accuracy: 46.50%
auc=0.48
epoch 1
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.6731 - categorical_accuracy: 0.5972
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.74
epoch 2
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.4406 - categorical_accuracy: 0.8067
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.52
epoch 3
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.2888 - categorical_accuracy: 0.8800
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.50
epoch 4
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.2013 - categorical_accuracy: 0.9294
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.85
epoch 5
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.1910 - categorical_accuracy: 0.9328
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.92
epoch 6
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0189 - categorical_accuracy: 0.9994
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.94
epoch 7
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0094 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.96
epoch 8
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0061 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.96
epoch 9
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.0046 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 54.00%
auc=0.96
geoffwoollard commented 5 years ago

0.1

for epoch in range(0,10):
    print('epoch %i' % epoch)
    model.fit_generator(fit_generator_helper.image_loader(df_train,batch_size=batch_size,nx=nx,ny=ny,crop_n=256),
                    steps_per_epoch=steps_per_epoch, # steps_per_epoch is number of batches per epoch
                    epochs=1,
                   )
    scores = model.evaluate(X_val, Y_val)
    print("%s: %.2f%%" % (model.metrics_names[1], scores[1] * 100))

    roc_aucs[epoch],fprs[epoch], tprs[epoch], thresholds[epoch] = roc_auc(X_val,Y_val,model)
    print('auc=%.2f'%roc_aucs[epoch])

    title='models/model-sc-nt0.1-J159-J160-drop0.1-0.77Mparams-ep-%s-' % epoch
    model_yaml = model.to_yaml()
    with open(title+timestr+'.yaml', "w") as yaml_file:
        yaml_file.write(model_yaml)
    model.save_weights(title+timestr+".h5")

epoch 0
Epoch 1/1
18/18 [==============================] - 153s 9s/step - loss: 0.7949 - categorical_accuracy: 0.5094
200/200 [==============================] - 6s 30ms/step
categorical_accuracy: 46.50%
auc=0.80
epoch 1
Epoch 1/1
18/18 [==============================] - 153s 9s/step - loss: 0.5359 - categorical_accuracy: 0.7367
200/200 [==============================] - 6s 29ms/step
categorical_accuracy: 46.50%
auc=0.50
epoch 2
Epoch 1/1
18/18 [==============================] - 151s 8s/step - loss: 0.3631 - categorical_accuracy: 0.8450
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 61.50%
auc=0.88
epoch 3
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.2347 - categorical_accuracy: 0.9178
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 54.00%
auc=0.88
epoch 4
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.0979 - categorical_accuracy: 0.9772
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.38
epoch 5
Epoch 1/1
18/18 [==============================] - 148s 8s/step - loss: 0.0179 - categorical_accuracy: 0.9983
200/200 [==============================] - 5s 27ms/step
categorical_accuracy: 53.50%
auc=0.65
epoch 6
Epoch 1/1
18/18 [==============================] - 147s 8s/step - loss: 0.0043 - categorical_accuracy: 1.0000
200/200 [==============================] - 5s 27ms/step
categorical_accuracy: 53.50%
auc=0.76
epoch 7
Epoch 1/1
18/18 [==============================] - 147s 8s/step - loss: 0.0031 - categorical_accuracy: 1.0000
200/200 [==============================] - 5s 27ms/step
categorical_accuracy: 53.50%
auc=0.84
epoch 8
Epoch 1/1
18/18 [==============================] - 147s 8s/step - loss: 0.0024 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.87
epoch 9
Epoch 1/1
18/18 [==============================] - 147s 8s/step - loss: 0.0020 - categorical_accuracy: 1.0000
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.88
geoffwoollard commented 5 years ago

0.9

epoch 0
Epoch 1/1
18/18 [==============================] - 152s 8s/step - loss: 0.9605 - categorical_accuracy: 0.5156
200/200 [==============================] - 6s 31ms/step
categorical_accuracy: 45.00%
auc=0.50
epoch 1
Epoch 1/1
18/18 [==============================] - 148s 8s/step - loss: 0.7372 - categorical_accuracy: 0.5133
200/200 [==============================] - 5s 27ms/step
categorical_accuracy: 46.50%
auc=0.64
epoch 2
Epoch 1/1
18/18 [==============================] - 148s 8s/step - loss: 0.6989 - categorical_accuracy: 0.5406
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.79
epoch 3
Epoch 1/1
18/18 [==============================] - 150s 8s/step - loss: 0.6238 - categorical_accuracy: 0.6433
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.50
epoch 4
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.4581 - categorical_accuracy: 0.7956
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.50
epoch 5
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.3659 - categorical_accuracy: 0.8511
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.50
epoch 6
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.2827 - categorical_accuracy: 0.8861
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 46.50%
auc=0.96
epoch 7
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.1989 - categorical_accuracy: 0.9378
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.93
epoch 8
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.1101 - categorical_accuracy: 0.9689
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.86
epoch 9
Epoch 1/1
18/18 [==============================] - 149s 8s/step - loss: 0.0390 - categorical_accuracy: 0.9967
200/200 [==============================] - 6s 28ms/step
categorical_accuracy: 53.50%
auc=0.85