0
votes

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>
1
there is already a great discussion here - Bal Krishna Jha

1 Answers

0
votes
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.