rasbt / machine-learning-book

Code Repository for Machine Learning with PyTorch and Scikit-Learn
https://sebastianraschka.com/books/#machine-learning-with-pytorch-and-scikit-learn
MIT License
3.64k stars 1.31k forks source link

CH 13: Changing the order of the cells gives different results. Pg 420 - 422 #83

Closed OmarAlmighty closed 2 years ago

OmarAlmighty commented 2 years ago

In the Solving an XOR classification problem section, the author defined the model, then defined the loss function and the optimizer, then created the data loader. Finally, he defined the training function followed by plotting the results. If I follow this same sequence, I get this figure image This figure is different from what is shown in the book!

However, in the notebook, the author defined the data loader, then the model, then the loss function and the optimizer, followed by the training and plotting procedures. That it, he defined the data loader first instead of being before the training procedure.

Can anyone please explain why changing the order of the cells causes such error?

rasbt commented 2 years ago

Hm that's weird. I must admit that I've never seen a loss or accuracy plot that looks like a step-wise function. Did you maybe call plt.step instead of plt.plot?

OmarAlmighty commented 2 years ago

Hi Sebastian, I did several experiments and concluded that there was a problem with the IDE, VS code. I restarted the IDE and my machine, then the code worked as supposed to be.

Thank you so much for your consideration!