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

> 改成python3需要更改三个地方才能跑起来. #12

Closed
zysNLP opened this issue Oct 26, 2021 · 0 comments
Closed

> 改成python3需要更改三个地方才能跑起来. #12

zysNLP opened this issue Oct 26, 2021 · 0 comments

Comments

@zysNLP
Copy link

zysNLP commented Oct 26, 2021

改成python3需要更改三个地方才能跑起来.
1.

np.random.shuffle(sents)  # 打乱语料,以便后面划分验证集
sents = sents[0]
chars = {}  # 统计字表
def max_in_dict(d):  # 定义一个求字典中最大值的函数
    key, value = list(d.items())[0]
    for i, j in list(d.items())[1:]:
        if j > value:
            key, value = i, j
    return key, value

卡在那不动,是生成器的时候,遍历数据的时候,数据为空,所以需要sents = sents[0], 后面两处是验证的时候需要更改的.
我测试环境是Python3.6+tensorflow1.14/tensorflow2.1

其实把split('\r\n')改成split('\n')就可以了

Originally posted by @liujingqiao in #5 (comment)

@zysNLP zysNLP closed this as completed Oct 26, 2021
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

1 participant