Skip to content

TypeError: x and y must have the same dtype, got tf.float32 != tf.float64 #7719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RohanWong opened this issue Oct 25, 2019 · 6 comments
Open
Assignees
Labels
models:research models that come under research directory type:support

Comments

@RohanWong
Copy link

I got the error when running the code of https://github.com/tensorflow/models/tree/master/research/efficient-hrl
on ubuntu 18.04 python 3.6 tensorflow 1.15 and other requirements at latest version.

When running
python scripts/local_train.py test1 hiro_orig ant_maze base_uvf suite

I got the following errors:

Traceback (most recent call last):
  File "./run_train.py", line 49, in <module>
    tf.app.run()
    …
  File "/root/anaconda3/envs/hrl/lib/python3.7/site-packages/tensorflow_core/python/ops/math_ops.py", line 997, in _truediv_python3
    (x_dtype, y_dtype))
TypeError: x and y must have the same dtype, got tf.float32 != tf.float64
  In call to configurable 'train_uvf' (<function train_uvf at 0x7f0b2e5ef320>)
@tensorflowbutler tensorflowbutler added the stat:awaiting response Waiting on input from the contributor label Oct 26, 2019
@tensorflowbutler
Copy link
Member

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks.
What is the top-level directory of the model you are using
Have I written custom code
OS Platform and Distribution
TensorFlow installed from
TensorFlow version
Bazel version
CUDA/cuDNN version
GPU model and memory
Exact command to reproduce

@RohanWong
Copy link
Author

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks.
What is the top-level directory of the model you are using
Have I written custom code
OS Platform and Distribution
TensorFlow installed from
TensorFlow version
Bazel version
CUDA/cuDNN version
GPU model and memory
Exact command to reproduce

directory of the model i used is models-mater/research/efficient-hrl
no custom code
ubuntu 18.04
tensorflow 1.15.0rc0 installed from pip
no Bazel no CUDA/cuDNN no GPU model
the exact command to reproduce is
python scripts/local_train.py test1 hiro_orig ant_maze base_uvf suite

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Waiting on input from the contributor label Oct 27, 2019
@ian-cannon
Copy link
Contributor

ian-cannon commented Apr 8, 2020

Seeing the same thing with both tensorflow 1.15 and tensorflow-gpu 1.15

What is the top-level directory of the model you are using: models/research/efficient-hrl
Have I written custom code: No
OS Platform and Distribution: Ubuntu 18.04
TensorFlow installed from: pip
TensorFlow version: 1.15.0 & tf-gpu 1.15.0
Bazel version: none
CUDA/cuDNN version: 10.2
GPU model and memory: Quadro P5200, 16GB
Exact command to reproduce python scripts/local_train.py test1 hiro_orig ant_maze base_uvf suite

@ian-cannon
Copy link
Contributor

This was solved by changing like 152 of agent.py to normalized_error = tf.cast(error, tf.float64) / tf.constant(spec_range) ** 2

credit to this post: https://stackoverflow.com/questions/56544619/how-to-fix-typeerror-x-and-y-must-have-the-same-dtype-got-tf-uint8-tf-floa

@ravikyram ravikyram added the models:research models that come under research directory label Jun 19, 2020
@ofirnachum
Copy link
Contributor

Thanks for surfacing this. Would you like to make a pull request to fix this?

@ian-cannon

This comment has been minimized.

ian-cannon added a commit to ian-cannon/models that referenced this issue Jun 23, 2020
Update agent.py according to changes noted tensorflow#7719
ofirnachum pushed a commit that referenced this issue Jun 23, 2020
Update agent.py according to changes noted #7719
kmindspark pushed a commit to kmindspark/models that referenced this issue Jul 19, 2020
Update agent.py according to changes noted tensorflow#7719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:research models that come under research directory type:support
Projects
None yet
Development

No branches or pull requests

6 participants