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.argmax Should Not Permit Backprop Through It #2177

Closed
NickShahML opened this issue Apr 30, 2016 · 1 comment
Closed

tf.argmax Should Not Permit Backprop Through It #2177

NickShahML opened this issue Apr 30, 2016 · 1 comment

Comments

@NickShahML
Copy link

Hey Tensorflow,

Lately, I have been using the argmax function but I have always placed a tf.stop_gradient before using it. However, when I remove the stop_gradient, tensorflow still works fine.

Maybe I'm misunderstanding something, but argmax is not a differentiable function. How is backprop still working when you remove it? Shouldn't an error be thrown when you pass argmax without any stop_gradient?

If it is possible to differentiate argmax, then I would greatly appreciate any resource showing how this is done. Thanks TF!

@NickShahML NickShahML changed the title tf.argmax should not Permit Backprop Through It tf.argmax Should Not Permit Backprop Through IT Apr 30, 2016
@NickShahML NickShahML changed the title tf.argmax Should Not Permit Backprop Through IT tf.argmax Should Not Permit Backprop Through It Apr 30, 2016
@yaroslavvb
Copy link
Contributor

Gradient is defined almost everywhere, so it could be defined in practice. It's not very useful though, so it's not registered for this op in TensorFlow.

x = tf.Variable([1., 1])
z = tf.argmax(x, 0)
sess = create_session()
xgrad = tf.gradients(z, x)
sess.run(tf.initialize_all_variables())
sess.run(xgrad)

LookupError: No gradient defined for operation 'ArgMax' (op type: ArgMax)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants