.Fluxparams

function defined in module Flux


			params(model)
params(layers...)

Given a model or specific layers from a model, create a Params object pointing to its trainable parameters.

This can be used with the gradient function, see the [training section of the manual]( man-training), or as input to the [ Flux.train!]( Flux.train!) function.

The behaviour of params on custom types can be customized using Functors.@functor or Flux.trainable .

Examples


			julia> using Flux: params

julia> params(Chain(Dense(ones(2,3)), softmax))  # unpacks Flux models
Params([[1.0 1.0 1.0; 1.0 1.0 1.0], [0.0, 0.0]])

julia> bn = BatchNorm(2, relu)
BatchNorm(2, relu)  # 4 parameters, plus 4 non-trainable

julia> params(bn)  # only the trainable parameters
Params([Float32[0.0, 0.0], Float32[1.0, 1.0]])

julia> params([1, 2, 3], [4])  # one or more arrays of numbers
Params([[1, 2, 3], [4]])

julia> params([[1, 2, 3], [4]])  # unpacks array of arrays
Params([[1, 2, 3], [4]])

julia> params(1, [2 2], (alpha=[3,3,3], beta=Ref(4), gamma=sin))  # ignores scalars, unpacks NamedTuples
Params([[2 2], [3, 3, 3]])
Methods

There is 1 method for Flux.params: