
    &Vf!                         d Z ddlZddlZddlmZ ddlmZ ddlmZ 	 ddZ	 ddZ	dd	Z
d
 Z e ej        d                                        ej                                                  ZdS )a"  Summary creation methods for the HParams plugin.

Typical usage for exporting summaries in a hyperparameters-tuning experiment:
1. Create the experiment (once) by calling experiment_pb() and exporting
   the resulting summary into a top-level (empty) run.
2. In each training session in the experiment, call session_start_pb() before
   the session starts, exporting the resulting summary into a uniquely named
   run for the session, say <session_name>.
3. Train the model in the session, exporting each metric as a scalar summary
   in runs of the form <session_name>/<sub_dir>, where <sub_dir> can be empty a
   (in which case the run is just the <session_name>) and depends on the
   metric. The name of such a metric is a (group, tag) pair given by
   (<sub_dir>, tag) where tag is the tag of the scalar summary.
   When calling experiment_pb in step 1, you'll need to pass all the metric
   names used in the experiemnt.
4. When the session completes, call session_end_pb() and export the resulting
   summary into the same session run <session_name>.
    N)api_pb2)metadata)plugin_data_pb2 c                     |t          j                     }t          j        |||| |          }t          t          j        t          j        |                    S )a  Creates a summary that defines a hyperparameter-tuning experiment.

    Args:
      hparam_infos: Array of api_pb2.HParamInfo messages. Describes the
          hyperparameters used in the experiment.
      metric_infos: Array of api_pb2.MetricInfo messages. Describes the metrics
          used in the experiment. See the documentation at the top of this file
          for how to populate this.
      user: String. An id for the user running the experiment
      description: String. A description for the experiment. May contain markdown.
      time_created_secs: float. The time the experiment is created in seconds
      since the UNIX epoch. If None uses the current time.

    Returns:
      A summary protobuffer containing the experiment definition.
    N)descriptionusertime_created_secshparam_infosmetric_infos)
experiment)timer   
Experiment_summaryr   EXPERIMENT_TAGr   HParamsPluginData)r   r   r	   r   r
   r   s         `/var/www/html/software/conda/lib/python3.11/site-packages/tensorboard/plugins/hparams/summary.pyexperiment_pbr   -   sg    &   IKK#+!!  J )Z@@@      c                    |t          j                     }t          j        ||||          }|                                 D ]\  }}t	          |t
                    r||j        |         _        -t	          |t          t          f          r||j        |         _
        \t	          |t                    r||j        |         _        t	          |t          t          f          r t          |          |j        |         _        t          d|d|dt!          |          d          t#          t$          j        t          j        |                    S )a  Constructs a SessionStartInfo protobuffer.

    Creates a summary that contains a training session metadata information.
    One such summary per training session should be created. Each should have
    a different run.

    Args:
      hparams: A dictionary with string keys. Describes the hyperparameter values
               used in the session, mapping each hyperparameter name to its value.
               Supported value types are  `bool`, `int`, `float`, `str`, `list`,
               `tuple`.
               The type of value must correspond to the type of hyperparameter
               (defined in the corresponding api_pb2.HParamInfo member of the
               Experiment protobuf) as follows:

                +-----------------+---------------------------------+
                |Hyperparameter   | Allowed (Python) value types    |
                |type             |                                 |
                +-----------------+---------------------------------+
                |DATA_TYPE_BOOL   | bool                            |
                |DATA_TYPE_FLOAT64| int, float                      |
                |DATA_TYPE_STRING | str, tuple, list   |
                +-----------------+---------------------------------+

               Tuple and list instances will be converted to their string
               representation.
      model_uri: See the comment for the field with the same name of
                 plugin_data_pb2.SessionStartInfo.
      monitor_url: See the comment for the field with the same name of
                   plugin_data_pb2.SessionStartInfo.
      group_name:  See the comment for the field with the same name of
                   plugin_data_pb2.SessionStartInfo.
      start_time_secs: float. The time to use as the session start time.
                       Represented as seconds since the UNIX epoch. If None uses
                       the current time.
    Returns:
      The summary protobuffer mentioned above.
    N)	model_urimonitor_url
group_namestart_time_secszhparams[z]=z has type: z which is not supported)session_start_info)r   r   SessionStartInfoitems
isinstanceboolhparams
bool_valuefloatintnumber_valuestrstring_valuelisttuple	TypeErrortyper   r   SESSION_START_INFO_TAGr   )r    r   r   r   r   r   hp_namehp_vals           r   session_start_pbr.   O   sd   R )++(9'	   %]]__  & fd## 	=C&w/::-- 
	?E&w/<<$$ 	?E&w/<<u.. 	?B6{{&w/<<)77FFFDLLLL2   ')1	
 	
 	
  r   c                     |t          j                     }t          j        | |          }t          t          j        t          j        |                    S )ax  Constructs a SessionEndInfo protobuffer.

    Creates a summary that contains status information for a completed
    training session. Should be exported after the training session is completed.
    One such summary per training session should be created. Each should have
    a different run.

    Args:
      status: A tensorboard.hparams.Status enumeration value denoting the
          status of the session.
      end_time_secs: float. The time to use as the session end time. Represented
          as seconds since the unix epoch. If None uses the current time.

    Returns:
      The summary protobuffer mentioned above.
    N)statusend_time_secs)session_end_info)r   r   SessionEndInfor   r   SESSION_END_INFO_TAGr   )r0   r1   r2   s      r   session_end_pbr5      s^    " 	&5]   %);KLLL  r   c                 2   t           j        j                                        }t	          j        |          }|                                }t           j        j        j                            |          }|j	        
                    | |t                     |S )zReturns a summary holding the given HParamsPluginData message.

    Helper function.

    Args:
      tag: string. The tag to use.
      hparams_plugin_data: The HParamsPluginData message to use.
    )tagr   tensor)tfcompatv1Summaryr   create_summary_metadataSerializeToStringSummaryMetadata
FromStringvalueadd_TF_NULL_TENSOR)r7   hparams_plugin_datasummarytb_metadataraw_metadatatf_metadatas         r   r   r      s     il""$$G23FGGK0022L),.99,GGKM    
 Nr   )r   r   N)r   r   r   N)N)__doc__r   
tensorflowr9   tensorboard.plugins.hparamsr   r   r   r   r.   r5   r   r*   make_tensor_protor@   NULL_TENSORr>   rC    r   r   <module>rO      s   (      / / / / / / 0 0 0 0 0 0 7 7 7 7 7 7 LP   F KOF F F FR   :  . $+r+A..//::**,, r   