2

I am trying to train my 20x20 images dataset using MXNet deep learning library, you can see the code below: the question is when I run it, although it shows no errors it returns nothing, I mean it does not show any processing like :

epoch 0 : ........accuracy:.....

epoch 1 : ........accuracy:.....

so, how shall I make it print such processing format, or where might be the problem? Note: I tried all kinds of the Callback API:http://mxnet.io/api/python/callback.html?fref=gc and none of them are giving any response; the code work with no errors but no processing steps shown!

Thanks in advance

X_train = []
training_flatten_rows_mxnet_csv=np.loadtxt("training_set_flatten_rows_mxnet.csv", delimiter=",")
train_data = training_flatten_rows_mxnet_csv
X_train = train_data.reshape((training_counter,1,20,20))
Y_train = np.loadtxt("training_labels.csv", delimiter=",")

X_validate = []
validate_flatten_rows_mxnet_csv=np.loadtxt("validation_set_flatten_rows_mxnet.csv", delimiter=",")
validate_data = validate_flatten_rows_mxnet_csv
X_validate = validate_data.reshape((validate_counter,1,20,20))
Y_validate = np.loadtxt("validate_labels.csv", delimiter=",")

train_iterator = mx.io.NDArrayIter(X_train, Y_train, batch_size=batch_size,shuffle=True)#,last_batch_handle='discard')
validate_iterator = mx.io.NDArrayIter(X_validate, Y_validate, batch_size=batch_size,shuffle=True)

data = mx.sym.var('data')

conv1 = mx.sym.Convolution(data=data, kernel=(3,3), num_filter=6)
relu1 = mx.sym.Activation(data=conv1, act_type="relu")
pool1 = mx.sym.Pooling(data=relu1, pool_type="max", kernel=(2,2), stride=(2,2))

conv2 = mx.sym.Convolution(data=pool1, kernel=(6,6), num_filter=12)
relu2 = mx.sym.Activation(data=conv2, act_type="relu")
pool2 = mx.sym.Pooling(data=relu2, pool_type="max", kernel=(2,2), stride=(2,2))

flatten = mx.sym.flatten(data=pool2)
fc1 = mx.symbol.FullyConnected(data=flatten, num_hidden=12 )

lenet = mx.sym.SoftmaxOutput(data=fc1, name='softmax')

lenet_model = mx.mod.Module(symbol=lenet, context=mx.cpu())

lenet_model.fit(train_iterator,
                eval_data=validate_iterator,
                optimizer='sgd',
                optimizer_params={'learning_rate':0.1},
                eval_metric='acc',
                batch_end_callback =mx.callback.Speedometer(batch_size, 100),
                num_epoch=5)
esraa
  • 41
  • 5

1 Answers1

2

Solved add to your code these lines:

import logging
logging.getLogger().setLevel(logging.INFO)

for different types of processing report, refer to "Callback API in MXNet"

esraa
  • 41
  • 5