0

I have a tensor “idx” that is returned as the result of the code below. The code uses three other tensors called “result”, “theta”, and “user” which are all described by the output below. I’m very new to tensorflow and I’m trying to understand what idx is, the documentation is a little unclear on what shape=(1,) would be. Is it a vector, or a matrix? Is there a way to access the elements of idx? I tried idx[1], or idx[1,] but I get out of bound errors.

Any tips are greatly appreciated.

Code:

result

Output:

<tf.Tensor 'DVBPR_1/Add_2:0' shape=(1, 100) dtype=float32>

Code:

thetau

Output:

<tf.Variable 'DVBPR/Variable:0' shape=(20, 100) dtype=float32_ref>


Code:

user

Output:

<tf.Tensor 'Placeholder_3:0' shape=(1,) dtype=int32>


Code:

idx = tf.reduce_sum(tf.matmul(result,tf.transpose(tf.gather(thetau,user))),1)

idx

Output:

<tf.Tensor 'Sum_1:0' shape=(1,) dtype=float32>
user3476463
  • 3,967
  • 22
  • 57
  • 117
  • there is already a great discussion [here](https://stackoverflow.com/questions/22053050/difference-between-numpy-array-shape-r-1-and-r) – Krishna Jul 12 '18 at 05:07

1 Answers1

0
idx = tf.reduce_sum(tf.matmul(result,tf.transpose(tf.gather(thetau,user))),1)

gives output of

<tf.Tensor 'Sum_1:0' shape=(1,) dtype=float32>

which is telling you that idx is a type of type Tensor with shape(1,), of type Shape, is telling you that you're underlying matrix is a 1-D array, 1 element long, in one row.

tjborromeo
  • 156
  • 6
  • API was at v1.9 as of this post, available at: https://www.tensorflow.org/api_docs/. You may want to utilize the python api, though I didn't check if it required python2.7 or python3. – tjborromeo Jul 12 '18 at 04:32