
    &Vfm(                         d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	  ed           G d d                      Z
dS )    N)backend)keras_export)io_utilszkeras.utils.Progbarc                   @    e Zd ZdZ	 	 	 	 	 ddZddZdd	Zd
 Zd ZdS )Progbara_  Displays a progress bar.

    Args:
        target: Total number of steps expected, None if unknown.
        width: Progress bar width on screen.
        verbose: Verbosity mode, 0 (silent), 1 (verbose), 2 (semi-verbose)
        stateful_metrics: Iterable of string names of metrics that should *not*
            be averaged over time. Metrics in this list will be displayed as-is.
            All others will be averaged by the progbar before display.
        interval: Minimum visual progress update interval (in seconds).
        unit_name: Display name for step counts (usually "step" or "sample").
          皙?Nstepc                 
   || _         || _        || _        || _        || _        |rt          |          | _        nt                      | _        t          t          j	        d          rt          j	        
                                p)dt          j        v pdt          j        v pdt          j        v | _        d| _        i | _        g | _        t%          j                    | _        d| _        | j        | _        d | _        d| _        d S )Nisatty	ipykernelposixPYCHARM_HOSTEDr   )targetwidthverboseinterval	unit_namesetstateful_metricshasattrsysstdoutr   modulesosenviron_dynamic_display_seen_so_far_values_values_ordertime_start_last_update_time_at_epoch_start_time_after_first_step_prev_total_width)selfr   r   r   r   r   r   s          T/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/utils/progbar.py__init__zProgbar.__init__   s     
 " 	*$'(8$9$9D!!$'EED! SZ**Bsz/@/@/B/B .ck).#+%.  2:-	 	  ikk$(K!&*#!"    c                 *
   || j         d}n|| j         k    }|pg }|D ]\  }}|| j        vr| j                            |           || j        vrkt	          || j        z
  d          }|| j        vr||z  |g| j        |<   b| j        |         dxx         ||z  z  cc<   | j        |         dxx         |z  cc<   |dg| j        |<   || _        d}d}t          j                    }	|                     ||	          }
| j	        dk    r|	| j
        z
  | j        k     r|sdS | j        r|d| j        z  z  }|dz  }n|dz  }| j         t          t          j        | j                             dz   }d	t#          |          z   d
z   || j         fz  }d| d}|dz  }t%          |          | j         z  }t          | j        |z            }|dk    r|dd|z  z   dz   z  }|dz  }|dd| j        |z
  z  z   dz   z  }|dz  }nd|z  }||z  }| j         J|sH|
| j         |z
  z  }|dk    rd|dz  |dz  dz  |dz  fz  }n|dk    rd|dz  |dz  fz  }nd|z  }d| d}nd|	| j        z
  dd}|dz  }||                     |
| j                  z  }| j        D ]}|d| dz  }t/          | j        |         t0                    rt3          j        t2          j                            | j        |         d         t	          d| j        |         d                   z                      }t%          |          }t;          |          dk    r
|d|d z  }|d|d!z  }|d| j        |          z  }||z  }t=          |          t=          |          z   |z
  }| j        |k    r|d| j        |z
  z  z  }|r|dz  }t?          j         |d"           || _        d}n;| j	        d#k    r/|r,t          t          j        | j                             dz   }d	t#          |          z   d
z   || j         fz  }| d|	| j        z
  dd$}|d%|                     |
| j                  z   z  }| j        D ]}|d| dz  }t3          j        t2          j                            | j        |         d         t	          d| j        |         d                   z                      }|dk    r
|d|d z  }|d|d!z  }|dz  }||z  }t?          j         |d"           d}|	| _
        dS )&a  Updates the progress bar.

        Args:
            current: Index of current step.
            values: List of tuples: `(name, value_for_last_step)`. If `name` is
                in `stateful_metrics`, `value_for_last_step` will be displayed
                as-is. Else, an average of the metric over time will be
                displayed.
            finalize: Whether this is the last update for the progress bar. If
                `None`, defaults to `current >= self.target`.
        NFr	   r    
