Return a slice of an input tensor.
tf.keras.ops.slice(
inputs, start_indices, shape
)
At a high level, this operation is an explicit replacement for array slicing
e.g. inputs[start_indices: start_indices + shape]
.
Unlike slicing via brackets, this operation will accept tensor start
indices on all backends, which is useful when indices dynamically computed
via other tensor operations.
inputs = np.zeros((5, 5))
start_indices = np.array([3, 3])
shape = np.array([2, 2])
inputs = keras.ops.slice(inputs, start_indices, updates)
Args |
inputs
|
A tensor, the tensor to be updated.
|
start_indices
|
A list/tuple of shape (inputs.ndim,) , specifying
the starting indices for updating.
|
shape
|
The full shape of the returned slice.
|
Returns |
A tensor, has the same shape and dtype as inputs .
|