# tf.gather_nd# 抽取 给定索引值数据 组合
b = tf.gather_nd(a,[0,1])print(b.shape)
c = tf.gather_nd(a,[0,1,2])print(c.shape)
d = tf.gather_nd(a,[[0,1,2]])print(d.shape)
# 抽取 不同索引数据 组合
b = tf.gather_nd(a,[[0,1],[1,1]])print(b.shape)
c = tf.gather_nd(a,[[0,0,0],[1,1,1],[2,2,2]])print(c.shape)
d = tf.gather_nd(a,[[[0,0,0],[1,1,1],[2,2,2],[3,3,3]]])print(d.shape)
# tf.boolean_mask
a = tf.random.normal([4,28,28,3])print(a.shape)# 抽取 True所在索引的数据
b = tf.boolean_mask(a, mask=[True,True,False,False])print(b.shape)
c = tf.boolean_mask(a, mask=[True,True,False], axis=3)print(c.shape)
a = tf.ones([2,3,4])
d = tf.boolean_mask(a, mask=[[True,False,False],[False,True,True]])print(d.shape)