zoukankan      html  css  js  c++  java
  • python2 以及 tensorflow1.4 的一个 bug

    python2 没有控制循环变量的变量名的作用域,致使同名变量冲突了,这在 python3 中已经修复。

    使用了相同的变量名,导致先前的变量指向了另一个变量,导致错误。来自 DIEN 代码

    ...
    uid = self.source_dicts[0][ss[1]] if ss[1] in self.source_dicts[0] else 0 # user id-number
    mid = self.source_dicts[1][ss[2]] if ss[2] in self.source_dicts[1] else 0 # item id-number
    cat = self.source_dicts[2][ss[3]] if ss[3] in self.source_dicts[2] else 0 # category id-number 
    is the default value for any (user, item, category) not appear in training data
    can be found in generate_voc.py default_mid, default_cat
    
    tmp = []
    for mid in ss[4].split(""): # mid_str, change name fea -> mid,** bug in here! **
    id_number = self.source_dicts[1][mid] if mid in self.source_dicts[1] else 0
    tmp.append(mid_number)
    mid_list = tmp
    ...
    

    更坑之处在于,tensorflow 报错指向的地方不对,指向的是最后一个点,
    prob, loss, acc, aux_loss = model.calculate(sess, [uids, mids, cats, mid_his, cat_his, mid_mask, target, sl, noclk_mids, noclk_cats, timeinterval_history_np, timelast_history_np, timenow_history_np])
    一直说是 timenow_history_np 对应的 self.timenow_history: inps[12], 出错,实际上是 mids, cats 出错。
    这是需要把 [uids, mids, cats, mid_his, cat_his, mid_mask, target, sl, noclk_mids, noclk_cats, timeinterval_history_np, timelast_history_np, timenow_history_np] 全部打印出来,才能发现错误。

  • 相关阅读:
    Unity 移动端的复制这么写
    Unity如何管理住Android 6.0 调皮的权限
    谷歌商店Apk下载器
    Unity编辑器下重启
    git pull error
    如何简单的实现新手引导之UGUI篇
    linux系统安装python3.5
    Grafana设置mysql为数据源
    hyper -v 虚拟机(win_server)忘记密码重置
    zabbix报错:the information displayed may not be current
  • 原文地址:https://www.cnblogs.com/Gelthin2017/p/13299227.html
Copyright © 2011-2022 走看看