Ask Your Question
2

When using tf.gather in the inputs of Tape.gradient, why does it result in None?

asked 2023-06-20 12:45:02 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-20 13:12:02 +0000

pufferfish gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-06-20 12:45:02 +0000

Seen: 14 times

Last updated: Jun 20 '23