addons
addons copied to clipboard
No gradients to transforms in tfa.image.transform
Describe the feature and the current behavior/state. back prop the gradient to transforms.
Relevant information
- Are you willing to contribute it (yes/no): no
- Are you willing to maintain it going forward? (yes/no): no
- Is there a relevant academic paper? (if so, where): no
- Does the relavent academic paper exceed 50 citations? (yes/no): no
- Is there already an implementation in another framework? (if so, where):
- https://tensorlayer.readthedocs.io/en/latest/_modules/tensorlayer/layers/spatial_transformer.html
- http://pytorch.org/vision/main/generated/torchvision.transforms.functional.affine.html
- Was it part of tf.contrib? (if so, where): no
Which API type would this fall under (layer, metric, optimizer, etc.) tfa.image.transform
Who will benefit with this feature? Implement spatial transformer networks.
A test code
import tensorflow as tf
import tensorflow_addons as tfa
im = tf.zeros([100, 100, 3])
mat = tf.constant([1, 0, 0, 0, 1, 0, 0, 0], dtype=tf.float32)
with tf.GradientTape() as tape:
tape.watch(im)
tape.watch(mat)
out = tfa.image.transform(im, mat)
loss = tf.reduce_mean(out)
grads = tape.gradient(loss, [im, mat])
print(grads)