Search code examples
mxnet

MXnet fine-tune save model


I'm using mxnet's fine-tune example to fine-tune my own data with this code:

https://github.com/dmlc/mxnet/blob/master/example/image-classification/fine-tune.py

By viewing common/fit.py, I got no idea of how to save temp model when I fine tuning.

For example, I wanna save .params files every 5000 iters, how can I do it? THX!


Solution

  • http://mxnet.io/api/python/callback.html

    Try to use the mx.callback API.

    module.fit(iterator, num_epoch=n_epoch,
    ... epoch_end_callback  = mx.callback.do_checkpoint("mymodel", 1))
    Start training with [cpu(0)]
    Epoch[0] Resetting Data Iterator
    Epoch[0] Time cost=0.100
    Saved checkpoint to "mymodel-0001.params"
    Epoch[1] Resetting Data Iterator
    Epoch[1] Time cost=0.060
    Saved checkpoint to "mymodel-0002.params"