# Convert tensor to Parameter (while keeping the graph)

**URL:** <https://discuss.pytorch.org/t/convert-tensor-to-parameter-while-keeping-the-graph/27219>\
**Category:** autograd\
**Created:** [October 14, 2018, 9:05am UTC](https://discuss.pytorch.org/t/convert-tensor-to-parameter-while-keeping-the-graph/27219 "2018-10-14T09:05:06Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![CNguyen](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/cnguyen/32/71957_2.png) [@CNguyen](https://discuss.pytorch.org/u/CNguyen)\
**Post date:** [January 20, 2022, 6:35am UTC](https://discuss.pytorch.org/t/convert-tensor-to-parameter-while-keeping-the-graph/27219/8 "2022-01-20T06:35:58Z")

</div>

For one that is still looking for a solution, you might find this [thread](https://discuss.pytorch.org/t/assign-parameters-to-nn-module-and-have-grad-fn-track-it/62677) useful. There are 2 ways to do it:

1. Delete the weights of each layer manually and re-assign by the tensor of interst (with history)
2. Use a package from [GitHub - SsnL/PyTorch-Reparam-Module: Reparameterize your PyTorch modules](https://github.com/SsnL/PyTorch-Reparam-Module), but note that it might not work with `batchnorm` layer when `track_running_stats=True`.

Another useful package that is supported directly from PyTorch is `functorch` with `make_functional`.

---

_[View the full topic](https://discuss.pytorch.org/t/convert-tensor-to-parameter-while-keeping-the-graph/27219)._
