mxnet gluon解决报错:UserWarning: Gradient of Parameter `net0_dense0_weight` in context gpu(0)

  完整报错如下:

UserWarning: Gradient of Parameter bisruaudio0_dense0_weight on context gpu(0) has not been updated by backward since last step. This could mean a bug in your model that maked it only use a subset of the Parameters (Blocks) for this iteration. If you are intentionally only using a subset, call step with ignore_stale_grad=True to suppress this warning and skip updating of Parameters with stale gradient

  错误部分的代码在这里,因为切片(slice)操作,不能反向求梯度(autograd)。

    def forward(self, x, y, z):
        x = self.dense1(x)
        z[0:10] = x
        z[10:20] = y
        x = self.dense2(z)
        return x

  改正如下:利用nd.concat来拼接,而不是用slice。

   def forward(self, x, y):
        x = self.dense1(x)
        x = nd.concat(x, y, dim=0)
        x = self.dense2(x)
        return x
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值