Reputation: 57
Python list, e.g. a = [1, 2, 3, 4]
can be accessed by a[1]
. But I want to access values except index=1, that is, I want access a[0]
and a[3:]
. Is there a elegant way to access list (like a[~1]
) could solve this?
In fact, I want to access tensor in tensorflow. I know several indexes I don't want to access, and I need all of others. Although we could solve this in some tedious method, like redefine a variable link to other indexes, that is not what we really want.
Upvotes: 2
Views: 419
Reputation: 5555
Here:
# The index that you want to exclude
mask = tf.not_equal(tf.range(tf.shape(X)[0]), index)
masked = tf.boolean_mask(X, mask)
Upvotes: 1