class mxnet.gluon.Trainer(params, optimizer, optimizer_params = None, kvstore = ‘device’, compression_params = None, updata_on_kvstore = None)
该类将一个优化器应用于一套参数,trainer应该与autograd一起使用.
参数
- params 参数字典,可以通过net.collect_params()指定需要优化的参数
- optimizer string或者mxnet.optimizer.Optimizer类的对象。使用字符串如’sgd’
- optimizer_params 字典,key会传递给optimizer,比如
learning_rate, wd(weight decay), clip_gradient, lr_scheduler
等,更多可以参考optimizer的constructor。 - kvstore (str or KVStore) – kvstore type for multi-gpu and distributed training. See help on mxnet.kvstore.create for more information.
compression_params (dict) – Specifies type of gradient compression and additional arguments depending on the type of compression being used. For example, 2bit compression requires a threshold. Arguments would then be {‘type’:‘2bit’, ‘threshold’:0.5} See mxnet.KVStore.set_gradient_compression method for more details on gradient compression. - update_on_kvstore (bool, default None) – Whether to perform parameter updates on kvstore. If None, then trainer will choose the more suitable option depending on the type of kvstore. If the update_on_kvstore argument is provided, environment variable MXNET_UPDATE_ON_KVSTORE will be ignored.
- Properties –
---------- – - learning_rate (float) – The current learning rate of the optimizer. Given an Optimizer object optimizer, its learn