当前位置:   article > 正文

Pytorch版本代码修正_userwarning: nn.init.xavier_uniform is now depreca

userwarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xa
Pytorch版本代码修正

概述:老版本代码(0.3.0)修正为(0.4.0)

1.UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.init.xavier_uniform(param)
  • 1

注:init.xavier_uniform 改为 init.xavier_uniform_

2.UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead. targets = [Variable(anno.cuda(), volatile=True) for anno in targets]
  • 1

注:im = Variable(im.cuda(),volatile=True)
应该改成im = Variable(im.cuda())

3.UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  • 1

注:loss.data[0]
应该改成loss.item()

4.UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
  • 1

注:upsample 替换为interpolate

5.UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.warnings.warn(warning.format(ret))
  • 1

注:size_average=False 改为 reduction='sum’

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/375406
推荐阅读
相关标签
  

闽ICP备14008679号