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

trouble using tf.where #380

Open
qvdgeer opened this issue Apr 20, 2018 · 3 comments
Open

trouble using tf.where #380

qvdgeer opened this issue Apr 20, 2018 · 3 comments

Comments

@qvdgeer
Copy link

qvdgeer commented Apr 20, 2018

Hi, trying to get a toy example with tf.where working
using TensorFlow

sess = TensorFlow.Session()

A = TensorFlow.Variable([-1,-1,-1,-1,0,-1])
B = TensorFlow.Variable([0,0,0,0,1,0])

mask = TensorFlow.equal(A,0)

C= TensorFlow.where(mask,B,A)

run(sess, TensorFlow.global_variables_initializer())
run(sess,[A,B,mask,C])

but I get this

MethodError: no method matching where(::TensorFlow.Tensor{Bool}, ::TensorFlow.Variables.Variable{Float64}, ::TensorFlow.Variables.Variable{Float64})
Closest candidates are:
where(::Any; name) at /Users/quentinvandegeer/.julia/v0.6/TensorFlow/src/ops/imported_ops.jl:3326

Stacktrace:
[1] include_string(::String, ::String) at ./loading.jl:515

Strangely if you give tf.where one boolean tensor it returns a single value

@oxinabox
Copy link
Collaborator

use select(mask, B, A).

We should probably add this as an second overload to where since this keep catches people out.

I think it comes down to our where does thee find operation to return the nonzero indices. (I feel like it used to do this when given 1 arg in python too, but cur docs say no.)

@qvdgeer
Copy link
Author

qvdgeer commented Apr 21, 2018

Many thanks, I will give this a try.

@qvdgeer qvdgeer closed this as completed Apr 21, 2018
@oxinabox oxinabox reopened this Apr 23, 2018
@oxinabox
Copy link
Collaborator

select is what the operation is called in the libtensorflow.

Python tensorflow does basically have a conditional,
that results in where something hitting the libtensorflow where and other times it hitting the libtensorflor select.
And python does not expose select directly

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