# How to define trainable weights in Flux

**URL:** <https://discourse.julialang.org/t/how-to-define-trainable-weights-in-flux/94617>\
**Category:** General Usage\
**Tags:** question, flux\
**Created:** [February 14, 2023, 10:39am UTC](https://discourse.julialang.org/t/how-to-define-trainable-weights-in-flux/94617 "2023-02-14T10:39:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xuekui\_wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xuekui_wang/32/30746_2.png) [@Xuekui\_wang](https://discourse.julialang.org/u/Xuekui_wang)\
**Post date:** [February 14, 2023, 10:39am UTC](https://discourse.julialang.org/t/how-to-define-trainable-weights-in-flux/94617/1 "2023-02-14T10:39:29Z")

</div>

I want to define a network mode with `W=[w11 0 w13; 0 w22 0; w31 0 w33]`,  
i.e. set some weights to fixed number and they are not trained,

for example

```julia
m3 = Chain(Dense(3,3), Dense(3,2))

```

how to set m3.layer[1].weights, and define which weight is trainable or not?

Thank you very much!
