On this page
tf.keras.backend.set_floatx
Sets the default float type.
tf.keras.backend.set_floatx(
value
)
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 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. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/backend/set_floatx