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.

[Question] Bias only, linear NN with PPO

See original GitHub issue

Important Note: We do not do technical support, nor consulting and don’t answer personal questions per email. Please post your question on the RL Discord, Reddit or Stack Overflow in that case.

Question

Hi, I have in the past used a 2 hidden layer NN with 32 neurons each and non-linear activation function. I want to try something new and I am having issues implementing it.

policy_kwargs = dict(activation_fn=torch.nn.LeakyReLU, net_arch=[32, 32])
model = PPO(MlpPolicy, env, verbose=1, n_steps=10, batch_size=10, seed=my_seed, policy_kwargs=policy_kwargs)

I want to use the exact same simulation as before but modify policy_kwargs in a way that I will have only bias taken into account and a linear activation function and no actual inputs. I know that this is not a regular RL problem and there are other methods that will do as good or even better but I want to use PPO for it.

I want to define no inputs and only bias, and set the activation function to be a linear activation function. I know how to define the linear regression net in pytorch but I havent found any information of how to do it using the policy_kwargs

Could anyone share an idea how this can be done? If there is no way to define that type of network then is there a way to define it as a simple linear regression type of net?

I attach image to illustrate the network I am trying to build.

image

Additional context

Add any other context about the question here.

Checklist

  • I have read the documentation (required)
  • I have checked that there is no similar issue in the repo (required)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Miffylicommented, Feb 27, 2022

@danielstankw Ah, sorry about the little typo: the dict should be wrapped in a list:

policy_kwargs = dict(activation_fn=torch.nn.Identity, net_arch=[dict(pi=[], vf=[])])

That should work 😃. Please re-close issue if so.

0reactions
danielstankwcommented, Feb 27, 2022

policy_kwargs = dict(activation_fn=torch.nn.Identity, net_arch=dict(pi=[], vf=[]))

I used what you suggested and get error: AssertionError: Error: the net_arch list can only contain ints and dicts

Read more comments on GitHub >

github_iconTop Results From Across the Web

What do the "in/out features" of a neural network mean?
Yes, linear layers connect all inputs to all outputs; to verify, write out each element of the result as sums and products of...
Read more >
Linear — PyTorch 1.13 documentation
Linear. class torch.nn.Linear(in_features, out_features, bias=True, device=None, dtype=None)[source]. Applies a linear transformation to the incoming data: ...
Read more >
The 37 Implementation Details of Proximal Policy Optimization
If you run the official PPO with the Atari game Breakout, the agent would get ~400 game scores in about 4 hours. Do...
Read more >
What is the class definition of nn.Linear in PyTorch?
CLASS torch.nn.Linear(in_features, out_features, bias=True). Applies a linear transformation to the incoming data: y = x*W^T + b.
Read more >
Understanding Gradient Clipping (and How It Can Fix ...
For the sake of keeping the norms to handle small, we'll only define two Linear/Dense layers for our neural network. class Net(nn.Module): def...
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