TensorFlow 的索引与切片操作 文章目录 TensorFlow 的索引与切片操作 一.基本切片操作 二. TensorFlow 自带的切片方法 2.1-tf.gather 2.2-tf.gather_nd 2.3-tf.boolean_mask 一.基本切片操作 首先,TensorFlow有最基本的切片操作,这个和许多高级语言的方式一样。同时,TensorFlow与Numpy语法也兼容。可以直接照搬Numpy的切片和索引操作。 除了这些,TensorFlow也有其特有的切片方法。 二. TensorFlow 自带的切片方法 2.1-tf.gather tf.gather( params, indices, validate_indices=None, name=None, axis=0 )