Error 59 is notoriously non-informative.  Are you, by chance, using a pre-trained model when you get this error?  I had a similar issue until I adjusted the number of outputs in the last layer to match the number of classes in my dataset.