Serialization
mpneuralnetwork.serialization.save_model(model, filepath)
Saves the full model state to a .npz archive.
The archive contains:
1. architecture (JSON): Configuration of layers (type, size, etc.).
2. model_config (JSON): Loss, Optimizer config, and Optimizer globals (learning rate, etc.).
3. layer_{i}_{param}: Raw numpy arrays for weights and biases.
4. layer_{i}_state_{name}: Internal state (e.g., BatchNorm moving averages).
5. optimizer_{param}_{layer_param}: Optimizer state (momentum, velocity) for each parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The model instance to save. |
required |
filepath
|
str
|
Destination path. If extension is missing, |
required |
Source code in src/mpneuralnetwork/serialization.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
mpneuralnetwork.serialization.load_model(path)
Loads a full model from a .npz archive.
This function instantiates a new Model object, rebuilds the layer graph,
initializes the optimizer and loss function, and then loads all weights
and states (including optimizer momentum) into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Model |
Model
|
The fully restored model, ready for training or inference. |
Source code in src/mpneuralnetwork/serialization.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |