Skip to content Skip to sidebar Skip to footer

Why Does My Keras Model Train After I Load It, Even Though I Have Not Actually Supplied Any New Training Data?

I am trying to train and make predictions with an LSTM model using tf.keras. I have written code in two different files, LSTMTraining.py which trains the Keras Model (and save it t

Solution 1:

The problem's likely with your VSCode IDE, which takes additional configuring to work both with Python and its packages -- when you run one script, you may be running all the scripts, thus the seen behavior. A solution I'd recommend is switching to Spyder and installing your packages with Anaconda. Once you've installed both, search "anaconda command prompt" or "anaconda powershell" on your PC, and in the terminal, type:

conda update conda
conda update --all
conda install numpy # optional (sort of)
conda install matplotlib # optional (sort of)# SEE BELOW
conda install -c conda-forge keras
conda update --all# final 'cleanup' command - ensures package compatibility

If you plan on using a GPU (highly recommended), you'll need to first download CUDA - instructions here (get CUDA 10 instead of 9 in the article). Then run conda install tensorflow-gpu as in the article.

Then, in Spyder: Tools -> Preferences -> PYTHONPATH manager -> add all folders of the modules/data you plan to use, so you don't have to %cd each time or worry about relative pathing and can import directly. Lastly, make sure Anaconda & Spyder use the right Python interpreter.

Restart Spyder, run scripts - assuming no bugs, all should be well.

Post a Comment for "Why Does My Keras Model Train After I Load It, Even Though I Have Not Actually Supplied Any New Training Data?"