大佬教程收集整理的这篇文章主要介绍了TensorFlow 推荐者:InvalidArgumentError:indices[0,1] = 66521 不在 [0, 12976) [Op:ResourceGather],大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用 TensorFlow Recommenders (TFRS) 构建推荐系统,但在推断训练模型时遇到问题。我已经创建了 query 和 CandIDate Towers 并将嵌入维度设置为我的数据集中唯一电影的长度。用户特征已经标准化。
class usermodel(tf.keras.Model):
def __init__(self,users_vocab,embedding_dimension = 128):
super().__init__()
self.user_R_14_11845@odel = tf.keras.Sequential([
tf.keras.layers.experimental.preprocessing.IntegerLookup(vocabulary=users_vocab),tf.keras.layers.Embedding(len(users_vocab) + 2,embedding_dimension)
])
def call(self,inputs):
# Take the input Dictionary,pass it through each input layer,# and concatenate the result.
ret = tf.concat([
self.user_R_14_11845@odel(inputs["user_iD"]),tf.reshape(inputs["user_FEATURE"],[-1,1])
],axis=1)
print(tf.shape(ret))
return ret
训练后,当我尝试通过使用 BruteForce 层创建索引来获得推荐时,d 是包含 UserID 和 User Features 的字典
index = tfrs.layers.factorized_top_k.bruteForce(model.query_model)
index.index(movIE_features.batch(16192).map(model.candIDate_model),movIEs)
_,titles = index(d,k=1)
我的模型推荐了嵌入向量空间中不存在的电影,并在我尝试获取 k>1 的推荐时抛出此错误
InvalIDArgumentError: inDices[0,1] = 66521 is not in [0,12976) [Op:resourceGather]
而当我通过 k=1 时,模型会给我一个电影 ID
recommendations for user [2471]: [MovIE ID]
我该如何解决这个问题?
谢谢! :)
EDIT 1:要补充上述问题,当我传递没有标识符 index.index(movIE_features.batch(16192).map(model.candIDate_model))
的候选特征时,我的模型正确返回索引,但这些索引值大于电影变量。
电影功能:<MaPDAtaset shapes: {MOVIE_ID: (),MOVIE_FEATURE: ()},types: {MOVIE_ID: tf.int32,MOVIE_FEATURE: tf.float64}>
电影:长度为 83349 的唯一电影 ID @H_151_5@movIEs = Training_data.MOVIE_ID.unique() 列表
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的TensorFlow 推荐者:InvalidArgumentError:indices[0,1] = 66521 不在 [0, 12976) [Op:ResourceGather]全部内容,希望文章能够帮你解决TensorFlow 推荐者:InvalidArgumentError:indices[0,1] = 66521 不在 [0, 12976) [Op:ResourceGather]所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。