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

源代码细节 #4

Closed
ICanFlyGFC opened this issue Nov 11, 2021 · 2 comments
Closed

源代码细节 #4

ICanFlyGFC opened this issue Nov 11, 2021 · 2 comments

Comments

@ICanFlyGFC
Copy link

ICanFlyGFC commented Nov 11, 2021

作者您好,我在阅读您的代码时不知道num_stack的作用是什么。为什么式子里面有的数字没有被替换成N*呢?
希望能解答下,感谢:)

` for pair in pairs_trained:
num_stack = []
for word in pair[1]:
temp_num = []
flag_not = True
if word not in output_lang.index2word:
flag_not = False
for i, j in enumerate(pair[2]):
if j == word:
temp_num.append(i)

        if not flag_not and len(temp_num) != 0:
            num_stack.append(temp_num)
        if not flag_not and len(temp_num) == 0:
            num_stack.append([_ for _ in range(len(pair[2]))])

    num_stack.reverse()
    input_cell = indexes_from_sentence(input_lang, pair[0])
    output_cell = indexes_from_sentence(output_lang, pair[1], tree)`
@ShichaoSun
Copy link
Owner

为什么式子里面有的数字没有被替换成N*呢?
因为有一些数字,需要直接生成,而不是从问题中获得,比如0, 1, pi,这些字符有特殊含义,是需要生成的。

num_stack 被用在

def generate_tree_input(target, decoder_output, nums_stack_batch, num_start, unk):

目的是生成某一个数字,比如6, 但6在题目中出现了两次,要选择likelihood更大的那一个作为当前的输入。

@ICanFlyGFC
Copy link
Author

感谢回答 :) ,帮了大忙,目前还在扣源码中~~

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

2 participants