Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pytorch:CNN don';torch.cat()之后我什么也学不到?_Pytorch - Fatal编程技术网

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值。谢谢大家!