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.

Passing parameters to the policy is hard

See original GitHub issue

I am doing a hyperparameter sweep and therefore would like to parameterize the network size of my policy. As I understood, to change the size of the policy network, I have to derive my own policy class like here. If I want to parameterize the size of the network, I have to use a weird construct like this:

def make_model(units_per_layer, num_layers, *args, **kwargs):
    class MyCustomMLP(FeedForwardPolicy):
        def __init__(self, *args, **kwargs):
            super(MyCustomMLP, self).__init__(*args, **kwargs,
                                              layers=[units_per_layer] * num_layers,
                                              feature_extraction="mlp")
    return PPO2(MyCustomMLP, *args, **kwargs)

It gets even more weird when I want to load a model because I need to somehow externally figure out the size of the network before I load it.

What would you consider the most elegant way to solve this issue?

If there was a way to pass custom arguments to the policy constructor that would help a bit, but would not solve the persistence problem right away. Passing a factory function for the policy instead of a policy class also does not help because in PPO2 there is a check if the policy is really an ActorCriticPolicy.

Any input is highly appreciated.

Edit: I just saw that the issue is partially addressed in the pull requests #83 and #84 but they do not seem to solve the store/load issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ernestumcommented, Jan 14, 2019

Looks like @hill-a did not start working on this one. So I will now.

1reaction
araffincommented, Nov 30, 2018

Note: we should address this issue once #91 is solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing Multiple Arguments To Laravel Policy Methods
In most cases, when writing policies in Laravel, you only pass one argument to a policy method, since the authenticated user is already ......
Read more >
c++ - How to pass arguments to a Policy's constructor?
One way is to provide member function templates that take a template arg to use with the policy. For example:
Read more >
Language: Parameters - HashiCorp Sentinel
Parameteres allow a Sentinel policy to describe variables that are expected to be supplied by the calling application, in addition to any default...
Read more >
How to pass parameters to action methods in ASP.NET Core ...
Consider the following code snippet that illustrates how you can pass parameters via query strings in an action method.
Read more >
Defining Policy Parameters - CloudRadial Support
Most policies in CloudRadial are based on a custom parameter that defines the criteria for exceptions. The following list defines the...
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