ClikaRT::nn::InitSpec
struct
Header: ClikaRT/nn/module.h
How Module::init_weights fills the storage-free slots of a tree (the parameters and buffers a config-built module declared from a FakeTensor spec), the way a model's weight initializer does before a checkpoint is bound, or when none is.
The base kind applies to every slot the override table does not name. overrides is read in order and the first row whose key matches a slot's dotted name wins; a key is an exact dotted name, else a regular expression (RE2 syntax) matched against the whole dotted name, and a key that is neither raises. A row's own overrides and reinit_materialized are not read. A slot whose dtype is not floating point (an integer index table, a Bool mask) takes zeros under a Normal base kind, or the value under Constant; a Normal override row aimed at such a slot raises. The library has no standard deviation of its own: a caller passes its model's (InitSpec::normal(0.0, initializer_range)).
Types
enum Kind
enum class Kind : std::uint8_t
| Enumerator | Description |
|---|---|
Zeros | |
Ones | |
Constant | |
Normal |
Declared in ClikaRT/nn/module.h, line 153
Static member functions
zeros()
static InitSpec zeros()
Declared in ClikaRT/nn/module.h, line 165
ones()
static InitSpec ones()
Declared in ClikaRT/nn/module.h, line 166
constant()
static InitSpec constant(double value)
Declared in ClikaRT/nn/module.h, line 171
normal()
static InitSpec normal(double mean, double stddev)
Declared in ClikaRT/nn/module.h, line 177
Data members
kind
Kind kind = Kind::Zeros
the fill every slot the table does not name takes
Declared in ClikaRT/nn/module.h, line 154
value
double value = 0.0
Constant: the fill value
Declared in ClikaRT/nn/module.h, line 155
mean
double mean = 0.0
Normal: the mean
Declared in ClikaRT/nn/module.h, line 156
stddev
double stddev = 1.0
Normal: the standard deviation (never negative)
Declared in ClikaRT/nn/module.h, line 157
reinit_materialized
bool reinit_materialized = false
Fill a slot that already holds storage too, in place (its storage is kept). Default off: a materialized slot is left as it is, so a tree bound from a checkpoint keeps its weights.
Declared in ClikaRT/nn/module.h, line 161
overrides
std::vector<std::pair<std::string, InitSpec>> overrides
The per-slot rows, (key, spec); the first match wins (above).
Declared in ClikaRT/nn/module.h, line 163