Extracts a strided slice of a tensor (generalized python array indexing). **Instead of calling this op directly most users will want to use the NumPy-style slicing syntax (e.g. `tensor[..., 3:4:-1, tf.newaxis, 3]`), which is supported via `tf.Tensor.__getitem__` and `tf.Variable.__getitem__`.
(input_,
begin,
end,
strides=None,
begin_mask=0,
end_mask=0,
ellipsis_mask=0,
new_axis_mask=0,
shrink_axis_mask=0,
var=None,
name=None)
| 858 | # pylint: disable=invalid-name |
| 859 | @tf_export("strided_slice") |
| 860 | def strided_slice(input_, |
| 861 | begin, |
| 862 | end, |
| 863 | strides=None, |
| 864 | begin_mask=0, |
| 865 | end_mask=0, |
| 866 | ellipsis_mask=0, |
| 867 | new_axis_mask=0, |
| 868 | shrink_axis_mask=0, |
| 869 | var=None, |
| 870 | name=None): |
| 871 | """Extracts a strided slice of a tensor (generalized python array indexing). |
| 872 | |
| 873 | **Instead of calling this op directly most users will want to use the |
| 874 | NumPy-style slicing syntax (e.g. `tensor[..., 3:4:-1, tf.newaxis, 3]`), which |
| 875 | is supported via `tf.Tensor.__getitem__` and `tf.Variable.__getitem__`.** |
| 876 | The interface of this op is a low-level encoding of the slicing syntax. |
| 877 | |
| 878 | Roughly speaking, this op extracts a slice of size `(end-begin)/stride` |
| 879 | from the given `input_` tensor. Starting at the location specified by `begin` |
| 880 | the slice continues by adding `stride` to the index until all dimensions are |
| 881 | not less than `end`. |
| 882 | Note that a stride can be negative, which causes a reverse slice. |
| 883 | |
| 884 | Given a Python slice `input[spec0, spec1, ..., specn]`, |
| 885 | this function will be called as follows. |
| 886 | |
| 887 | `begin`, `end`, and `strides` will be vectors of length n. |
| 888 | n in general is not equal to the rank of the `input_` tensor. |
| 889 | |
| 890 | In each mask field (`begin_mask`, `end_mask`, `ellipsis_mask`, |
| 891 | `new_axis_mask`, `shrink_axis_mask`) the ith bit will correspond to |
| 892 | the ith spec. |
| 893 | |
| 894 | If the ith bit of `begin_mask` is set, `begin[i]` is ignored and |
| 895 | the fullest possible range in that dimension is used instead. |
| 896 | `end_mask` works analogously, except with the end range. |
| 897 | |
| 898 | `foo[5:,:,:3]` on a 7x8x9 tensor is equivalent to `foo[5:7,0:8,0:3]`. |
| 899 | `foo[::-1]` reverses a tensor with shape 8. |
| 900 | |
| 901 | If the ith bit of `ellipsis_mask` is set, as many unspecified dimensions |
| 902 | as needed will be inserted between other dimensions. Only one |
| 903 | non-zero bit is allowed in `ellipsis_mask`. |
| 904 | |
| 905 | For example `foo[3:5,...,4:5]` on a shape 10x3x3x10 tensor is |
| 906 | equivalent to `foo[3:5,:,:,4:5]` and |
| 907 | `foo[3:5,...]` is equivalent to `foo[3:5,:,:,:]`. |
| 908 | |
| 909 | If the ith bit of `new_axis_mask` is set, then `begin`, |
| 910 | `end`, and `stride` are ignored and a new length 1 dimension is |
| 911 | added at this point in the output tensor. |
| 912 | |
| 913 | For example, |
| 914 | `foo[:4, tf.newaxis, :2]` would produce a shape `(4, 1, 2)` tensor. |
| 915 | |
| 916 | If the ith bit of `shrink_axis_mask` is set, it implies that the ith |
| 917 | specification shrinks the dimensionality by 1, taking on the value at index |
no test coverage detected