# Appropriate method for weight sharing in convolutional layers?

**URL:** <https://discuss.pytorch.org/t/appropriate-method-for-weight-sharing-in-convolutional-layers/145093>\
**Category:** Uncategorized\
**Created:** [February 27, 2022, 4:34am UTC](https://discuss.pytorch.org/t/appropriate-method-for-weight-sharing-in-convolutional-layers/145093 "2022-02-27T04:34:14Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![aaroswings](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/aaroswings/32/32628_2.png) [@aaroswings](https://discuss.pytorch.org/u/aaroswings)\
**Post date:** [February 27, 2022, 5:23pm UTC](https://discuss.pytorch.org/t/appropriate-method-for-weight-sharing-in-convolutional-layers/145093/3 "2022-02-27T17:23:36Z")

</div>

Thanks @ptrblck .  
Since the gradients are added up, in order to effectively average the update across the different forward passes, would dividing the gradients by the number of forward passes shared weights are used in, using a backward hook, be a good way to do this?

I see in [this topic](https://discuss.pytorch.org/t/how-to-use-shared-weights-in-different-layers-of-a-model/71263/2), @albanD recommended sharing weights by `.clone()`ing the same weight into the `weight` attribute of different modules on the forward pass. Are there reasons that would better or more memory efficient than using `F.conv2d` and passing in the weight tensor to a functional call?

---

_[View the full topic](https://discuss.pytorch.org/t/appropriate-method-for-weight-sharing-in-convolutional-layers/145093)._
