The reason why using tf.gather
in the inputs of tape.gradient
results in None
is because tf.gather
returns a tensor with the same shape as the indices tensor, and gradients for indices will not exist. In other words, tf.gather
creates a new tensor by indexing into the original tensor, and gradients will be propagated only along the values of the original tensor, not the indices. Therefore, it is necessary to compute the gradients with respect to the original tensor before applying the tf.gather
operation.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-20 12:45:02 +0000
Seen: 7 times
Last updated: Jun 20
How many inputs produced 23 files located at 'META-INF/MANIFEST.MF' path?
What does 'Invalid interp_ranges: should be Dx3' in the inputs of naturalneighbor.griddata mean?
What is the process for programming multiple user inputs in a JUnit unit test?
What should be the argument's type if it is a function?
How can I resolve the ValueError regarding incompatible shapes between (None, 20, 9) and (None, 9)?
What is the method to eliminate the diagonal plot in a pairplot?
What is the method for printing a single tensor value in TensorFlow?
What does the ValueError 'Dimension must be 2 but is 3 for {{node lambda/transpose}}' indicate?