Thanks, that helped with the size issue, however the loss seems to be shrinking for a couple of instances, then it goes to infinity and then to nan, where it stays for the rest of the runtime.
EDIT: changing the learning rate helped with that. However the loss seems to be jumping around, not descreasing too much, and it gets way outside 0-1 range