Hello Ra!



 Ra-V:

I’ve made suggested corrections, but unfortunately the network still doesn’t learn anything, and now it started to classify all observations to class 0, which has resulted in even worse accuracy. I’ve used binary_cross_entropy_with_logits as loss function, with one dimension of outputs of last linear layer of the network without passing it into sigmoid function, but directly to loss function


You didn’t mention it, but did you also change the y_batch you pass
to your binary_cross_entropy_with_logits loss_function?
The individual target samples in your y_batch should now be single
class labels that are either 0 or 1.  (They could be probabilities
between 0 and 1, but I’m guessing you’re not doing that.)
Other than that, things look right.  I don’t see anything wrong with
your code (but I miss things all the time).  In any event, as a general
debugging practice, you should go over your code with a fine-tooth
comb, and maybe print out some intermediate results here and there
to make sure things look like what you expect.
About the data, am I correct that a single input sample (an element
of x_batch) has four “features,” that is, consists of four numbers?
And that a single target sample (an element of y_batch) consists
of a single 0-or-1 class label?
If you look at the data manually, can you classify it?  Is the problem
clearly doable, or does it look hard or impossible?  You mention a
“randomly generated dataset.”  If it’s really random (depending what
you mean by that), maybe there isn’t really any link between the
samples (x_batch) and the labels (y_batch), so you’d be trying
to build a classifier for random noise.
What happens if you make your own data in the same format as
the data you’re working with, but obviously and easily classifiable?
(For example, you could generate your four “features” randomly,
and set class = 1 when sum (features) > 0, and class = 0,
otherwise.)  Does your network train successfully on trivial data?
What is your batch size?  Have you tried running with a smaller and
larger learning_rate?  num_epoch = 100 seems like it should be
enough to at least see something for a problem of this size, but have
you tried running for a lot more epochs?
Good luck!
K. Frank