import numpy as np
test1=np.array([[[0,1],[0,1],[0,2],[0,3],[0,2]],[[0,1],[0,1],[0,2],[0,3],[0,2]]])
print(f'test1.shape: {test1.shape}')
mask = np.array([[True,False,False,True,True],[True,False,True,True,False]])
test2=test1[0,mask[0],:][np.newaxis]
print(f'test2.shape: {test2.shape}')
print(f'test2: {test2}')
for i in range(test1.shape[0])[1:]:
#test2=np.hstack((test2, test1[i,mask[i],:]))
test2=np.vstack((test2, test1[i,mask[i],:][np.newaxis]))
print(f'test2.shape: {test2.shape}')
print(f'test2: {test2}')
(tf2.3.0)
只会循环
第一维度是batchsize-->一个batch训练几个数据~(全局平均-->batch平均)
不能直接 test2=test1[mask,:] 是因为直接按照前两维坐标去找shape[-1]的那个数据,然后结果就是shape[-1]组成的list(还是np.array的搞不清楚)