Hi Brian!



 ApeelingPotato:

No matter what I do the predicted value comes out as 0
I think the problem I am having is with teaching the network.
            self.fc3 = nn.Linear(interneuron_count, 1)  # final fully connected layer with one output
...
            x = self.fc3(x)
            return F.log_softmax(x, dim=0)

When I test the NN using     print(net(test_inputs[0]))  I get
tensor([0.], grad_fn=<LogSoftmaxBackward>)


Your problem is that you are passing a length-one vector to
softmax().  softmax() returns a vector of probabilities that
sum to one.  Since there is only one probability in the sum, it
will always be 1.0.  log (1.0) = 0.0, so, analogously,
log_softmax() will always return 0.0.
If this network is for a binary classification problem, and your
single output is supposed to indicate whether your input is in
class-“0” or c;ass-“1”, then you should have
    return F.sigmoid (x)

and use BCELoss for your loss function (or just return x without
the sigmoid(), and use BCEWithLogitsLoss).
As an aside, in return F.log_softmax(x, dim=0), dim = 0 is
the batch dimension.  I’m guessing in the example you gave that
your batch size in 1.  If it did make sense to use log_softmax()
(which it doesn’t, but would, for example, if your last layer were
Linear(interneuron_count, 10)) you would want something like
log_softmax(x, dim = 1) or log_softmax(x, dim = -1).
Best.
K. Frank