2
我想使用MXNet深度學習庫來訓練我的20x20圖像數據集,您可以看到下面的代碼: 問題是當我運行它時,雖然它未顯示任何錯誤,它返回什麼,我的意思是它不顯示像任何處理:如何打印來自model.fit MXNet的處理步驟/報告Python
劃時代0:........精度:.....
劃時代1:.... ....精度:.....
那麼,我該如何讓它打印這樣的處理格式,或者哪裏可能會出現問題呢? 注:我試過各種回調API:http://mxnet.io/api/python/callback.html?fref=gc,他們都沒有給出任何迴應;代碼工作沒有錯誤,但沒有顯示處理步驟!
在此先感謝
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)