# How do RAY calculate the number of Parameters(weights and bias)?

**URL:** <https://discuss.ray.io/t/how-do-ray-calculate-the-number-of-parameters-weights-and-bias/2676>\
**Category:** RLlib\
**Created:** [June 28, 2021, 2:22am UTC](https://discuss.ray.io/t/how-do-ray-calculate-the-number-of-parameters-weights-and-bias/2676 "2021-06-28T02:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xim\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xim_lee/32/300_2.png) [@Xim\_Lee](https://discuss.ray.io/u/Xim_Lee)\
**Post date:** [June 28, 2021, 2:22am UTC](https://discuss.ray.io/t/how-do-ray-calculate-the-number-of-parameters-weights-and-bias/2676/1 "2021-06-28T02:22:28Z")

</div>

Hi, 🙂  
I have a question.  
How do RAY calculate the number of Parameters?  
I used PPO algorithm and input\_dim = 16, hiddens = [256,256] and my action space = 4 dimensional.  
I have attached a picture below, but the result is strange.

![image](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/7/71ef2afddebe76211f665cfaa70b07b68b267216.png)

where is it comes number ‘8’?  
if I use the Compute\_action function, I get the 4-dimensional action space.  
Could anyone explain me?

---

<div class="post-metadata">

**Author:** ![Xim\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xim_lee/32/300_2.png) [@Xim\_Lee](https://discuss.ray.io/u/Xim_Lee)\
**Post date:** [June 29, 2021, 1:33am UTC](https://discuss.ray.io/t/how-do-ray-calculate-the-number-of-parameters-weights-and-bias/2676/2 "2021-06-29T01:33:32Z")

</div>

```auto
state = env.reset()
action = agent.compute_action(state)

    out = F.relu(F.linear(torch.from_numpy(state).float(), torch.from_numpy(policy_wei[1][1]),
                          torch.from_numpy(policy_bias[1][1])))
    out = F.relu(F.linear(out, torch.from_numpy(policy_wei[2][1]),
                          torch.from_numpy(policy_bias[2][1])))
    out = F.tanh(F.linear(out, torch.from_numpy(policy_wei[0][1]),
                          torch.from_numpy(policy_bias[0][1])))

```

```auto
policy out: tensor([0.3966, 0.6118, 0.5565, 0.0270, -0.9395, 0.8203, -0.0793, -0.3315])
state: [0.09984301 0.09992453 0.09992143 0.09991941 0.29046342 0.87227278
 0.98566566 0.10100834 0.21494237 0. 0.5 0.
 0.5 0. 1. 0.25 ] 
action: [-0.85631555 1. 0.8432337 -0.7363308]

```

Why do i get different result of compute\_action and Policy network about same state.  
How do RAY’s compute\_action work?

---

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [June 29, 2021, 3:05am UTC](https://discuss.ray.io/t/how-do-ray-calculate-the-number-of-parameters-weights-and-bias/2676/3 "2021-06-29T03:05:20Z")

</div>

Have a look here for an overview: [RLlib Models, Preprocessors, and Action Distributions — Ray v2.0.0.dev0](https://docs.ray.io/en/master/rllib-models.html#rllib-models-preprocessors-and-action-distributions)