%zd/%dz[1mz[0m    z[32mu   ━z[0m	   z[37mz%7d/Unknowni  z%d:%02d:%02d<   z%d:%02dz%dsz [1m.0fzs[0mz - :MbP? z.4fz.4e)
line_break   sz -)!r   r!   appendr   maxr   r    r"   _estimate_step_durationr   r$   r   r   r'   intmathlog10strfloatr   r#   _format_timer   
isinstancelistr   convert_to_numpynumpymeanabslenr   	print_msg)r(   currentvaluesfinalizekv
value_basemessagespecial_char_lennowtime_per_unit	numdigitsbarprog
prog_widtheta
eta_formatinfoavgtotal_widthcounts                        r)   updatezProgbar.update>   sQ    {" "dk12 	) 	)DAq***"))!,,,--- !4+<!<a@@
DL(('(:~z&BDLOOLOA&&&!j.8&&&LOA&&&*4&&&&
 $%a&Q#ikk44WcBB<1T&&66x6$  4$"88844{&
4; 7 7881<	S^^+f4$+8NN---- A% W~~3 d!233
>>9uz'99IEEC$)$y5DJ,C#DDyPP A%   $g-sNG {&x&#t{W'<=::!/tt*b3 "JJ
 2XX!*cRir-B!BJJ!&J5*555 B#"3AAAA! D%%mT^DDDD ' 2 2
a


"dl1ot44 2!2** LOA.QQ8J1K1KK  C
  **C3xx$C-C-1Q111DDtOGc((SYY.1AAK%333$"8;"FGG  4w59999%0D"GG\Q 
4; 7 7881<	s9~~-67DK:PP<<C$+$5<<<<t00OOOO+ 
. 
.AJ!JJJ&D!2** LOA.QQ8J1K1KK  C
 TzzC-C-4"7u====r+   c                 B    |                      | j        |z   |           d S N)ra   r   )r(   nrN   s      r)   addzProgbar.add   s$    D%)622222r+   c                     d}|dk    s|dk    r|d|dd| z  }n%|dk    r|d|dz  dd	| z  }n|d|d
z  dd| z  }|S )a  format a given duration to display to the user.

        Given the duration, this function formats it in either milliseconds
        or seconds and displays the unit (i.e. ms/step or s/epoch).

        Args:
            time_per_unit: the duration to display
            unit_name: the name of the unit to display

        Returns:
            A string with the correctly formatted duration and units
        r-   r	   r   r8   r5   zs/r7   g     @@zms/g    .Azus/ )r(   rV   r   	formatteds       r)   rD   zProgbar._format_time   s     	A!!3!3=]===)===IId""G]V3GGGIGGGIIJ]Y6JJJyJJJIr+   c                 ~    |r:| j         |dk    r|| j         z
  |dz
  z  }n|| j        z
  |z  }|dk    r|| _         |S dS )a  Estimate the duration of a single step.

        Given the step number `current` and the corresponding time `now` this
        function returns an estimate for how long a single step takes. If this
        is called before one step has been completed (i.e. `current == 0`) then
        zero is given as an estimate. The duration estimate ignores the duration
        of the (assumed to be non-representative) first step for estimates when
        more steps are available (i.e. `current>1`).

        Args:
            current: Index of current step.
            now: The current time.

        Returns: Estimate of the duration of a single step.
        Nr	   r   )r&   r#   )r(   rM   rU   rV   s       r)   r>   zProgbar._estimate_step_duration   si       	 *67Q;;!$t'B!BaK! "%t{!2g =!||.1+  1r+   )r   r	   r
   Nr   )NNrc   )	__name__
__module____qualname____doc__r*   ra   re   rD   r>   rg   r+   r)   r   r      s           "# "# "# "#HR  R  R  R h3 3 3 3  ," " " " "r+   r   )r@   r   r   r"   	keras.srcr   keras.src.api_exportr   keras.src.utilsr   r   rg   r+   r)   <module>rq      s     				 



        - - - - - - $ $ $ $ $ $ #$$A A A A A A A %$A A Ar+   