mxnet学习(8):Trainer

本文详细介绍了MXNet中的Gluon Trainer类,它用于结合autograd进行参数优化。Trainer接受一个优化器、参数字典和其他配置选项。同时,文章提到了Optimizer类,它是所有优化算法的基础,包括学习率调整、权重衰减等。还讨论了LRScheduler和FactorScheduler类,用于动态调整学习率。学习率调度器可以根据步数线性或恒定地增减学习率,以改善训练过程。
摘要由CSDN通过智能技术生成

class mxnet.gluon.Trainer(params, optimizer, optimizer_params = None, kvstore = ‘device’, compression_params = None, updata_on_kvstore = None)

参考:http://mxnet.incubator.apache.org/versions/master/api/python/gluon/gluon.html?highlight=trainer#mxnet.gluon.Trainer

该类将一个优化器应用于一套参数,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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值