tf.keras.ops.slice
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 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.
[null,null,["Last updated 2024-06-07 UTC."],[],[]]