火炬补充索引操作
我有一个张量说t = [1、2、3、4、5、6、7、8、9]
和我想删除的索引列表,例如d = [0 ,2,5]
。
做t [d]
给我带有我要删除的元素的子镜。
我如何使用d
来获取所有元素 d
索引的子镜头。必须有t [〜d]
之类的东西,对吗?
像Numpy的 numpy.delete.delete.delete 。
I have a tensor say t = [1, 2, 3, 4, 5, 6, 7, 8, 9]
and a list of indices I want to remove like d = [0, 2, 5]
.
Doing t[d]
gives me the subtensor with the elements I want to remove.
How can I used d
to get the subtensor with all the elements except the ones indexed in d
. There must be something like t[~d]
, right?
Something like numpy's numpy.delete.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
delete
使用逻辑,例如mask
是我们要保留的所有索引的bool。这是简单的1D版本。delete
uses logic likemask
is a bool that is true for all indices we want to keep. This is the simple 1d version.