question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Proposal] `load(...)` but only for model parameters

See original GitHub issue

Problem 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 named load_parameters(str:filename, ...) which takes in path to a saved model (from save(...)) and only loads the model parameters for the agent. Most of this can be done by re-using code already in load(...), with some re-structuring.
  • Required TF assign operations would be created during creation of the graph, after setup_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:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
araffincommented, May 13, 2019

My idea was more to keep the pickle file in the general case but:

  1. save parameters (trained weights) in a dict rather than a list (which is currently the case)
  2. allow the use to load/save the parameters only from/in a numpy archive, the use case is you have one pickle file that contains all the hyperparameters for an experiments and several numpy archives for different results of the optimization with the same hyperparams
1reaction
araffincommented, May 7, 2019

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 a save_parameters (save weight to a file) and get_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.

New function for ActorCriticRLModel

I would do that for all models.

Required TF assign operations would be created during creation of the graph, after setup_model.

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found