chenchongthu / DeepCoNN

This is our implementation of DeepCoNN
151 stars 65 forks source link

AttributeError: Can't pickle local object 'numerize.<locals>.<lambda>' #3

Open s1162276945 opened 6 years ago

s1162276945 commented 6 years ago

DeepCoNN/pro_data/loaddata.py 运行不了,报的是pickle 错误 print(item_reviews[11]) pickle.dump(user_reviews, open(os.path.join(TPS_DIR, 'user_review'), 'wb'))

s1162276945 commented 6 years ago

in python3, you currently have to import dill as pickle https://stackoverflow.com/questions/25348532/can-python-pickle-lambda-functions

Aliang-CN commented 4 years ago

改成dill读取也是不行的,修改如下,把lambda换成apply就行了 def numerize(tp):

uid = map(lambda x: user2id[x], tp['user_id'])

# sid = map(lambda x: item2id[x], tp['item_id'])
tp['user_id'] = tp['user_id'].apply(lambda x:user2id[x])
tp['item_id'] = tp['item_id'].apply(lambda x:item2id[x])
return tp
ITEliteCCY commented 4 years ago

改成dill读取也是不行的,修改如下,把lambda换成apply就行了 def numerize(tp):

uid = map(lambda x: user2id[x], tp['user_id'])

sid = map(lambda x: item2id[x], tp['item_id'])

tp['user_id'] = tp['user_id'].apply(lambda x:user2id[x]) tp['item_id'] = tp['item_id'].apply(lambda x:item2id[x]) return tp

code: t.apply(lambda p: str(p.name)) for t in train_folders[0].glob("*.png") error: AttributeError: 'WindowsPath' object has no attribute 'apply' how to solve the error????