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.39k stars 1.24k forks source link

Issue with chapter 15 Sentiment Analysis with LSTM. Getting 100% accuracy while training. #135

Closed sabre-code closed 1 year ago

sabre-code commented 1 year ago

Hello @rasbt. I am facing some issue with chapter 15 part 2 notebook. I tried running the notebook on colab. Issues:

  1. According to the book the IMDB test data should have 25k samples. Currently the IMDB test data has 12.5k samples.
  2. Need for installation of portalocker.
  3. While training I am getting 100% validation accuracy right from from first epoch. (100% accuracy for all further epochs), and the test accuracy is also 100%. Screenshot 2023-07-15 175804
rasbt commented 1 year ago

Hi there,

I think that's because there were a few changes in torchtext. In order to reproduce the results in the book, you can try

pip install torchtext==0.10.0

to install the version I used in the book from https://pypi.org/project/torchtext/0.10.0/

sabre-code commented 1 year ago

Hello I just tried installing the said version but torch text 0.10.0 seems unavailable.

rasbt commented 1 year ago

I can confirm. It jumps from 0.6 to 0.12. They must have removed this version. This is so weird. It's still available online but it seems that there is no source file anymore: https://pypi.org/project/torchtext/0.10.0/#files

Screenshot 2023-07-15 at 11 33 55 AM
sabre-code commented 1 year ago

I guess changing the code to suit the new torchtext is only option. Will try that.

rasbt commented 1 year ago

Yeah, that might be the unfortunate consequence of that. Sorry about that! I am a bit hesitant to update the original notebook since it would then be different from the book text, which could be confusing for some. But if you get it to work with a newer version, I'd appreciate a PR. We could include this as an alternative notebook here on GitHub and then link it from the original one.

sabre-code commented 1 year ago

Surely I will work on it.

sabre-code commented 1 year ago

Hello, I have created PR please check.