eegproc.deep_learning.training_outputs module
- class eegproc.deep_learning.training_outputs.CompactEpochLogger(fold_number=None, context=None)[source]
Bases:
CallbackPrint one consolidated training-diagnostics row per epoch.
Keras’ built-in
verbose=2logger places every metric on one very long line. This callback retains the readable metric/class/loss groupings without emitting several separate rows and leaveshistory.historyunchanged.- Parameters:
fold_number (
int|None, default:None)context (
str|None, default:None)
- on_epoch_end(epoch, logs=None)[source]
Called at the end of an epoch.
Subclasses should override for any actions to run. This function should only be called during TRAIN mode.
- Parameters:
epoch (
int) – Integer, index of epoch.logs (
dict|None, default:None) – Dict, metric results for this training epoch, and for the validation epoch if validation is performed. Validation result keys are prefixed with val_. For training epoch, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.
- Return type:
None
- on_train_begin(logs=None)[source]
Called at the beginning of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently no data is passed to this argument for this method but that may change in the future.- Return type:
None
- on_train_end(logs=None)[source]
Called at the end of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently the output of the last call to on_epoch_end() is passed to this argument for this method but that may change in the future.- Return type:
None
- class eegproc.deep_learning.training_outputs.HeldOutUserOracleMetrics(X_target, y_target, subject_ids_target, trial_ids_target, target_subject, evaluation_level, batch_size=None, decision_threshold=0.5, diagnostic_thresholds=None, ece_bins=15, calibration_shots=None, calibration_fold=None)[source]
Bases:
HeldOutUserOracleMetricsEmit one complete reporting-only oracle-prediction row per epoch.
The parent callback previously printed decoder and classification values on separate rows. This replacement preserves its initialization contract and reporting-only history while computing the complete classification suite, probability log loss, and both branch-specific reconstruction suites in one memory-bounded pass per output type.
- Parameters:
X_target (
ndarray)y_target (
ndarray)subject_ids_target (
ndarray)trial_ids_target (
ndarray)evaluation_level (
Literal['window','trial'])batch_size (
int|None, default:None)decision_threshold (
float, default:0.5)diagnostic_thresholds (
list[float] |tuple[float,...] |None, default:None)ece_bins (
int, default:15)calibration_shots (
int|None, default:None)calibration_fold (
int|None, default:None)
- on_epoch_end(epoch, logs=None)[source]
Called at the end of an epoch.
Subclasses should override for any actions to run. This function should only be called during TRAIN mode.
- Parameters:
epoch (
int) – Integer, index of epoch.logs (
dict|None, default:None) – Dict, metric results for this training epoch, and for the validation epoch if validation is performed. Validation result keys are prefixed with val_. For training epoch, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.
- Return type:
None
- on_train_begin(logs=None)[source]
Called at the beginning of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently no data is passed to this argument for this method but that may change in the future.- Return type:
None
- on_train_end(logs=None)[source]
Called at the end of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently the output of the last call to on_epoch_end() is passed to this argument for this method but that may change in the future.- Return type:
None
- class eegproc.deep_learning.training_outputs.PredictionDiagnostics(X_train, y_train, X_val=None, y_val=None, fold_number=None, batch_size=None, every_n_epochs=1, max_samples=256, threshold_tolerance=0.01, reported_metric='accuracy', decision_threshold=0.5, decision_thresholds=None, ece_bins=15, seed=42)[source]
Bases:
CallbackPrint one complete deterministic training-diagnostics row per epoch.
Only a fixed, approximately class-balanced subset is evaluated, so the callback remains inexpensive relative to a full validation pass. The row combines the existing Keras epoch metrics/losses with exact probability metrics on that fixed subset, including ROC-AUC and macro F1. Decoder values come from the epoch-wide Keras logs when available; a memory-bounded inference fallback is used only for models that expose a decoder without tracking its metrics.
- Parameters:
X_train (
ndarray)y_train (
ndarray)X_val (
ndarray|None, default:None)y_val (
ndarray|None, default:None)fold_number (
int|None, default:None)batch_size (
int|None, default:None)every_n_epochs (
int, default:1)max_samples (
int, default:256)threshold_tolerance (
float, default:0.01)reported_metric (
str, default:'accuracy')decision_threshold (
float, default:0.5)decision_thresholds (
Optional[Sequence[float]], default:None)ece_bins (
int, default:15)seed (
int|None, default:42)
- on_epoch_end(epoch, logs=None)[source]
Called at the end of an epoch.
Subclasses should override for any actions to run. This function should only be called during TRAIN mode.
- Parameters:
epoch (
int) – Integer, index of epoch.logs (
dict|None, default:None) – Dict, metric results for this training epoch, and for the validation epoch if validation is performed. Validation result keys are prefixed with val_. For training epoch, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.
- Return type:
None
- on_train_begin(logs=None)[source]
Called at the beginning of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently no data is passed to this argument for this method but that may change in the future.- Return type:
None
- on_train_end(logs=None)[source]
Called at the end of training.
Subclasses should override for any actions to run.
- Parameters:
logs (
dict|None, default:None) – Dict. Currently the output of the last call to on_epoch_end() is passed to this argument for this method but that may change in the future.- Return type:
None