§
    -P„jœ  ã                   ó²   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ g d	¢Zdd„Zdd„Zdd„Zdd„Z	 	 dd„Zdd„Zdd„Zdd„Zdd„Zd
S )az  Contains helper functions for creating summaries.

This module contains various helper functions for quickly and easily adding
tensorflow summaries. These allow users to print summary values
automatically as they are computed and add prefixes to collections of summaries.

Example usage:
  import tf_slim as slim

  slim.summaries.add_histogram_summaries(slim.variables.get_model_variables())
  slim.summaries.add_scalar_summary(total_loss, 'Total Loss')
  slim.summaries.add_scalar_summary(learning_rate, 'Learning Rate')
  slim.summaries.add_histogram_summaries(my_tensors)
  slim.summaries.add_zero_fraction_summaries(my_tensors)

é    )Úabsolute_import)Údivision)Úprint_function)Úops)Úlogging_ops)Únn_impl)Úsummary)Úadd_histogram_summaryÚadd_image_summaryÚadd_scalar_summaryÚadd_zero_fraction_summaryÚadd_histogram_summariesÚadd_image_summariesÚadd_scalar_summariesÚadd_zero_fraction_summariesNc                 óJ   — |s| j         j        }|r|dz   |z   }|r|dz   |z   }|S )a  Produces the summary name given.

  Args:
    tensor: A variable or op `Tensor`.
    name: The optional name for the summary.
    prefix: An optional prefix for the summary name.
    postfix: An optional postfix for the summary name.

  Returns:
    a summary name.
  ú/)ÚopÚname)Útensorr   ÚprefixÚpostfixs       úV/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/tf_slim/summaries.pyÚ_get_summary_namer   8   sF   € ð 
ð ØŒ9Œ>€DØð Ø�C‰<˜$Ñ€DØð  Ø�#‰:˜Ñ€DØ	€+ó    c                 óJ   — t          j        t          | ||¦  «        | ¦  «        S )a6  Adds a histogram summary for the given tensor.

  Args:
    tensor: A variable or op tensor.
    name: The optional name for the summary.
    prefix: An optional prefix for the summary names.

  Returns:
    A scalar `Tensor` of type `string` whose contents are the serialized
    `Summary` protocol buffer.
  )r	   Ú	histogramr   )r   r   r   s      r   r
   r
   M   s*   € õ 
Ô	Ý˜  fÑ-Ô-¨vñ
7ô 
7ð 7r   Fc                 óÜ   — t          | ||¦  «        }|rg nd}t          j        || |¬¦  «        }|r;t          j        || g|¦  «        }t          j        t
          j        j        |¦  «         |S )a¾  Adds an image summary for the given tensor.

  Args:
    tensor: a variable or op tensor with shape [batch,height,width,channels]
    name: the optional name for the summary.
    prefix: An optional prefix for the summary names.
    print_summary: If `True`, the summary is printed to stdout when the summary
      is computed.

  Returns:
    An image `Tensor` of type `string` whose contents are the serialized
    `Summary` protocol buffer.
  N©r   r   Úcollections)	r   r	   Úimager   ÚPrintr   Úadd_to_collectionÚ	GraphKeysÚ	SUMMARIES)r   r   r   Úprint_summaryÚsummary_namer    r   s          r   r   r   ]   s€   € õ # 6¨4°Ñ8Ô8€,ð $Ð-��¨€+Ý„}Ø °KðAñ Aô A€"àð 7Ý	Ô	˜2 ˜x¨Ñ	6Ô	6€BÝÔ�#œ-Ô1°2Ñ6Ô6Ð6Ø	€)r   c                 óÜ   — |rg nd}t          | ||¦  «        }t          j        || |¬¦  «        }|r;t          j        || g|¦  «        }t          j        t
          j        j        |¦  «         |S )a–  Adds a scalar summary for the given tensor.

  Args:
    tensor: a variable or op tensor.
    name: the optional name for the summary.
    prefix: An optional prefix for the summary names.
    print_summary: If `True`, the summary is printed to stdout when the summary
      is computed.

  Returns:
    A scalar `Tensor` of type `string` whose contents are the serialized
    `Summary` protocol buffer.
  Nr   )	r   r	   Úscalarr   r"   r   r#   r$   r%   )r   r   r   r&   r    r'   r   s          r   r   r   w   s€   € ð $Ð-��¨€+Ý" 6¨4°Ñ8Ô8€,õ „~Ø °KðAñ Aô A€"àð 7Ý	Ô	˜2 ˜x¨Ñ	6Ô	6€BÝÔ�#œ-Ô1°2Ñ6Ô6Ð6Ø	€)r   c                 ór   — t          | ||d¦  «        }t          j        | ¦  «        } t          | ||¬¦  «        S )a°  Adds a summary for the percentage of zero values in the given tensor.

  Args:
    tensor: a variable or op tensor.
    name: the optional name for the summary.
    prefix: An optional prefix for the summary names.
    print_summary: If `True`, the summary is printed to stdout when the summary
      is computed.

  Returns:
    A scalar `Tensor` of type `string` whose contents are the serialized
    `Summary` protocol buffer.
  ÚFraction_of_Zero_Values)r&   )r   ÚnnÚzero_fractionr   )r   r   r   r&   s       r   r   r   ’   s=   € õ 
