CNNTrainer_fullConfig.py 1.43 KB
Newer Older
1 2
import logging
import mxnet as mx
3
import CNNCreator_fullConfig
Nicola Gatto's avatar
Nicola Gatto committed
4
import CNNDataLoader_fullConfig
5
import CNNSupervisedTrainer_fullConfig
6 7 8 9

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger()
10
    handler = logging.FileHandler("train.log", "w", encoding=None, delay="true")
11 12
    logger.addHandler(handler)

Nicola Gatto's avatar
Nicola Gatto committed
13
    fullConfig_creator = CNNCreator_fullConfig.CNNCreator_fullConfig()
14 15 16 17 18
    fullConfig_loader = CNNDataLoader_fullConfig.CNNDataLoader_fullConfig()
    fullConfig_trainer = CNNSupervisedTrainer_fullConfig.CNNSupervisedTrainer_fullConfig(
        fullConfig_loader,
        fullConfig_creator
    )
Nicola Gatto's avatar
Nicola Gatto committed
19 20

    fullConfig_trainer.train(
21 22 23 24 25 26
        batch_size=100,
        num_epoch=5,
        load_checkpoint=True,
        context='gpu',
        normalize=True,
        eval_metric='mse',
Eyüp Harputlu's avatar
Eyüp Harputlu committed
27 28 29 30
        loss='softmax_cross_entropy',
        loss_params={
            'sparse_label': True,
            'from_logits': False},
31 32
        optimizer='rmsprop',
        optimizer_params={
33 34 35 36 37 38 39 40 41 42 43 44
            'weight_decay': 0.01,
            'centered': True,
            'gamma2': 0.9,
            'gamma1': 0.9,
            'clip_weights': 10.0,
            'learning_rate_decay': 0.9,
            'epsilon': 1.0E-6,
            'rescale_grad': 1.1,
            'clip_gradient': 10.0,
            'learning_rate_minimum': 1.0E-5,
            'learning_rate_policy': 'step',
            'learning_rate': 0.001,
45
            'step_size': 1000}
46
    )