flax.linen.Variable#

class flax.linen.Variable(scope, collection, name, unbox)[source]#

A Variable object allows mutable access to a variable in a VariableDict.

Variables are identified by a collection (e.g., “batch_stats”) and a name (e.g., “moving_mean”). The value property gives access to the variable’s content and can be assigned to for mutation.

__init__(scope, collection, name, unbox)[source]#

Initializes a variable.

Parameters
  • scope – The scope in which the variable is stored.

  • collection – The collection of the variable (e.g., “params”).

  • name – The name of the variable (e.g., “dense”).

  • unbox – Whether to unbox boxed values with metadata.

Methods

__init__(scope, collection, name, unbox)

Initializes a variable.

is_mutable()

Checks if this Variable is mutable.

Attributes

value

Returns the value of this Variable.