Skip to content
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

[TF 2.0] Using tf.py_function which has tf.string type input in dataset.map() generates dtype warning. #28248

Closed
KichangKim opened this issue Apr 29, 2019 · 10 comments · Fixed by #30107
Assignees
Labels
comp:eager Eager related issues good first issue Good first issue for newcomers. stat:contribution welcome Status - Contributions welcome TF 2.0 Issues relating to TensorFlow 2.0 type:docs-bug Document issues

Comments

@KichangKim
Copy link

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64 1809
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): pip
  • TensorFlow version (use command below): unknown 2.0.0-dev20190428
  • Python version: 3.6.7
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: CUDA 10.0, cudnn-10.0-windows10-x64-v7.5.0.56
  • GPU model and memory: GeForce GTX 1070 8GB

Describe the current behavior
Using tf.py_function which has tf.string type input generates warning like this:

W0429 14:24:18.965364 13252 backprop.py:820] The dtype of the watched tensor must be floating (e.g. tf.float32), got tf.string

This warning did not shown with v1.12.0-9492-g2c319fb415 2.0.0-alpha0, but 2.0.0-dev20190428 does.

Describe the expected behavior
dtype warning should not be shown.

Code to reproduce the issue

import tensorflow as tf


def transform_tag_python(x):
    return 1.0


dataset = tf.data.Dataset.from_tensor_slices(['tag1'])
dataset = dataset.map(lambda x: tf.py_function(
    transform_tag_python, (x,), (tf.float32,)))

for sample in dataset:
    print(sample)
@shashvatshahi1998
Copy link
Contributor

Look where tf.py_function is defined there is no such warning file present regarding dtype to be float. So why it is showing this?

@rbrueckner
Copy link

I am facing the same issue.

@achandraa achandraa self-assigned this May 2, 2019
@achandraa achandraa added comp:ops OPs related issues type:support Support issues TF 2.0 Issues relating to TensorFlow 2.0 labels May 2, 2019
@achandraa achandraa assigned jvishnuvardhan and unassigned achandraa May 3, 2019
@jvishnuvardhan jvishnuvardhan added comp:data tf.data related issues and removed comp:ops OPs related issues labels May 6, 2019
@jvishnuvardhan
Copy link
Contributor

@KichangKim There was no warning when TF2.0.0-alpha0 or tf-nightly was used. The issue was reproduced with tf-nightly-2.0-preview. We will check for the source of error and resolve it. Thanks for finding this. Thanks!

@jvishnuvardhan jvishnuvardhan added type:docs-bug Document issues and removed type:support Support issues labels May 6, 2019
@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label May 7, 2019
@sleighsoft
Copy link
Contributor

sleighsoft commented Jun 17, 2019

Here:

logging.WARN, "The dtype of the watched tensor must be "

Having the same issue even though the statement is not within tf.GradientTape.

Even simpler example:

import tensorflow as tf

tensor = tf.constant([1,2,3])
tf.py_function(lambda x: x.numpy(), [tensor], tensor.dtype)

I am wondering why this code is called anyways. My example does not even use GradientTape.

Callstack of test.py (just includes code above):
grafik

I am not sure it is intended that a py_function has a GradientTape by default.

@jsimsa jsimsa assigned alextp and unassigned jsimsa Jun 24, 2019
@alextp alextp added stat:contribution welcome Status - Contributions welcome comp:eager Eager related issues good first issue Good first issue for newcomers. and removed stat:awaiting tensorflower Status - Awaiting response from tensorflower comp:data tf.data related issues labels Jun 24, 2019
@alextp
Copy link
Contributor

alextp commented Jun 24, 2019

It's likely the tape.watch here

which needs to be called only for floating dtypes.

@alextp
Copy link
Contributor

alextp commented Jun 24, 2019

I'll happily accept a PR to fix this.

@feihugis
Copy link
Member

The PR #30107 is submitted to fix this issue.

cc @alextp

@vineetred
Copy link

Looks like the PR failed a few checks. Is the issue still persisting?

@shubhraaich
Copy link

This issue still exists in tf-2 version beta-1.

@sleighsoft
Copy link
Contributor

You have to use nightly builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:eager Eager related issues good first issue Good first issue for newcomers. stat:contribution welcome Status - Contributions welcome TF 2.0 Issues relating to TensorFlow 2.0 type:docs-bug Document issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.