snowflake.ml.experiment.callback.keras.SnowflakeKerasCallback¶
- class snowflake.ml.experiment.callback.keras.SnowflakeKerasCallback(experiment_tracking: ExperimentTracking, log_model: bool = True, log_metrics: bool = True, log_params: bool = True, log_every_n_epochs: int = 1, model_name: Optional[str] = None, version_name: Optional[str] = None, model_signature: Optional[ModelSignature] = None)¶
Bases:
CallbackKeras callback for automatically logging to a Snowflake ML Experiment.
Creates a new Keras callback.
- Parameters:
experiment_tracking (ExperimentTracking) – The Experiment Tracking instance to use for logging.
log_model (bool) – Whether to log the model at the end of training. Default is True.
log_metrics (bool) – Whether to log metrics during training. Default is True.
log_params (bool) – Whether to log model parameters at the start of training. Default is True.
log_every_n_epochs (int) – Frequency with which to log metrics. Must be positive. Default is 1, logging after every epoch.
model_name (Optional[str]) – The model name to use when logging the model. If None, the model name will be derived from the experiment name.
version_name (Optional[str]) – The model version name to use when logging the model. If None, the version name will be randomly generated.
model_signature (Optional[ModelSignature]) – The model signature to use when logging the model. This is required if
log_modelis set to True.
- Raises:
ValueError – When
log_every_n_epochsis not a positive integer.
Methods
- on_epoch_end(epoch: int, logs: Optional[dict[str, Any]] = None) None¶
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 – Integer, index of epoch.
logs – 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}.
- on_train_begin(logs: Optional[dict[str, Any]] = None) None¶
Called at the beginning of training.
Subclasses should override for any actions to run.
- Parameters:
logs – Dict. Currently no data is passed to this argument for this method but that may change in the future.
- on_train_end(logs: Optional[dict[str, Any]] = None) None¶
Called at the end of training.
Subclasses should override for any actions to run.
- Parameters:
logs – 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.
Attributes
- model¶