UserWarning: This overload of add_ is deprecated

本文介绍了如何在PyTorch 1.5中处理关于`add_`和`addcmul_`方法的过时警告,通过提供更新后的代码示例来帮助开发者适应新的参数顺序。
部署运行你感兴趣的模型镜像

运行别人的代码碰到了两个 warning,虽然不影响使用,但是看着不舒服。

UserWarning: This overload of add_ is deprecated: add_(Number alpha, Tensor other) Consider using one of the following signatures instead: add_(Tensor other, *, Number alpha)

UserWarning: This overload of addcmul_ is deprecated: addcmul_(Number value, Tensor tensor1, Tensor tensor2) Consider using one of the following signatures instead: addcmul_(Tensor tensor1, Tensor tensor2, *, Number value)

原因:PyTorch 1.5 改变了方法的默认参数。

很容易解决,照着提示修改即可。

# 改之前
# next_m.mul_(beta1).add_(1 - beta1, grad)
# next_v.mul_(beta2).addcmul_(1 - beta2, grad, grad)

# 改之后
next_m.mul_(beta1).add_(grad, alpha=1 - beta1)
next_v.mul_(beta2).addcmul_(grad, grad, value=1 - beta2)

您可能感兴趣的与本文相关的镜像

PyTorch 2.7

PyTorch 2.7

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

(OmniRobCtrl) li@li-ASUS-TUF-Gaming-F15-FX507ZV4-FX507ZV4:~/Downloads/LocomotionWithNP3O-master$ python3 train.py --task=go2N3poHim Importing module 'gym_38' (/home/li/Downloads/isaacgym/python/isaacgym/_bindings/linux-x86_64/gym_38.so) Setting GYM_USD_PLUG_INFO_PATH to /home/li/Downloads/isaacgym/python/isaacgym/_bindings/linux-x86_64/usd/plugInfo.json PyTorch version 2.4.1 Device count 1 /home/li/Downloads/isaacgym/python/isaacgym/_bindings/src/gymtorch Using /home/li/.cache/torch_extensions/py38_cu121 as PyTorch extensions root... Emitting ninja build file /home/li/.cache/torch_extensions/py38_cu121/gymtorch/build.ninja... Building extension module gymtorch... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) ninja: no work to do. Loading extension module gymtorch... Setting seed: 1 Not connected to PVD +++ Using GPU PhysX Physics Engine: PhysX Physics Device: cuda:0 GPU Pipeline: enabled [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/base.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/hip.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/thigh.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/calf.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/foot.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/hip.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/thigh_mirror.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/calf_mirror.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/foot.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/hip.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/thigh.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/calf.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/foot.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/hip.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/thigh_mirror.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/calf_mirror.dae' [Error] [carb.gym.plugin] Failed to resolve visual mesh '/home/pi/Downloads/LocomotionWithNP3O-master/resources/go2/dae/foot.dae' body_names: ['base', 'FL_hip', 'FL_thigh', 'FL_calf', 'FL_foot', 'FR_hip', 'FR_thigh', 'FR_calf', 'FR_foot', 'Head_upper', 'Head_lower', 'RL_hip', 'RL_thigh', 'RL_calf', 'RL_foot', 'RR_hip', 'RR_thigh', 'RR_calf', 'RR_foot'] dof_names: ['FL_hip_joint', 'FL_thigh_joint', 'FL_calf_joint', 'FR_hip_joint', 'FR_thigh_joint', 'FR_calf_joint', 'RL_hip_joint', 'RL_thigh_joint', 'RL_calf_joint', 'RR_hip_joint', 'RR_thigh_joint', 'RR_calf_joint'] feet_names: ['FL_foot', 'FR_foot', 'RL_foot', 'RR_foot'] /home/li/anaconda3/envs/OmniRobCtrl/lib/python3.8/site-packages/torch/functional.py:513: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1724789259345/work/aten/src/ATen/native/TensorShape.cpp:3609.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
10-14
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值