OOPS I deleted it Again !!!

Param Saraf
2 min readNov 27, 2021

It’s Friday night and you started Training your Deep Learning Model. You spent your Weekends checking the Model progress and BAM !!! its done on Monday morning.

Excited about checking the Model Performance you quickly run your Jupyter Notebook cells and OOPS !!! There was a command

del model

Photo by Sammy Williams on Unsplash

This is the ‘point of no-return’ and it happens a lot of times, where you just wonder ‘what if’ I had not done this and that and most of the times it ends with acceptance.

Good News !!!

There is a way back and it took me some time to figure it out myself as this query itself was unique to google and stackoverflow and though I got some direction but not the solution

Here is what you should do !!!!

  1. Basically when we delete any object it just deletes a reference or link of the object name with the object but the actual object actually stays in the global memory
  2. run globals() in your jupyter notebook and check where you referenced the object (in this case our model) last
  3. You will see entries in the form of dictionaries like: ‘_i31’: ‘df.head’,
  4. Just do globals()[‘_i31’] and assign it to new variable

BAM !!!! You just reincarnated your model and Thank me later :)

You can use this logic to bring any deleted object back to life be it a dataframe or anything else

--

--

Param Saraf

Data Scientist | Machine Learning Engineer | Power BI/ MSBI Expert