a
    /Sic.                     @   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 ed
dgdeje
ddddZed
g dejdddZedgddd ZdS )z?Connects all half, float and double tensors to CheckNumericsOp.    )context)dtypes)ops)	array_ops)control_flow_ops)deprecation)dispatch)	tf_exportzdebugging.assert_all_finiteverify_tensor_all_finite)v1Nc                 C   s,   t d|d| }t d|d|}t|||S )a  Assert that the tensor does not contain any NaN's or Inf's.

  Args:
    t: Tensor to check.
    msg: Message to log on failure.
    name: A name for this operation (optional).
    x: Alias for t.
    message: Alias for msg.

  Returns:
    Same tensor as `t`.
  xtmessagemsg)r   deprecated_argument_lookupverify_tensor_all_finite_v2)r   r   namer   r    r   Z/var/www/html/django/DPS/env/lib/python3.9/site-packages/tensorflow/python/ops/numerics.pyr
      s
    c              	   C   s   t |d| gd}t j| dd} t | , tj| |d}t|g| }W d   n1 s\0    Y  W d   n1 sz0    Y  |S )zAssert that the tensor does not contain any NaN's or Inf's.

  Args:
    x: Tensor to check.
    message: Message to log on failure.
    name: A name for this operation (optional).

  Returns:
    Same tensor as `x`.
  ZVerifyFiniter   )r   r   N)r   
name_scopeconvert_to_tensorcolocate_withr   check_numericsr   with_dependencies)r   r   r   Zverify_inputoutr   r   r   r   2   s    Jr   add_check_numerics_opsc               
   C   s   t  rtdg } t  D ]}|jD ]|}|jtj	tj
tjfv r*| durXtd|jd t|j }t|   tj||dg} W d   q*1 s0    Y  q*q tj|  S )a  Connect a `tf.debugging.check_numerics` to every floating point tensor.

  `check_numerics` operations themselves are added for each `half`, `float`,
  or `double` tensor in the current default graph. For all ops in the graph, the
  `check_numerics` op for all of its (`half`, `float`, or `double`) inputs
  is guaranteed to run before the `check_numerics` op on any of its outputs.

  Note: This API is not compatible with the use of `tf.cond` or
  `tf.while_loop`, and will raise a `ValueError` if you attempt to call it
  in such a graph.

  Returns:
    A `group` op depending on all `check_numerics` ops added.

  Raises:
    ValueError: If the graph contains any numeric operations in a control flow
      structure.
    RuntimeError: If called with eager execution enabled.

  @compatibility(eager)
  Not compatible with eager execution. To check for `Inf`s and `NaN`s under
  eager execution, call `tf.debugging.enable_check_numerics()` once before
  executing the checked operations.
  @end_compatibility
  zadd_check_numerics_ops() is not compatible with eager execution. To check for Inf's and NaN's under eager execution, call tf.debugging.enable_check_numerics() once before executing the checked operations.Nz`tf.add_check_numerics_ops() is not compatible with TensorFlow control flow operations such as `tf.cond()` or `tf.while_loop()`.:r   )r   executing_eagerlyRuntimeErrorr   get_default_graphget_operationsoutputsdtyper   float16float32float64_get_control_flow_context
ValueErrorr   strvalue_indexcontrol_dependenciesr   r   r   group)Zcheck_opopoutputr   r   r   r   r   G   s    
2)NNNNN)N)__doc__tensorflow.python.eagerr   tensorflow.python.frameworkr   r   tensorflow.python.opsr   r   tensorflow.python.utilr   r    tensorflow.python.util.tf_exportr	   add_dispatch_supportdeprecated_endpointsr
   r   r   r   r   r   r   <module>   s"   

