![](/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.