- #1
fog37
- 1,568
- 108
- TL;DR Summary
- Saving data and saving the state of a program (persistence)
Hello Forum,
I am not completely clear on the idea of saving the state of a Python program. We can write a .py program which has instructions, formulas, variables, user inputs, and uses data from an external file, etc., and run such file. However, running the program is different from saving its state.
I see how, sometimes, the data generated by the program during its execution needs to be saved in an external file using JSON or pickle. Not sure if that is saving the state...Saving the state seems to imply that the entire program is saved as if we were taking a snapshot of it.
Without saving the state, everything is temporarily saved in RAM and disappears after the program has run.
Some applications work with some kind of "persistent" state. Saving the state seems to essentially mean that we store values away outside of the program and whenever we need the values we read the from that outside place. External files can be JSON, YAML, TXT, or it could be another program, like a database.
People that work with machine learning create ML models and train them (set ideal model weights) before deploying the model.
After training, the model can be used with the weights obtained during training. But that is only possible if we save the state of the model. Otherwise, if we run the ML model every time, the weight would change every time. Saving the state of the model means saving the trained model into a different file to reload it later when we need to use it. The model will be identical without having to run all the data processing and training phase. The model file (json, binary, etc.) contains the model properties (layer type, activation functions, weights, etc.)
Is my understanding correct? Any corrections?
Thanks!
I am not completely clear on the idea of saving the state of a Python program. We can write a .py program which has instructions, formulas, variables, user inputs, and uses data from an external file, etc., and run such file. However, running the program is different from saving its state.
I see how, sometimes, the data generated by the program during its execution needs to be saved in an external file using JSON or pickle. Not sure if that is saving the state...Saving the state seems to imply that the entire program is saved as if we were taking a snapshot of it.
Without saving the state, everything is temporarily saved in RAM and disappears after the program has run.
Some applications work with some kind of "persistent" state. Saving the state seems to essentially mean that we store values away outside of the program and whenever we need the values we read the from that outside place. External files can be JSON, YAML, TXT, or it could be another program, like a database.
People that work with machine learning create ML models and train them (set ideal model weights) before deploying the model.
After training, the model can be used with the weights obtained during training. But that is only possible if we save the state of the model. Otherwise, if we run the ML model every time, the weight would change every time. Saving the state of the model means saving the trained model into a different file to reload it later when we need to use it. The model will be identical without having to run all the data processing and training phase. The model file (json, binary, etc.) contains the model properties (layer type, activation functions, weights, etc.)
Is my understanding correct? Any corrections?
Thanks!