StridedSliceHelper
Stay organized with collections
Save and categorize content based on your preferences.
Helper endpoint methods for Python like indexing.
Inherited Methods
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Constructors
public
StridedSliceHelper
()
Public Methods
Return a strided slice from `input`.
The goal of this op is to produce a new tensor with a subset of the elements from the `n` dimensional `input`
tensor. The subset is chosen using a sequence of `m` sparse range specifications encoded into the arguments of this
function. Note, in some cases `m` could be equal to `n`, but this need not be the case. Each range specification
entry can be one of the following:
- An ellipsis (...) using ellipsis()
. Ellipses are used to imply zero or more dimensions of
full-dimension selection. For example, stridedSlice(foo, Indices.ellipsis()
is the identity slice.
- A new axis using newAxis()
. This is used to insert a new shape=1 dimension.
For example, `stridedSlice(foo, Indices.newAxis())
where foo
is shape (3, 4)
produces a (1, 3, 4)
tensor.
- A range begin:end:stride
using slice(Long, Long, long)
Index.slice()} or all()
. This is used to specify
how much to choose from a given dimension. stride
can be any integer but 0. begin
is an integer which
represents the index of the first value to select while end
represents the index of the last value to select
(exclusive). Begin and end can be null, in which case the index begins or ends at the beginning or end of the dimension,
respectively (reversed if stride is negative). When both are null, slice()
is the same as all()
.
The number of values selected in each dimension is end - begin
if stride > 0
and begin - end
if stride < 0
. begin
and end
can be negative where -1
is the last element, -2
is the second to last. For example, given a shape (3,)
tensor stridedSlice(foo, Indices.all())
, the
effective begin
and end
are 0
and 3
. Do not assume this is equivalent to
stridedSlice(foo, Indices.slice(0, -1))
which has an effective begin
and end
of 0
and
2
. Another example is stridedSlice(foo, Indices.slice(-2, null, -1))
which reverses the first dimension
of a tensor while dropping the last two (in the original order elements). For example foo = [1,2,3,4];
stridedSlice(foo, Indices.slice(-2, null, -1)
is [4,3]
.
- A single index using at(long)
. This is used to keep only elements that have a given index. For
example (stridedSlice(foo, Indices.at(2))
on a shape (5,6)
tensor produces a shape (6,)
tensor.
The dimension can be kept with size one using at(long, boolean)
.
These semantics generally follow NumPy's indexing semantics, which can be found here:
https://numpy.org/doc/stable/reference/arrays.indexing.html
Requirements:
`0 != strides[i] for i in [0, m)` Only one ellipsis.
Parameters
scope |
current scope |
indices |
The indices to slice. See Indices . |
Returns
- a new instance of StridedSlice
Assign `value` to the sliced l-value reference of `ref`.
The values of `value` are assigned to the positions in the variable `ref` that are selected by the slice
parameters. The slice parameters `begin`, `end`, `strides`, etc. work exactly as in `StridedSlice`.
NOTE this op currently does not support broadcasting and so `value`'s shape must be exactly the shape produced by
the slice of `ref`.
Parameters
scope |
current scope |
ref |
the tensor to assign to. |
value |
the value to assign. |
indices |
The indices to slice. See Indices . |
Returns
- a new instance of StridedSliceAssign
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.
Last updated 2021-11-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-11-29 UTC."],[],[],null,["# StridedSliceHelper\n\npublic abstract class **StridedSliceHelper** \nHelper endpoint methods for Python like indexing. \n\n##### See Also\n\n- [Indices](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices) \n\n### Public Constructors\n\n|---|-----------------------------------------------------------------------------------------------------------|\n| | [StridedSliceHelper](/jvm/api_docs/java/org/tensorflow/op/core/StridedSliceHelper#StridedSliceHelper())() |\n\n### Public Methods\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static \\\u003cT extends [TType](/jvm/api_docs/java/org/tensorflow/types/family/TType)\\\u003e [StridedSlice](/jvm/api_docs/java/org/tensorflow/op/core/StridedSlice)\\\u003cT\\\u003e | [stridedSlice](/jvm/api_docs/java/org/tensorflow/op/core/StridedSliceHelper#stridedSlice(org.tensorflow.op.Scope, org.tensorflow.Operand\u003cT\u003e, org.tensorflow.ndarray.index.Index...))([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e input, [Index...](/jvm/api_docs/java/org/tensorflow/ndarray/index) indices) Return a strided slice from \\`input\\`. |\n| static \\\u003cT extends [TType](/jvm/api_docs/java/org/tensorflow/types/family/TType)\\\u003e [StridedSliceAssign](/jvm/api_docs/java/org/tensorflow/op/core/StridedSliceAssign)\\\u003cT\\\u003e | [stridedSliceAssign](/jvm/api_docs/java/org/tensorflow/op/core/StridedSliceHelper#stridedSliceAssign(org.tensorflow.op.Scope, org.tensorflow.Operand\u003cT\u003e, org.tensorflow.Operand\u003cT\u003e, org.tensorflow.ndarray.index.Index...))([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e ref, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e value, [Index...](/jvm/api_docs/java/org/tensorflow/ndarray/index) indices) Assign \\`value\\` to the sliced l-value reference of \\`ref\\`. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**StridedSliceHelper**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public static [StridedSlice](/jvm/api_docs/java/org/tensorflow/op/core/StridedSlice)\\\u003cT\\\u003e\n**stridedSlice**\n([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e input, [Index...](/jvm/api_docs/java/org/tensorflow/ndarray/index) indices)\n\nReturn a strided slice from \\`input\\`.\n\n\nThe goal of this op is to produce a new tensor with a subset of the elements from the \\`n\\` dimensional \\`input\\`\ntensor. The subset is chosen using a sequence of \\`m\\` sparse range specifications encoded into the arguments of this\nfunction. Note, in some cases \\`m\\` could be equal to \\`n\\`, but this need not be the case. Each range specification\nentry can be one of the following:\n\n\n- An ellipsis (...) using [ellipsis()](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#ellipsis()). Ellipses are used to imply zero or more dimensions of\nfull-dimension selection. For example, `stridedSlice(foo, Indices.ellipsis()` is the identity slice.\n\n\n- A new axis using [newAxis()](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#newAxis()). This is used to insert a new shape=1 dimension.\nFor example, \\``stridedSlice(foo, Indices.newAxis())` where `foo` is shape `(3, 4)`\nproduces a `(1, 3, 4)` tensor.\n\n\n- A range `begin:end:stride` using [slice(Long, Long, long)](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#slice(java.lang.Long, java.lang.Long, long)) Index.slice()} or [all()](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#all()). This is used to specify\nhow much to choose from a given dimension. `stride` can be any integer but 0. `begin` is an integer which\nrepresents the index of the first value to select while `end` represents the index of the last value to select\n(exclusive). Begin and end can be null, in which case the index begins or ends at the beginning or end of the dimension,\nrespectively (reversed if stride is negative). When both are null, `slice()` is the same as `all()`.\nThe number of values selected in each dimension is `end - begin` if `stride \u003e 0` and `begin - end`\nif `stride \u003c 0`. `begin` and `end` can be negative where `-1` is the last element, `-2`\nis the second to last. For example, given a shape `(3,)` tensor `stridedSlice(foo, Indices.all())`, the\neffective `begin` and `end` are `0` and `3`. Do not assume this is equivalent to\n`stridedSlice(foo, Indices.slice(0, -1))` which has an effective `begin` and `end` of `0` and\n`2`. Another example is `stridedSlice(foo, Indices.slice(-2, null, -1))` which reverses the first dimension\nof a tensor while dropping the last two (in the original order elements). For example `foo = [1,2,3,4];\nstridedSlice(foo, Indices.slice(-2, null, -1)` is `[4,3]`.\n\n\n- A single index using [at(long)](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#at(long)). This is used to keep only elements that have a given index. For\nexample (`stridedSlice(foo, Indices.at(2))` on a shape `(5,6)` tensor produces a shape `(6,)` tensor.\nThe dimension can be kept with size one using [at(long, boolean)](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices#at(long, boolean)).\n\n\nThese semantics generally follow NumPy's indexing semantics, which can be found here:\n\u003chttps://numpy.org/doc/stable/reference/arrays.indexing.html\u003e\n\n\n*Requirements*:\n\\`0 != strides\\[i\\] for i in \\[0, m)\\` Only one ellipsis.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| scope | current scope |\n| indices | The indices to slice. See [Indices](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices). |\n|---------|-----------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of StridedSlice \n\n##### See Also\n\n- [Indices](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices) \n\n#### public static [StridedSliceAssign](/jvm/api_docs/java/org/tensorflow/op/core/StridedSliceAssign)\\\u003cT\\\u003e\n**stridedSliceAssign**\n([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e ref, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e value, [Index...](/jvm/api_docs/java/org/tensorflow/ndarray/index) indices)\n\nAssign \\`value\\` to the sliced l-value reference of \\`ref\\`.\n\n\nThe values of \\`value\\` are assigned to the positions in the variable \\`ref\\` that are selected by the slice\nparameters. The slice parameters \\`begin\\`, \\`end\\`, \\`strides\\`, etc. work exactly as in \\`StridedSlice\\`.\n\n\nNOTE this op currently does not support broadcasting and so \\`value\\`'s shape must be exactly the shape produced by\nthe slice of \\`ref\\`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| scope | current scope |\n| ref | the tensor to assign to. |\n| value | the value to assign. |\n| indices | The indices to slice. See [Indices](/jvm/api_docs/java/org/tensorflow/ndarray/index/Indices). |\n|---------|-----------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of StridedSliceAssign \n\n##### See Also\n\n- [ERROR(/org.tensorflow.op.Ops#stridedSlice(Operand, Index...))](/jvm/api_docs/java)"]]