o
    $i	                     @   sv   d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 dZ
G dd dZG d	d
 d
Ze	ddG dd deZdS )    )DictN)TensorflowCheckpoint)RayReportCallback)	PublicAPIzxThe `ray.tune.integration.keras` module is deprecated in favor of `ray.train.tensorflow.keras.ReportCheckpointCallback`.c                   @      e Zd ZdZdd ZdS )TuneReportCallbackYDeprecated.
    Use :class:`ray.train.tensorflow.keras.ReportCheckpointCallback` instead.c                 O      t tNDeprecationWarning_DEPRECATION_MESSAGEclsargskwargs r   W/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/tune/integration/keras.py__new__      zTuneReportCallback.__new__N__name__
__module____qualname____doc__r   r   r   r   r   r          r   c                   @   r   )_TuneCheckpointCallbackr   c                 O   r	   r
   r   r   r   r   r   r      r   z_TuneCheckpointCallback.__new__Nr   r   r   r   r   r      r   r   alpha)	stabilityc                   @   s0   e Zd ZdZdedefddZdefddZdS )	TuneReportCheckpointCallbackaW  Keras callback for Ray Tune reporting and checkpointing.

    .. note::
        Metrics are always reported with checkpoints, even if the event isn't specified
        in ``report_metrics_on``.

    Example:
        .. code-block:: python

            ############# Using it in Ray Tune ###############
            from ray.tune.integrations.keras import TuneReportCheckpointCallback

            def train_fn():
                model = build_model()
                model.fit(dataset_shard, callbacks=[TuneReportCheckpointCallback()])

            tuner = tune.Tuner(train_fn)
            results = tuner.fit()

    Args:
        metrics: Metrics to report. If this is a list, each item describes
            the metric key reported to Keras, and it's reported under the
            same name. If this is a dict, each key is the name reported
            and the respective value is the metric key reported to Keras.
            If this is None, all Keras logs are reported.
        report_metrics_on: When to report metrics. Must be one of
            the Keras event hooks (less the ``on_``), e.g.
            "train_start" or "predict_end". Defaults to "epoch_end".
        checkpoint_on: When to save checkpoints. Must be one of the Keras event hooks
            (less the ``on_``), e.g. "train_start" or "predict_end". Defaults to
            "epoch_end".

    metrics
checkpointc                 C   s   t jj||d d S )N)r!   raytunereport)selfr    r!   r   r   r   _save_and_report_checkpointB   s   z8TuneReportCheckpointCallback._save_and_report_checkpointc                 C   s   t j| d S r
   r"   )r&   r    r   r   r   _report_metricsG   s   z,TuneReportCheckpointCallback._report_metricsN)r   r   r   r   r   r   r'   r(   r   r   r   r   r      s    "
r   )typingr   ray.tuner#   ray.train.tensorflowr   ray.train.tensorflow.kerasr   ray.util.annotationsr   r   r   r   r   r   r   r   r   <module>   s    