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

Allow tf.GradientTape.batch_jacobian to accept containers of tensors as source #56938

Open
cammyoung opened this issue Jul 28, 2022 · 0 comments
Assignees
Labels
comp:autograph Autograph related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests

Comments

@cammyoung
Copy link

cammyoung commented Jul 28, 2022

Click to expand!

Issue Type

Feature Request

Source

binary

Tensorflow Version

tf 2.8.2

Custom Code

No

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?

At the moment, containers of tensors are supported by `tf.GradientTape.jacobian`, but not `tf.GradientTape.batch_jacobian`.

If this behavior was allowed in `batch_jacobian`, I would expect it to return the same container with tensors equal to the `batch_jacobian` of `target` with respect to each tensor in the `source` container.

Example expected output shown in the colab.

Standalone code to reproduce the issue

https://colab.research.google.com/drive/1RTv34VMa-joB45x7xu-9H3pdSTnDAj72?usp=sharing

Relevant log output

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-5c1f96355dc5> in <module>()
      6     pred = my_model(x, training=False)[:, :, 0]
      7 
----> 8 j = tape.batch_jacobian(pred, x)

/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/backprop.py in batch_jacobian(self, target, source, unconnected_gradients, parallel_iterations, experimental_use_pfor)
   1287       dim = target_shape.dims[0]
   1288     if not (target_shape.with_rank_at_least(2) and
-> 1289             source.shape.with_rank_at_least(2) and
   1290             dim.is_compatible_with(source.shape[0])):
   1291       raise ValueError(

AttributeError: 'dict' object has no attribute 'shape'
@google-ml-butler google-ml-butler bot added the type:feature Feature requests label Jul 28, 2022
@tilakrayal tilakrayal added the comp:ops OPs related issues label Jul 29, 2022
@sachinprasadhs sachinprasadhs added comp:autograph Autograph related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower and removed comp:ops OPs related issues labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:autograph Autograph related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

3 participants