简体   繁体   English

Pytorch卷积层返回Nan

[英]Pytorch Convolutional Layer returning Nan

so I am using a convolutional layer as the first layer of a neural network for deep reinforcement learning to get the spatial features out of a simulation I built. 因此,我将卷积层用作神经网络的第一层,以进行深度强化学习,以从我建立的模拟中获得空间特征。 The simulation gives different maps that are of different lengths and heights to process. 该模拟给出了要处理的具有不同长度和高度的不同地图。 If I understand convolutional networks, this should not matter since the channel size is kept constant. 如果我了解卷积网络,那么这无关紧要,因为通道大小保持恒定。 In between the convolutional network and the fully connected layers there is a spatial pyramid pooling layer so that the varying image sizes does not matter. 在卷积网络和完全连接的层之间,存在一个空间金字塔池化层,因此变化的图像大小无关紧要。 Also the spatial data is pretty sparse. 而且空间数据非常稀疏。 Usually it is able to go through a few states and sometimes a few episodes before the first convolutional layer spits out all Nans. 通常,在第一个卷积层吐出所有Nans之前,它能够经历一些状态,有时甚至是几集。 Even when I fix the map size this happens. 即使我固定了地图大小,也会发生这种情况。 I do not know where the problem lies, where can the problem lie? 我不知道问题出在哪里,问题出在哪里?

Try to initialize your weights with random numbers between 0 and 1 and then try different learning rates for your network training. 尝试使用0到1之间的随机数初始化权重,然后为网络训练尝试不同的学习率。 (I suggest test it with learning rates equal to 10, 1, 0.1, 0.01, ...) (我建议以等于10、1、0.1、0.01等的学习率对其进行测试。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM