---
title: "ClikaRT::nn::InitSpec"
sidebar_label: "InitSpec"
description: "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 c…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--struct">struct</span>

**Header:** `ClikaRT/nn/module.h`

How [`Module::init_weights`](./Module.md#init_weights) fills the storage-free slots of a tree (the parameters and buffers a config-built module declared from a [`FakeTensor`](../FakeTensor.md) spec), the way a model's weight initializer does before a checkpoint is bound, or when none is.

The base [`kind`](./InitSpec.md#kind) applies to every slot the override table does not name. [`overrides`](./InitSpec.md#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`](./InitSpec.md#overrides) and [`reinit_materialized`](./InitSpec.md#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`](./InitSpec.md#normal)`(0.0, initializer_range)`).

## Types

### enum Kind {#Kind}

<div class="api-signature">

`enum class` **`Kind`** `:` `std::uint8_t`

</div>

| Enumerator | Description |
| --- | --- |
| `Zeros` |  |
| `Ones` |  |
| `Constant` |  |
| `Normal` |  |

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 153

</div>

## Static member functions

### zeros() {#zeros}

<div class="api-signature">

`static` [`InitSpec`](./InitSpec.md) **`zeros`**()

</div>

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 165

</div>

### ones() {#ones}

<div class="api-signature">

`static` [`InitSpec`](./InitSpec.md) **`ones`**()

</div>

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 166

</div>

### constant() {#constant}

<div class="api-signature">

`static` [`InitSpec`](./InitSpec.md) **`constant`**(`double` `value`)

</div>

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 171

</div>

### normal() {#normal}

<div class="api-signature">

`static` [`InitSpec`](./InitSpec.md) **`normal`**(`double` `mean`, `double` `stddev`)

</div>

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 177

</div>

## Data members

### kind {#kind}

<div class="api-signature">

[`Kind`](./InitSpec.md#Kind) **`kind`** `=` [`Kind::Zeros`](./InitSpec.md#Kind)

</div>

the fill every slot the table does not name takes

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 154

</div>

### value {#value}

<div class="api-signature">

`double` **`value`** `= 0.0`

</div>

`Constant`: the fill value

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 155

</div>

### mean {#mean}

<div class="api-signature">

`double` **`mean`** `= 0.0`

</div>

`Normal`: the mean

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 156

</div>

### stddev {#stddev}

<div class="api-signature">

`double` **`stddev`** `= 1.0`

</div>

`Normal`: the standard deviation (never negative)

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 157

</div>

### reinit\_materialized {#reinit_materialized}

<div class="api-signature">

`bool` **`reinit_materialized`** `= false`

</div>

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.

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 161

</div>

### overrides {#overrides}

<div class="api-signature">

`std::vector<std::pair<std::string,` [`InitSpec`](./InitSpec.md)`>>` **`overrides`**

</div>

The per-slot rows, `(key, `[`spec`](../spec/index.md)`)`; the first match wins (above).

<div class="api-declared">

Declared in `ClikaRT/nn/module.h`, line 163

</div>
