# Freeze a weight with Flux

**URL:** <https://discourse.julialang.org/t/freeze-a-weight-with-flux/97441>\
**Category:** Performance\
**Created:** [April 13, 2023, 7:36pm UTC](https://discourse.julialang.org/t/freeze-a-weight-with-flux/97441 "2023-04-13T19:36:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [April 13, 2023, 7:36pm UTC](https://discourse.julialang.org/t/freeze-a-weight-with-flux/97441/1 "2023-04-13T19:36:00Z")

</div>

I have a few linear layers created with Flux. I ran these layers for a few epochs, and would now to freeze all the weights of one of the linear layers, but leaving the bias unfrozen. Could somebody post a MWE demonstrating the freezing and unfreezing of the weights of a given layer? Thanks.

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [April 14, 2023, 6:07am UTC](https://discourse.julialang.org/t/freeze-a-weight-with-flux/97441/2 "2023-04-14T06:07:23Z")

</div>

You can use `Optmisers.freeze!`, see the docs  
[https://fluxml.ai/Optimisers.jl/dev/#Frozen-Parameters](https://fluxml.ai/Optimisers.jl/dev/#Frozen-Parameters)