˜6 4¨Ð1JÑ	KÔ	K€$ÝÔ˜FÑ#Ô#€&Ý	˜F D¸Ð	FÑ	FÔ	FÐFr   c                 ó\   — g }| D ]&}|                      t          ||¬¦  «        ¦  «         Œ'|S )a%  Adds a histogram summary for each of the given tensors.

  Args:
    tensors: A list of variable or op tensors.
    prefix: An optional prefix for the summary names.

  Returns:
    A list of scalar `Tensors` of type `string` whose contents are the
    serialized `Summary` protocol buffer.
  ©r   )Úappendr
   ©Útensorsr   Úsummary_opsr   s       r   r   r   ¦   sE   € ð €+Øð Eð E€fØ×ÒÕ,¨V¸FÐCÑCÔCÑDÔDÐDÐDØ	Ðr   c                 ó\   — g }| D ]&}|                      t          ||¬¦  «        ¦  «         Œ'|S )a"  Adds an image summary for each of the given tensors.

  Args:
    tensors: A list of variable or op tensors.
    prefix: An optional prefix for the summary names.

  Returns:
    A list of scalar `Tensors` of type `string` whose contents are the
    serialized `Summary` protocol buffer.
  r/   )r0   r   r1   s       r   r   r   ·   sE   € ð €+Øð Að A€fØ×ÒÕ(¨¸Ð?Ñ?Ô?Ñ@Ô@Ð@Ð@Ø	Ðr   c                 ó^   — g }| D ]'}|                      t          |||¬¦  «        ¦  «         Œ(|S )a…  Adds a scalar summary for each of the given tensors.

  Args:
    tensors: a list of variable or op tensors.
    prefix: An optional prefix for the summary names.
    print_summary: If `True`, the summary is printed to stdout when the summary
      is computed.

  Returns:
    A list of scalar `Tensors` of type `string` whose contents are the
    serialized `Summary` protocol buffer.
  )r   r&   )r0   r   )r2   r   r&   r3   r   s        r   r   r   È   s]   € ð €+Øð Hð H€fØ×ÒÕ)¨&¸Ø8EðGñ Gô Gñ Hô Hð Hð Hà	Ðr   c                 ó\   — g }| D ]&}|                      t          ||¬¦  «        ¦  «         Œ'|S )a0  Adds a scalar zero-fraction summary for each of the given tensors.

  Args:
    tensors: a list of variable or op tensors.
    prefix: An optional prefix for the summary names.

  Returns:
    A list of scalar `Tensors` of type `string` whose contents are the
    serialized `Summary` protocol buffer.
  r/   )r0   r   r1   s       r   r   r   Ü   sE   € ð €+Øð Ið I€fØ×ÒÕ0°ÀÐGÑGÔGÑHÔHÐHÐHØ	Ðr   )NNN)NN)NNF)N)NF)Ú__doc__Ú
__future__r   r   r   Útensorflow.python.frameworkr   Útensorflow.python.opsr   r   r,   Útensorflow.python.summaryr	   Ú__all__r   r
   r   r   r   r   r   r   r   © r   r   ú<module>r>      sl  ðð"ð ð  'Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %ð ,Ð +Ð +Ð +Ð +Ð +Ø -Ð -Ð -Ð -Ð -Ð -Ø /Ð /Ð /Ð /Ð /Ð /Ø -Ð -Ð -Ð -Ð -Ð -ð	ð 	ð 	€ðð ð ð ð*7ð 7ð 7ð 7ð ð ð ð ð4ð ð ð ð6 9=Ø,1ðGð Gð Gð Gð(ð ð ð ð"ð ð ð ð"ð ð ð ð(ð ð ð ð ð r   