# How to print the constant numbers in the forward function

**URL:** <https://discuss.pytorch.org/t/how-to-print-the-constant-numbers-in-the-forward-function/18639>\
**Category:** vision\
**Created:** [May 25, 2018, 1:14am UTC](https://discuss.pytorch.org/t/how-to-print-the-constant-numbers-in-the-forward-function/18639 "2018-05-25T01:14:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11185](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/11185/32/15473_2.png) [@11185](https://discuss.pytorch.org/u/11185)\
**Post date:** [May 25, 2018, 1:14am UTC](https://discuss.pytorch.org/t/how-to-print-the-constant-numbers-in-the-forward-function/18639/1 "2018-05-25T01:14:15Z")

</div>

hello, guys. I only have access to a well-trained model and have forgot the exact settings in the Network strucutre.

I used to train a model with a layer like this:

> ```
> def forward(self, x):
> x_a = self.linear_a(x)
> x_b = self.linear_b(x)
> x_c = self.linear_c(x)
>     
> s_a = self.score_a(x)
> s_b = self.score_b(x)
> s_c = self.score_c(x)
> 
> s_a = torch.sigmoid(s_a)
> s_b = torch.sigmoid(s_b)
> s_c = torch.sigmoid(s_c)
> 
> f_a = x_a
> f_b = torch.cat([(s_a+0.5)*x_a, (s_b+0.5)*x_b], 1)
> f_c = torch.cat([(s_a+0.5)*x_a, (s_b+0.5)*x_b, (s_c)*x_c], 1)
>     
> return [f_a, f_b, f_c, f_c]
> 
> ```

You can see that I use some constant number here like "f\_b = torch.cat([(s\_a+0.5)\*x\_a, (s\_b+0.5)\*x\_b], 1)"and I have forgot the exact value of these numbers. But I have stored a model and I am wondering how can I print the numbers within the equation “f\_b = torch.cat([(s\_a+0.5)\*x\_a, (s\_b+0.5)\*x\_b], 1),1)”

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 25, 2018, 4:29pm UTC](https://discuss.pytorch.org/t/how-to-print-the-constant-numbers-in-the-forward-function/18639/2 "2018-05-25T16:29:43Z")

</div>

Did you save your model’s `state_dict`?  
If so, I think there isn’t an option to get the constants in this line, since they weren’t saved and just defined in the forward pass.

---

<div class="post-metadata">

**Author:** ![11185](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/11185/32/15473_2.png) [@11185](https://discuss.pytorch.org/u/11185)\
**Post date:** [May 29, 2018, 2:21pm UTC](https://discuss.pytorch.org/t/how-to-print-the-constant-numbers-in-the-forward-function/18639/3 "2018-05-29T14:21:07Z")

</div>

> [@ptrblck](#):
>
> onstants in this

Thanks for your comments.
