mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Prediction does not change after fit

Open hehaodele opened this issue 10 years ago • 4 comments

I try to load a checkpoint and continue tuning it, yet I encounter a strange situation that the model.arg_params changed. However, the predictions are exactly the same before and after model.fit. Following are the codes:

net, arg_params, arg_auxs = mx.model.load_checkpoint('PReluDrop500X100', 0)
model = mx.model.FeedForward(
    ctx = mx.gpu(0), num_epoch = m + 10, begin_epoch=m,
    symbol              = net,
    learning_rate       = args.lr,
    wd = 0.0001,
    optimizer           = 'adam',
    arg_params          = arg_params,
)

print model.arg_params['fc1_weight'].asnumpy()
print model.predict(np_to_mxIter(val, 1000)).flatten()[:10]
model.fit(X=trainIter,eval_metric=metricMSE,epoch_end_callback = do_checkpoint('PReluDrop500X100'))
print model.arg_params['fc1_weight'].asnumpy()
print model.predict(np_to_mxIter(val, 1000)).flatten()[:10]

Any ideas of this issue? Thanks.

hehaodele avatar Dec 20 '15 16:12 hehaodele

It seems is about your network and optimization problem. Try normalization of input, different optimizer, and different learning rate

antinucleon avatar Dec 20 '15 19:12 antinucleon

Close for now. Please feel free to reopen it if needed

winstywang avatar Jan 03 '16 13:01 winstywang

I have actually encountered the same problem. If I fit the model first, use predict to see the outcomes, continue to fit the model for additional rounds, I can clearly see that the arguments of the model change, nevertheless predictions stay the same.

Quares avatar Mar 05 '16 23:03 Quares

Adding an epoch end callback function to model.fit works for me. I guess the issue is due to asynchronous data in either MXNet engine or the Python interface. The callback function forces system to synchronize all the parameters.

GaiYu0 avatar Aug 19 '16 11:08 GaiYu0