![](/img/trans.png)
[英]InvalidArgumentError (see above for traceback): indices[1] = 10 is not in [0, 10)
[英]Tensorflow InvalidArgumentError (see above for traceback): flat indices does not index into param
我正在使用tensorflow使用协作过滤算法来构建Recommendationg系统。
由于内存占用,我必须使用稀疏矩阵。
#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)
使用我的feed_dict, ratings.dense_shape == (45776, 60184)
pred = tf.matmul(items_features, user_preferences, name='Prediction') + global_mean
我已经硬编码了pred.shape == (45776, 60184)
那么,当我尝试收集预测以以后计算成本时会怎样
pred_values = tf.gather_nd(pred, ratings.indices)
我得到错误
InvalidArgumentError(请参见上面的回溯):平面索引[2714679,:] = [48375,2227]不索引到参数中(形状:[45776,60184])。
?
原来我确实弄乱了尺寸。 我输入索引的顺序与我想象的相反,即形状(60184,45776)
而不是所需的(45776,60184)
。
出现错误,提示我的flat indices[2714679, :]
正在索引[48375, 2227]
-未显示的形状-没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.