I want each epoch information to be stored in a log file to see the accuracy versus epoch, but I am not able to log. Why?
mnist = mx.test_utils.get_mnist()
batch_size = 100
print(os.getcwd())
log_file = '1.log'#''process_fold_' + str(0) + '_trial_' + str(1) + '.log'
logging.basicConfig(format='%(asctime)s %(levelname)s - %(message)s', datefmt='%d/%m/%Y %I:%M:%S %p', filename=log_file, level=logging.INFO)
logging.info('Started training on fold {} at trial {}'.format(0, 0))
train_iter = mx.io.NDArrayIter(mnist['train_data'],mnist['train_label'], batch_size, shuffle=True)
val_iter = mx.io.NDArrayIter(mnist['test_data'], mnist['test_label'],
batch_size) # important as the prediction need not have equal barch size
lenet =get_my_net()
# create a trainable module on GPU 0
lenet_model = mx.mod.Module(symbol=lenet, context=mx.gpu(),logger=logzulu)
# train with the same
lenet_model.fit(train_iter,
eval_data=val_iter,
optimizer='sgd',
optimizer_params={'learning_rate':0.1},
eval_metric='acc',
batch_end_callback = mx.callback.Speedometer(batch_size, 100),
num_epoch=10,
initializer=mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2))
test_iter = mx.io.NDArrayIter(mnist['test_data'], None, batch_size)