-
Notifications
You must be signed in to change notification settings - Fork 74.3k
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
Implement advanced indexing (and mixed basic/advanced) #4638
Comments
Broken off of #206 |
I mentioned this in #206, but I wanted to remind again that mixed indexing with slices/arrays has some really strange/unpredictable behavior for the order of result axes in NumPy. So it might be better to hold off on implementing that in TensorFlow until we're sure we're doing it right. |
Yes, I am aware of how the mixed advanced/basic indexing is super nonintuitive. I could break the mixed indexing into its own issue. |
idx1/idx2 in your example could be Tensor objects, right? |
does .10 currently support negative indexing? as in X[:,-1] for example? |
@yaroslavvb: yes,
@robsync: negative indices have a bug in 0.10 and work in 0.11rc0 |
@Fenugreek Tensors are immutable. But you can do this sort of thing if |
...and making sure that it gets executed: with tf.control_dependencies([foo[:3].assign(tf.zeros(3))]):
foo = tf.identity(foo) |
Great, thanks @shoyer and @danijar . I am past that problem now, but have another error with the basic indexing: print pool.get_shape(), args.get_shape(), values.get_shape()
tf.assign(pool[args], values) gives
There are no rank 2 shapes anywhere, so I am confused. The same error results even if I just do a |
I'm having a similar error to @Fenugreek:
gives an error:
This is using version 1.0.0. Thanks. |
You need to manually broadcast it i.e. |
@aselle Can you elaborate more on how to manually broadcast to make it work ? Thanks. |
StackOverflow would be a great place to ask for tips on how to use
broadcasting to make gather_nd work
…On Mon, Apr 3, 2017 at 6:56 PM, Kublai-Jing ***@***.***> wrote:
@aselle <https://github.com/aselle> Can you elaborate more on how to
manually broadcast to make it work ? Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1tCXk0PpQctDC7VHNcWE18soT37sks5rsaNkgaJpZM4KJUyn>
.
|
I posted the issue to SO: https://stackoverflow.com/questions/44793286/slicing-tensorflow-tensor-with-tensor. |
@itsmeolivia why was the issue closed? It doesn't seem like the example in the OP works. |
This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks! |
I'm asking why the ticket was closed given the op was in fact a feature. Was it implemented? Or decided to not implement. There is no info in the ticket as to why it was closed. |
@aselle probably want to keep this open right? |
I have realize the advanced indexing like the same way in numpy. Please refer to: |
Nagging Assigneee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
@aselle do you know if we have plan to implement this? If not, should we mark this as contribution welcome? |
use gather to do advanced index need much more code than numpy/pytorch, and make code hard to read. please implement this if possible. |
Nagging Assignee @aselle: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
2 similar comments
Nagging Assignee @aselle: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Nagging Assignee @aselle: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
Nagging Assignee @aselle: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
@saxenasaurabh, could you take this issue over? |
@saxenasaurabh, could you please take this issue over? |
Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the |
4 similar comments
Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the |
Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the |
Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the |
Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the |
@aselle Is there active development on this front or is using tf Eager the less painful way to go? Thanks! |
@gokul-uf - Nope, this is not being actively developed at this time. Not quite sure if using eager helps you either. You could easily convert a Tensor to numpy and use advanced indexing, but if you want to compute gradients through that indexing, that won't work. |
On a related note, it might be worth reviewing our proposal for how to
change indexing behavior in NumPy moving forward:
http://www.numpy.org/neps/nep-0021-advanced-indexing.html
…On Thu, Jul 26, 2018 at 10:44 AM Asim Shankar ***@***.***> wrote:
@gokul-uf <https://github.com/gokul-uf> - Nope, this is not being
actively developed at this time. Not quite sure if using eager helps you
either. You could easily convert a Tensor to numpy and use advanced
indexing, but if you want to compute gradients through that indexing, that
won't work.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4638 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1lwYXKQeWKJ36lMhrDG_rxT9eTAtks5uKf_jgaJpZM4KJUyn>
.
|
I have been trying to replace one of the I'm stuck on replacing tensor's values which is created as an Object and not a Variable. Similar Stack Overflow Question |
Is it doable something like this in tensorflow:
please refer to this post for reproducble example. Thanks |
This issue is way to broad and stale. However, anyone needing advanced indexing functionality should consider the excellent tf.experimental.numpy` module by @wangpengmit |
(CCing @cantonios) |
NumPy style advanced indexing is documented here http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#advanced-indexing
We currently support basic indexing http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#basic-slicing-and-indexing
using StridedSlice.
e.g.
foo = Some tensor
idx1=[1,2,3]
idx2=[3,4,5]
foo[idx1, idx2, 3]
The text was updated successfully, but these errors were encountered: