nemos.callbacks.TestLossLogger#
- class nemos.callbacks.TestLossLogger(X_test, y_test, events)[source]#
Bases:
CallbackLog the loss evaluated on a fixed test set at the requested events.
Appends
model.compute_loss(params, X_test, y_test)toloss_historyeach time one of the requestedeventsfires.- Parameters:
X_test (Union[DESIGN_INPUT_TYPE, ArrayLike]) – Test input (design matrix).
y_test (ArrayLike) – Test target (e.g. spike counts).
events (str | Iterable[str]) – Event name or names at which to log the test score. Each must be one of
{"train_begin", "train_end", "pass_begin", "pass_end", "batch_begin", "batch_end"}.
- loss_history#
List of
(event, pass_idx, batch_idx, test_score)tuples, one per logged event, recording which event fired and the training position at the time.
Methods
__init__(X_test, y_test, events)on_batch_begin(ctx)Run before each batch update.
on_batch_end(ctx)Run after each batch update.
on_pass_begin(ctx)Run at the start of a pass.
on_pass_end(ctx)Run at the end of each pass.
on_train_begin(ctx)Run once at the start of training.
on_train_end(ctx)Run once at the end of training.
- on_batch_begin(ctx)#
Run before each batch update.
- Return type:
- Parameters:
ctx (TrainingContext)
- on_batch_end(ctx)#
Run after each batch update.
- Return type:
- Parameters:
ctx (TrainingContext)
- on_pass_begin(ctx)#
Run at the start of a pass.
This hook is called after the training loop advances
ctx.pass_idxand before the first batch of that pass is processed. It marks the start of pass-level work from the callback perspective.Solver-specific pass preparation may still occur after this hook and before the first batch update. Callbacks should therefore treat this hook as notification that a new pass is starting, not as a guarantee that all solver-internal pass setup has already completed.
- Return type:
- Parameters:
ctx (TrainingContext)
- on_pass_end(ctx)#
Run at the end of each pass.
- Return type:
- Parameters:
ctx (TrainingContext)
- on_train_begin(ctx)#
Run once at the start of training.
- Return type:
- Parameters:
ctx (TrainingContext)
- on_train_end(ctx)#
Run once at the end of training.
- Return type:
- Parameters:
ctx (TrainingContext)