Transfer Learning¶
Save, load, freeze, fine-tune SNN models.
from sc_neurocore.transfer import save_checkpoint, load_checkpoint, freeze_layers
save_checkpoint(model, "model_v1.npz")
model = load_checkpoint("model_v1.npz")
freeze_layers(model, layers=["conv1", "conv2"])
See Tutorial 81: Transfer Learning.
sc_neurocore.transfer
¶
Save, load, freeze, fine-tune SNN models. The foundation of modern ML.
SNNCheckpoint
dataclass
¶
Complete SNN model checkpoint.
Source code in src/sc_neurocore/transfer/checkpoint.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
TransferConfig
dataclass
¶
Configuration for transfer learning.
Parameters¶
freeze_until : str or int Freeze all layers up to (and including) this layer name or index. lr_backbone : float Learning rate for frozen layers (usually 0 or very small). lr_head : float Learning rate for unfrozen layers.
Source code in src/sc_neurocore/transfer/fine_tune.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
save_checkpoint(checkpoint, path)
¶
Save SNN checkpoint to .npz + .json.
Parameters¶
checkpoint : SNNCheckpoint path : str or Path Base path (without extension). Creates path.npz and path.json.
Source code in src/sc_neurocore/transfer/checkpoint.py
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 | |
load_checkpoint(path)
¶
Load SNN checkpoint from .npz + .json.
Parameters¶
path : str or Path Base path (without extension).
Returns¶
SNNCheckpoint
Source code in src/sc_neurocore/transfer/checkpoint.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
freeze_layers(checkpoint, layer_names=None, until_index=None)
¶
Freeze layers (mark as non-trainable).
Parameters¶
checkpoint : SNNCheckpoint layer_names : list of str, optional Specific layers to freeze. until_index : int, optional Freeze all layers with index <= until_index.
Returns¶
SNNCheckpoint with frozen_layers updated
Source code in src/sc_neurocore/transfer/fine_tune.py
41 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 | |
unfreeze_layers(checkpoint, layer_names=None, all_layers=False)
¶
Unfreeze layers (mark as trainable).
Parameters¶
checkpoint : SNNCheckpoint layer_names : list of str, optional Specific layers to unfreeze. all_layers : bool If True, unfreeze everything.
Source code in src/sc_neurocore/transfer/fine_tune.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |