Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
s1162276945 opened this issue Jan 31, 2018 · 3 comments

Comments

@s1162276945
Copy link

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

@s1162276945
Copy link
Author

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

@Aliang-CN
Copy link

改成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
Copy link

改成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????

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants