[Feature Proposal] `load(...)` but only for model parameters
See original GitHub issueProblem
Currently ActorCriticRLModel
implements load(...)
so that it creates the network/model from zero and then loads stored parameters. This creates hefty amount of overhead, and bit of a memory leak if you are not careful, when you only want to change to different set of model parameters, e.g. when evaluating bunch of stored model.
Suggestion
- New function for
ActorCriticRLModel
namedload_parameters(str:filename, ...)
which takes in path to a saved model (fromsave(...)
) and only loads the model parameters for the agent. Most of this can be done by re-using code already inload(...)
, with some re-structuring. - Required TF
assign
operations would be created during creation of the graph, aftersetup_model
.
We have been using hacky-ish setup like this for our work with success, and thought it could be useful for others as well.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Use Models — detectron2 0.6 documentation
Use a Model A model can be called by outputs = model(inputs) , where inputs is a list[dict] . Each dict corresponds to...
Read more >Region Proposal Network — A detailed view
We generate candidate boxes using two parameters — scales and aspect ratios. The boxes need to be at image dimensions, whereas the feature...
Read more >DETR - Hugging Face
Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the from_pretrained() method to...
Read more >Implement your own Mask RCNN model - Medium
Mask RCNN model has 63,749,552 total parameters, ... us to create our own functions to extract bounding boxes, load mask, and load dataset....
Read more >REST API Testing Strategy: What Exactly Should You Test?
If it breaks, it puts at risk, not just a single application, but an entire chain ... positive tests to include optional parameters...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My idea was more to keep the pickle file in the general case but:
Hello,
I think this is a good feature to have. Especially when you want to deploy your model for instance (where you just need the weights of the policy) .
I have some additional remarks, questions:
If we implement a
load_parameters
(that takes either a list of numpy arrays or a path to a file) we should also implement asave_parameters
(save weight to a file) andget_parameters
(returns list/dict of numpy arrays representing the weights)As I understand, you were suggesting to still use the same
.pkl
file that contains both parameters and data (e.g. hyperparams) for loading the parameters? I think in that case have a different format for saving the parameters only (e.g. numpy dict) would make more sense.I would do that for all models.
Why not when calling the
load_parameters
?Note that if we change the parameters format to be a dict of numpy arrays instead of a list, this would solve that issue too: https://github.com/hill-a/stable-baselines/issues/113