# How to create model with sharing weight?

**URL:** <https://discuss.pytorch.org/t/how-to-create-model-with-sharing-weight/398>\
**Category:** Uncategorized\
**Created:** [February 8, 2017, 3:00pm UTC](https://discuss.pytorch.org/t/how-to-create-model-with-sharing-weight/398 "2017-02-08T15:00:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![apaszke](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/apaszke/32/21_2.png) [@apaszke](https://discuss.pytorch.org/u/apaszke)\
**Post date:** [February 8, 2017, 5:31pm UTC](https://discuss.pytorch.org/t/how-to-create-model-with-sharing-weight/398/2 "2017-02-08T17:31:43Z")

</div>

**EDIT: we do support sharing Parameters between modules, but it’s recommended to decompose your model into many pieces that don’t share parameters if possible.**

We don’t support using the same Parameters in many modules. Just reuse the base for two inputs:

```python
class MyModel(nn.Module):
    def __init__ (self):
        self.base = ...
        self.head_A = ...
        self.head_B = ...

    def forward(self, input1, input2):
        return self.head_A(self.base(input1)), self.head_B(self.base(input2))
        

```

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-create-model-with-sharing-weight/398)._
