text
stringlengths
0
4.99k
Returns
String, the current default float type.
Example
>>> tf.keras.backend.floatx()
'float32'
set_floatx function
tf.keras.backend.set_floatx(value)
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.experimental.set_policy('mixed_float16'). See the mixed precision guide for details.
Arguments
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.
image_data_format function
tf.keras.backend.image_data_format()
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'
set_image_data_format function
tf.keras.backend.set_image_data_format(data_format)
Sets the value of the image data format convention.
Arguments
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.
epsilon function
tf.keras.backend.epsilon()
Returns the value of the fuzz factor used in numeric expressions.
Returns
A float.
Example
>>> tf.keras.backend.epsilon()
1e-07
set_epsilon function
tf.keras.backend.set_epsilon(value)
Sets the value of the fuzz factor used in numeric expressions.
Arguments
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)
is_keras_tensor function
tf.keras.backend.is_keras_tensor(x)