o
    ?e                     @   s   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	 dd	lm
Z
 dd
lmZ ddlmZ edejdejdfddZedejdejdfddZdS )zHistograms.
    )dtypes)ops)	array_ops)clip_ops)control_flow_assert)control_flow_ops)gen_math_ops)math_ops)dispatch)	tf_exporthistogram_fixed_width_binsd   Nc           
   	   C   s  t |d| ||gu t j| dd} t| }t| dg} t j|dd}t j|tjdd}t	t
|dd	| g}t|g|}t
|| j}t
j| |d  |d
 |d  dd}t
j|| dd}	t
t|	d|d
 tj}	t|	|W  d   S 1 sw   Y  dS )a  Bins the given values for use in a histogram.

  Given the tensor `values`, this operation returns a rank 1 `Tensor`
  representing the indices of a histogram into which each element
  of `values` would be binned. The bins are equal width and
  determined by the arguments `value_range` and `nbins`.

  Args:
    values:  Numeric `Tensor`.
    value_range:  Shape [2] `Tensor` of same `dtype` as `values`.
      values <= value_range[0] will be mapped to hist[0],
      values >= value_range[1] will be mapped to hist[-1].
    nbins:  Scalar `int32 Tensor`.  Number of histogram bins.
    dtype:  dtype for returned histogram.
    name:  A name for this operation (defaults to 'histogram_fixed_width').

  Returns:
    A `Tensor` holding the indices of the binned values whose shape matches
    `values`.

  Raises:
    TypeError: If any unsupported dtype is provided.
    tf.errors.InvalidArgumentError: If value_range does not
        satisfy value_range[0] < value_range[1].

  Examples:

  >>> # Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
  ...
  >>> nbins = 5
  >>> value_range = [0.0, 5.0]
  >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
  >>> indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
  >>> indices.numpy()
  array([0, 0, 1, 2, 4, 4], dtype=int32)
  r   values)namevalue_rangenbinsdtyper   r   znbins %s must > 0   scaled_valuesindicesN)r   
name_scopeZconvert_to_tensorr   shapeZreshaper   int32r   Assertr	   Zgreaterr   Zwith_dependenciescastr   truedivfloorr   Zclip_by_value)
r   r   r   r   r   r   checkZnbins_floatr   r    r    d/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/histogram_ops.pyr      s0   +


$histogram_fixed_widthc                 C   sL   t |d| ||g}tj| ||||dW  d   S 1 sw   Y  dS )a  Return histogram of values.

  Given the tensor `values`, this operation returns a rank 1 histogram counting
  the number of entries in `values` that fell into every bin.  The bins are
  equal width and determined by the arguments `value_range` and `nbins`.

  Args:
    values:  Numeric `Tensor`.
    value_range:  Shape [2] `Tensor` of same `dtype` as `values`.
      values <= value_range[0] will be mapped to hist[0],
      values >= value_range[1] will be mapped to hist[-1].
    nbins:  Scalar `int32 Tensor`.  Number of histogram bins.
    dtype:  dtype for returned histogram.
    name:  A name for this operation (defaults to 'histogram_fixed_width').

  Returns:
    A 1-D `Tensor` holding histogram of values.

  Raises:
    TypeError: If any unsupported dtype is provided.
    tf.errors.InvalidArgumentError: If value_range does not
        satisfy value_range[0] < value_range[1].

  Examples:

  >>> # Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
  ...
  >>> nbins = 5
  >>> value_range = [0.0, 5.0]
  >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
  >>> hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
  >>> hist.numpy()
  array([2, 1, 1, 0, 2], dtype=int32)
  r"   r   N)r   r   r   Z_histogram_fixed_width)r   r   r   r   r   r    r    r!   r"   g   s   )
$)__doc__Ztensorflow.python.frameworkr   r   Ztensorflow.python.opsr   r   r   r   r   r	   Ztensorflow.python.utilr
   Z tensorflow.python.util.tf_exportr   Zadd_dispatch_supportr   r   r"   r    r    r    r!   <module>   s.   F