You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have I written custom code (as opposed to using a stock example script provided in Keras): I didn't execute an official example script.
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Arch Linux and Ubuntu 20.04
TensorFlow installed from (source or binary): binaries from conda-forge and pip3
TensorFlow version (use command below): intel_tensorflow 2.6.0, tensorflow 2.6.0 from conda-forge, tensorflow-gpu 2.4.1 from conda-forge and tensorflow 2.6.1 from pip3
Python version: 3.9.7
Bazel version (if compiling from source):
GPU model and memory: no nvidia GPU and Nvidia GeForce RTX 3080
Exact command to reproduce: python3 -c 'import tensorflow as tf; tf.keras.backend.set_floatx("float64"); print(tf.keras.backend.floatx(), tf.constant(1.0))'
Describe the problem.
I would like to change the default float precision for initialising tensors and found the tf.keras.backend.set_floatx function in the documentation.
When I use this function, tf.keras.backend.floatx() shows the configured float type but unexpectedly this type does not affect the type of created tensors:
python3-c'import tensorflow as tf; tf.keras.backend.set_floatx("float64"); print(tf.keras.backend.floatx(), tf.constant(1.0))'
The command outputs float64 tf.Tensor(1.0, shape=(), dtype=float32) when I execute it.
I have tested it with intel_tensorflow 2.6.0, tensorflow 2.6.0 from conda-forge, tensorflow-gpu 2.4.1 from conda-forge and tensorflow 2.6.1 from pip3. The type of the created tensor never matched the configured default type.
The documentation only shows Sets the default float type., so I assume that the floatx is supposed to affect both keras and tensorflow.
If this is not the case, I would like to know if it is possible at all to globally change the default dtype in tensorflow tensor initialisations such as tf.zeros and tf.constant.
Describe the current behavior.
The default float precision is used when creating a tensor.
Describe the expected behavior.
If I don't explicitly specify a dtype argument, the dtype is float32 and not the current keras backend floatx.
tf.keras.backend.set_floatx supports only for Keras and it doesn't have any effect on Tensorflow, Can you take a look at this issue? where a similar feature has been proposed and it is still open. Thanks!
System information.
python3 -c 'import tensorflow as tf; tf.keras.backend.set_floatx("float64"); print(tf.keras.backend.floatx(), tf.constant(1.0))'
Describe the problem.
I would like to change the default float precision for initialising tensors and found the tf.keras.backend.set_floatx function in the documentation.
When I use this function,
tf.keras.backend.floatx()
shows the configured float type but unexpectedly this type does not affect the type of created tensors:The command outputs
float64 tf.Tensor(1.0, shape=(), dtype=float32)
when I execute it.I have tested it with intel_tensorflow 2.6.0, tensorflow 2.6.0 from conda-forge, tensorflow-gpu 2.4.1 from conda-forge and tensorflow 2.6.1 from pip3. The type of the created tensor never matched the configured default type.
Issue at tensorflow: tensorflow/tensorflow#52941
More related issues: #15226, tensorflow/tensorflow#51379
The documentation only shows
Sets the default float type.
, so I assume that the floatx is supposed to affect both keras and tensorflow.If this is not the case, I would like to know if it is possible at all to globally change the default dtype in tensorflow tensor initialisations such as
tf.zeros
andtf.constant
.Describe the current behavior.
The default float precision is used when creating a tensor.
Describe the expected behavior.
If I don't explicitly specify a dtype argument, the dtype is float32 and not the current keras backend floatx.
Contributing.
Standalone code to reproduce the issue.
The text was updated successfully, but these errors were encountered: