Closed mullerhai closed 2 years ago
You can access any specific sub-element of your Tensor/NdArray by calling x.get(0, 1)
, which mimics x[0][1]
in Python.
For more fancy indexing, like x[:,0,:,2]
, you should slice your data using NdArray indexers, like this:
import static org.tensorflow.ndarray.index.Indices.*;
// given x a Tensor/NdArray of shape [4,32,32,3]
x.slice(all(), at(0), all(), at(2));
Look at NdArray's Indices
for more options on how you can slice your data.
You can access any specific sub-element of your Tensor/NdArray by calling
x.get(0, 1)
, which mimicsx[0][1]
in Python.For more fancy indexing, like
x[:,0,:,2]
, you should slice your data using NdArray indexers, like this:import static org.tensorflow.ndarray.index.Indices.*; // given x a Tensor/NdArray of shape [4,32,32,3] x.slice(all(), at(0), all(), at(2));
Look at NdArray's
Indices
for more options on how you can slice your data.
thanks it's great ,I also get another way but not the same good as you mention
HI: In tensorflow python ,If we create tensor like shape[x,y,z] three dimension ,
x = tf.random.normal([4,32,32,3]) we can get it any dimension data , like x[0] is shape (32,32,3) , x[0,::,::,::] the shape also is (32,32,3) ,also we can get other dimension ,like x[0,1] the shape is (32,,3). but in tensorflow-java ,for Operand[T ] type object ,like Operand[TFloat32] data, I dont know how to get it any dimensions data,could you show me the example to do this.
like my code
if we can do like this https://github.com/scalanlp/breeze/wiki/Linear-Algebra-Cheat-Sheet thanks