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.py_function throws KeyError when computing Jacobian matrix #60084

Open
trickiwoo opened this issue Mar 23, 2023 · 1 comment
Open

tf.py_function throws KeyError when computing Jacobian matrix #60084

trickiwoo opened this issue Mar 23, 2023 · 1 comment
Assignees
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.11 Issues related to TF 2.11 type:bug Bug

Comments

@trickiwoo
Copy link

trickiwoo commented Mar 23, 2023

Click to expand!

Issue Type

Bug

Have you reproduced the bug with TF nightly?

Yes

Source

source

Tensorflow Version

2.11

Custom Code

Yes

OS Platform and Distribution

No response

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

tf.py_function throws KeyError when computing Jacobian matrix. It works well when it is computing gradient.

Standalone code to reproduce the issue

import os
import tensorflow as tf
import numpy as np

a = tf.Variable([1.0, 2.0])

def square(a):
    return tf.py_function(lambda a: a ** 2, [a], a.dtype)

with tf.GradientTape(persistent=True) as tape:
    tape.watch(a)
    y = square(a)
# gradient = tape.gradient(y, a) # pass
jacobian = tape.jacobian(y, a)
print(jacobian)

Relevant log output

Node: 'gradient_tape/EagerPyFunc'
KeyError: b'pyfunc_0'


         [[{{node gradient_tape/EagerPyFunc}}]] [Op:__inference_f_173]
@google-ml-butler google-ml-butler bot added the type:bug Bug label Mar 23, 2023
@synandi synandi added comp:ops OPs related issues TF 2.11 Issues related to TF 2.11 labels Mar 27, 2023
@synandi
Copy link
Contributor

synandi commented Mar 27, 2023

Hi @trickiwoo, Apologies for the delay. We were able to replicate the issue in Colab using TF v2.11. Please find the gist here. It seems like we have to dig deep into the issue, we'll update here soon. Thank you!

@synandi synandi assigned tilakrayal and unassigned synandi Mar 29, 2023
@tilakrayal tilakrayal added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.11 Issues related to TF 2.11 type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants