Loicca 2020-06-07 15:46 采纳率: 0%
浏览 1970
已结题

使用nn.init自定义权重,总是报错Expected object of scalar type Double but got scalar type Float for argument #2 'weight' in call to _thnn_conv2d_forward

编程小白求大佬拯救!
最近为了毕设在做MobileNet的实验,在训练网络的时候通过nn.init自定义了权重,代码如下:

在这里插入图片描述

运行之后系统报错:

经过调试之后发现原代码里面的m.weight的dtype是tensor.float32,于是百度了很多改格式的方法,tensor.type(),tensor.double()啥的都用过了,还是没有用。有没有大神可以帮忙指条明路(被自己菜哭了)

  • 写回答

4条回答 默认 最新

  • threenewbee 2020-06-07 16:59
    关注

    这些问题归结起来都是类型不匹配的问题
    参考 https://blog.csdn.net/ljh618625/article/details/105230546/

    评论

报告相同问题?