B
    Ó»ˆd  ã               @   s˜   d Z ddlmZ ddlmZ dadadaedƒejdd	„ ƒƒZ	ed
ƒdd„ ƒZ
edƒdd„ ƒZedƒdd„ ƒZedƒejdd„ ƒƒZedƒdd„ ƒZdS )zKeras backend config API.é    )Údispatch)Úkeras_exportÚfloat32gH¯¼šò×z>Úchannels_lastzkeras.backend.epsilonc               C   s   t S )z”Returns the value of the fuzz factor used in numeric expressions.

  Returns:
      A float.

  Example:
  >>> tf.keras.backend.epsilon()
  1e-07
  )Ú_EPSILON© r   r   úX/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/keras/backend_config.pyÚepsilon   s    r	   zkeras.backend.set_epsilonc             C   s   | a dS )a%  Sets the value of the fuzz factor used in numeric expressions.

  Args:
      value: float. New value of epsilon.

  Example:
  >>> tf.keras.backend.epsilon()
  1e-07
  >>> tf.keras.backend.set_epsilon(1e-5)
  >>> tf.keras.backend.epsilon()
  1e-05
   >>> tf.keras.backend.set_epsilon(1e-7)
  N)r   )Úvaluer   r   r   Úset_epsilon-   s    r   zkeras.backend.floatxc               C   s   t S )zÐReturns the default float type, as a string.

  E.g. `'float16'`, `'float32'`, `'float64'`.

  Returns:
      String, the current default float type.

  Example:
  >>> tf.keras.backend.floatx()
  'float32'
  )Ú_FLOATXr   r   r   r   Úfloatx@   s    r   zkeras.backend.set_floatxc             C   s$   | dkrt dt| ƒ ƒ‚t| ƒadS )aã  Sets the default float type.

  Note: It is not recommended to set this to float16 for training, as this will
  likely cause numeric stability issues. Instead, mixed precision, which is
  using a mix of float16 and float32, can be used by calling
  `tf.keras.mixed_precision.set_global_policy('mixed_float16')`. See the
  [mixed precision guide](
    https://www.tensorflow.org/guide/keras/mixed_precision) for details.

  Args:
      value: String; `'float16'`, `'float32'`, or `'float64'`.

  Example:
  >>> tf.keras.backend.floatx()
  'float32'
  >>> tf.keras.backend.set_floatx('float64')
  >>> tf.keras.backend.floatx()
  'float64'
  >>> tf.keras.backend.set_floatx('float32')

  Raises:
      ValueError: In case of invalid value.
  >   r   Úfloat16Úfloat64zUnknown floatx type: N)Ú
ValueErrorÚstrr   )r
   r   r   r   Ú
set_floatxP   s    r   zkeras.backend.image_data_formatc               C   s   t S )zÈReturns the default image data format convention.

  Returns:
      A string, either `'channels_first'` or `'channels_last'`

  Example:
  >>> tf.keras.backend.image_data_format()
  'channels_last'
  )Ú_IMAGE_DATA_FORMATr   r   r   r   Úimage_data_formato   s    r   z#keras.backend.set_image_data_formatc             C   s$   | dkrt dt| ƒ ƒ‚t| ƒadS )aÌ  Sets the value of the image data format convention.

  Args:
      data_format: string. `'channels_first'` or `'channels_last'`.

  Example:
  >>> tf.keras.backend.image_data_format()
  'channels_last'
  >>> tf.keras.backend.set_image_data_format('channels_first')
  >>> tf.keras.backend.image_data_format()
  'channels_first'
  >>> tf.keras.backend.set_image_data_format('channels_last')

  Raises:
      ValueError: In case of invalid `data_format` value.
  >   Úchannels_firstr   zUnknown data_format: N)r   r   r   )Zdata_formatr   r   r   Úset_image_data_format~   s    r   N)Ú__doc__Ztensorflow.python.utilr   Z tensorflow.python.util.tf_exportr   r   r   r   Zadd_dispatch_supportr	   r   r   r   r   r   r   r   r   r   Ú<module>   s   