CNNTrainer.ftl 1.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)??>
        load_checkpoint = ${config.loadCheckpoint.value?string("True","False")},
</#if>
<#if (config.context)??>
        context = '${config.context.value}',
</#if>
<#if (config.normalize)??>
        normalize = ${config.normalize.value?string("True","False")},
</#if>
<#if (config.configuration.optimizer)??>
        optimizer = '${config.optimizerName}',
        optimizer_params = {
<#list config.optimizerParams?keys as param>
            '${param}': ${config.optimizerParams[param]}<#sep>,
</#list>
        }
</#if>
    )
</#list>