CNNTrainer.ftl 1.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import logging
import mxnet as mx
<#list configurations as config>
import CNNCreator_${config.instanceName}
</#list>

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

<#list configurations as config>
    ${config.instanceName} = CNNCreator_${config.instanceName}.CNNCreator_${config.instanceName}()
    ${config.instanceName}.train(
<#if (config.batchSize)??>
        batch_size = ${config.batchSize},
</#if>
<#if (config.loadCheckpoint)??>
20
        load_checkpoint = ${config.loadCheckpoint?string("True","False")},
21
22
</#if>
<#if (config.context)??>
23
        context = '${config.context}',
24
25
</#if>
<#if (config.normalize)??>
26
        normalize = ${config.normalize?string("True","False")},
27
28
29
30
31
32
33
34
35
36
37
</#if>
<#if (config.configuration.optimizer)??>
        optimizer = '${config.optimizerName}',
        optimizer_params = {
<#list config.optimizerParams?keys as param>
            '${param}': ${config.optimizerParams[param]}<#sep>,
</#list>
        }
</#if>
    )
</#list>