def forward(self, x):

        hidden_inputs = self.hidden(x)

        hidden_outputs = self.sigmoid(hidden_inputs)

        final_inputs = self.output(hidden_outputs)

        final_outputs = self.softmax(final_inputs)

        return final_outputs


torch.isnan(self.features).any() # false
label_predict = self.forward(self.features)
torch.isnan(label_predict).any() # true


I checked, and it’s the nn.linear causing the output to be nan. Why is that and how can I fix that?