tensorflow / fold

Deep learning with dynamic computation graphs in TensorFlow
Apache License 2.0
1.83k stars 266 forks source link

td.Block.__rrshift__(lhs) v. td.Block.__rshift__(rhs) #35

Closed ch3njust1n closed 7 years ago

ch3njust1n commented 7 years ago

What's the difference between td.Block.__rrshift__(lhs) and td.Block.__rshift__(rhs). According to the documentation, they're the same thing. Blocks API

moshelooks commented 7 years ago

They are the same thing. In Python if you say 'a >> b' then you get a.rshift(b) if a has a right shift operator, or b.rrshift(a) as a fallback. We support the fallback so that e.g.

tensor >> foo

will do the right thing when 'tensor' is a tensor and foo is a block; this is equivalent to

td.ConvertToTensor(tensor) >> foo

(see convert_to_block https://github.com/tensorflow/fold/blob/master/tensorflow_fold/g3doc/py/td.md#td.convert_to_block for details on the conversion). This is a reasonable conversion because >> is one of the few operators that tf Tensor never overloads.

On Mon, Mar 13, 2017 at 6:02 PM, Justin Chen notifications@github.com wrote:

What's the difference between td.Block.rrshift(lhs) and td.Block.rshift(rhs). According to the documentation, they're the same thing. Blocks API https://github.com/tensorflow/fold/blob/master/tensorflow_fold/g3doc/py/td.md#tdblock__rrshift__lhs

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tensorflow/fold/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsbjiK0xPQvyzTDUXhw-jyOc4mIEAglks5rlecigaJpZM4McANr .

ch3njust1n commented 7 years ago

Ok thanks for the clarification