# Gradients are 0, weights not updating

**URL:** <https://discuss.pytorch.org/t/gradients-are-0-weights-not-updating/11522>\
**Category:** autograd\
**Created:** [December 24, 2017, 8:40pm UTC](https://discuss.pytorch.org/t/gradients-are-0-weights-not-updating/11522 "2017-12-24T20:40:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cphb](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@cphb](https://discuss.pytorch.org/u/cphb)\
**Post date:** [December 24, 2017, 8:40pm UTC](https://discuss.pytorch.org/t/gradients-are-0-weights-not-updating/11522/1 "2017-12-24T20:40:35Z")

</div>

I’m initializing the bias and weight of my first convolutional to an arbitrary tensor and freezing them. Unfortunately this leads to the gradients of several other layers becoming all 0s. Does anyone know a solution to this?

This is the code I’m setting the layer’s weights with. I made sure that require\_grad is True for all other layers.

```
m.weight=torch.nn.Parameter(torch.from_numpy(d).float())
nn.init.constant(m.bias.data, 0) #set bias=0
m.weight.require_grad=False
m.bias.require_grad=False

```

Thanks so much!
