我是靠谱客的博主 要减肥萝莉,这篇文章主要介绍使用torch.nn.BatchNorm1d出现Tensor for argument #2 ‘weight‘ is on CPU, but expected it to on GPU错误,现在分享给大家,希望可以做个参考。
st_gcn网络定义中使用了torch.nn.BatchNorm1d,在运行网络时出现RuntimeError: Tensor for argument #2 'weight' is on CPU, but expected it to be on GPU (while checking arguments for cudnn_batch_norm)
论坛中的解释是因为在forward函数中直接定义并使用了一个函数,但是源代码中是在__init__函数中定义,forward函数中再使用的
github上好像说是batchnorm1d的通病
最后在__init__函数中将定义的函数转到GPU上得到解决
self.data_bn = nn.BatchNorm1d(in_channels * A.size(1))
self.data_bn.cuda()
最后
以上就是要减肥萝莉最近收集整理的关于使用torch.nn.BatchNorm1d出现Tensor for argument #2 ‘weight‘ is on CPU, but expected it to on GPU错误的全部内容,更多相关使用torch.nn.BatchNorm1d出现Tensor内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复