Exemple #1
0
minibatch_size = 64

#create network & trainer
network = FCNN_SoftmaxCE(2, [100, 100],
                         2, ['Relu', 'Relu'],
                         weight_init_std='he')
trainer = Trainer(network,
                  X_train,
                  Y_train,
                  X_val,
                  Y_val,
                  num_epoch,
                  minibatch_size,
                  'adam', {'lr': 0.01},
                  verbose=True,
                  LossAccInterval=10)

#start training network
train_loss_list, val_loss_list, train_acc_list, val_acc_list, x, lrs = trainer.train(
)
#network training finished

#feed the trained final network, whole moon data in order to visualize the result
draw_border(network,
            X_train,
            Y_train,
            X_val,
            Y_val,
            0.01,
            c_map='viridis',
            c_edge='black')
                   minibatch_size,
                   'sgd', {'lr': 0.2901},
                   verbose=True,
                   LossAccInterval=10)
trainer10 = Trainer(network10,
                    X_train,
                    Y_train,
                    X_val,
                    Y_val,
                    num_epoch,
                    minibatch_size,
                    'sgd', {'lr': 0.35},
                    verbose=True,
                    LossAccInterval=10)

train_loss_list_1, val_loss_list_1, train_acc_list_1, val_acc_list_1, x, lrs_1 = trainer1.train(
)
train_loss_list_2, val_loss_list_2, train_acc_list_2, val_acc_list_2, x, lrs_2 = trainer2.train(
)
train_loss_list_3, val_loss_list_3, train_acc_list_3, val_acc_list_3, x, lrs_3 = trainer3.train(
)
train_loss_list_4, val_loss_list_4, train_acc_list_4, val_acc_list_4, x, lrs_4 = trainer4.train(
)
train_loss_list_5, val_loss_list_5, train_acc_list_5, val_acc_list_5, x, lrs_5 = trainer5.train(
)
train_loss_list_6, val_loss_list_6, train_acc_list_6, val_acc_list_6, x, lrs_6 = trainer6.train(
)
train_loss_list_7, val_loss_list_7, train_acc_list_7, val_acc_list_7, x, lrs_7 = trainer7.train(
)
train_loss_list_8, val_loss_list_8, train_acc_list_8, val_acc_list_8, x, lrs_8 = trainer8.train(
)
train_loss_list_9, val_loss_list_9, train_acc_list_9, val_acc_list_9, x, lrs_9 = trainer9.train(
                          minibatch_size,
                          'adam', {'lr': 0.001},
                          verbose=True,
                          LossAccInterval=100)
trainer_increase = Trainer(network_increase,
                           X_train_extended,
                           Y_train_extended,
                           X_val,
                           Y_val,
                           num_epoch,
                           minibatch_size,
                           'adam', {'lr': 0.001},
                           verbose=True,
                           LossAccInterval=100)

train_loss_list_augment, val_loss_list_augment, train_acc_list_augment, val_acc_list_augment, x, lrs = trainer_augment.train(
)
train_loss_list_increase, val_loss_list_increase, train_acc_list_increase, val_acc_list_increase, x, lrs = trainer_increase.train(
)

trainLoss_aug = go.Scatter(x=x,
                           y=train_loss_list_augment,
                           mode='lines',
                           name='augment',
                           line=dict(color=('rgb(232, 85, 85)')))
valLoss_aug = go.Scatter(x=x,
                         y=val_loss_list_augment,
                         mode='lines',
                         name='augment',
                         line=dict(color=('rgb(232, 85, 85)'), dash='dash'))
trainAcc_aug = go.Scatter(x=x,
                          y=train_acc_list_augment,
Exemple #4
0
                              weight_init_std='he',
                              use_dropout=True,
                              use_batchnorm=True,
                              keep_probs=[0.9, 0.9],
                              batchnorm_prev=True)
trainer_prev = Trainer(network_prev,
                       X_train,
                       Y_train,
                       X_val,
                       Y_val,
                       num_epoch,
                       minibatch_size,
                       optimizer_type, {'lr': learning_rate},
                       verbose=True,
                       LossAccInterval=5)
train_loss_list_prev, val_loss_list_prev, train_acc_list_prev, val_acc_list_prev, x_axis, lrs = trainer_prev.train(
)

network_after = FCNN_SoftmaxCE(784, [256, 256],
                               10, ['Relu', 'Relu'],
                               weight_init_std='he',
                               use_dropout=True,
                               use_batchnorm=True,
                               keep_probs=[0.9, 0.9],
                               batchnorm_prev=False)
trainer_after = Trainer(network_after,
                        X_train,
                        Y_train,
                        X_val,
                        Y_val,
                        num_epoch,
                        minibatch_size,
Exemple #5
0
                          10, ['Relu', 'Relu', 'Relu', 'Relu', 'Relu'],
                          weight_init_std='he',
                          use_dropout=True,
                          use_batchnorm=True,
                          keep_probs=[0.9, 0.9, 0.9, 0.9, 0.9])
trainer1 = Trainer(network1,
                   X_train,
                   Y_train,
                   X_val,
                   Y_val,
                   num_epoch,
                   minibatch_size,
                   optimizer_type1, {'lr': learning_rate},
                   verbose=True,
                   LossAccInterval=20)
train_loss_list1, val_loss_list1, train_acc_list1, val_acc_list1, x_axis, lrs = trainer1.train(
)

network2 = FCNN_SoftmaxCE(784, [256, 256, 256, 256, 256],
                          10, ['Relu', 'Relu', 'Relu', 'Relu', 'Relu'],
                          weight_init_std='he',
                          use_dropout=True,
                          use_batchnorm=True,
                          keep_probs=[0.9, 0.9, 0.9, 0.9, 0.9])
trainer2 = Trainer(network2,
                   X_train,
                   Y_train,
                   X_val,
                   Y_val,
                   num_epoch,
                   minibatch_size,
                   optimizer_type2, {'lr': learning_rate},