[英]Tensorflow InvalidArgumentError (see above for traceback): flat indices does not index into param
I'm using tensorflow to build a recommendationg system using collaborative filtering algorithm. 我正在使用tensorflow使用协作过滤算法来构建Recommendationg系统。
Due to memory usage I have to use sparse matrices. 由于内存占用,我必须使用稀疏矩阵。
#Arbitrary number of items are rated by arbitrary number of users
ratings = tf.sparse_placeholder(tf.float32, shape=[None, None])
ratings = tf.sparse_reorder(ratings)
With my feed_dict, ratings.dense_shape == (45776, 60184)
使用我的feed_dict, ratings.dense_shape == (45776, 60184)
pred = tf.matmul(items_features, user_preferences, name='Prediction') + global_mean
I have hardcoded so pred.shape == (45776, 60184)
我已经硬编码了pred.shape == (45776, 60184)
So how comes when I try to collect predictions to later calculate the cost 那么,当我尝试收集预测以以后计算成本时会怎样
pred_values = tf.gather_nd(pred, ratings.indices)
I get error 我得到错误
InvalidArgumentError (see above for traceback): flat indices[2714679, :] = [48375, 2227] does not index into param (shape: [45776,60184]). InvalidArgumentError(请参见上面的回溯):平面索引[2714679,:] = [48375,2227]不索引到参数中(形状:[45776,60184])。
? ?
It turns out I did mess up with dimensions. 原来我确实弄乱了尺寸。 I fed indices in the opposite order than I thought, ie, for shape (60184,45776)
instead of needed (45776,60184)
. 我输入索引的顺序与我想象的相反,即形状(60184,45776)
而不是所需的(45776,60184)
。
Having an error telling that my flat indices[2714679, :]
are indexing [48375, 2227]
- shape that does not appear - didn't help. 出现错误,提示我的flat indices[2714679, :]
正在索引[48375, 2227]
-未显示的形状-没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.