Pytorch:CNN don';torch.cat()之后我什么也学不到?
我尝试用这样的代码连接网络中的变量Pytorch:CNN don';torch.cat()之后我什么也学不到?,pytorch,Pytorch,我尝试用这样的代码连接网络中的变量 x = self.layer1(x) x = self.layer2(x) x = self.layer3(x) x = self.layer4(x) x = x.view(x.size(0), -1) x= torch.cat((x,angle),1) # from here I concat it. x = self.dropout1(self.relu1(self.bn1(self.fc1(x))
x = self.layer1(x)
x = self.layer2(x)
x = self.layer3(x)
x = self.layer4(x)
x = x.view(x.size(0), -1)
x= torch.cat((x,angle),1) # from here I concat it.
x = self.dropout1(self.relu1(self.bn1(self.fc1(x))))
x = self.dropout2(self.relu2(self.bn2(self.fc2(x))))
x = self.fc3(x)
然后我发现我的网络什么都学不到,给acc 50%左右。所以我打印param.grad
,正如我所料,它们都是nan。以前有人遇到过这种事情吗
我以前在没有连接的情况下运行了代码,结果很好。所以我想这就是问题所在,系统不会抛出任何错误或异常。如果需要任何其他备份信息,请告诉我
谢谢。错误可能在您提供的代码之外。尝试检查输入中是否存在nan,并检查丢失函数是否没有导致nan。尝试调整超参数。您就在这里,我仔细检查了,结果发现它源自我自己数据中的几个nan值。谢谢大家!