Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个包含 28x28 图像行的 3d numpy 数组。一个(“A”)具有(1000、28、28)的形状,另一个(“B”)具有(100、28、28)的形状,其中一些包含在后者中。如何过滤“A”以删除 B 中也包含的所有元素?
用理解索引第一个数组:
filtered = A[[0 if i in B else 1 for i in A]]
列表生成器:
new_A = [line for line in A if line not in B]
emm,有用吗?它应该比迭代更快。