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

So many bug!! #1

Open
xiaodaoyoumin opened this issue Aug 1, 2018 · 2 comments
Open

So many bug!! #1

xiaodaoyoumin opened this issue Aug 1, 2018 · 2 comments

Comments

@xiaodaoyoumin
Copy link

So many bugs,please give up coding! I almost fixed the code here and there

@jihunchoi
Copy link
Owner

How about giving up ranting and starting to think what's README for? 😃

@xiaodaoyoumin
Copy link
Author

xiaodaoyoumin commented Aug 18, 2018

ok i apologize for that ,and i wanna sugest you use following code instead of yours , It will spped up at least 5 times than yours

def pack_for_rnn_seq(self,inputs, lengths):
    """
    :param inputs: [T * B * D]
    :param lengths:  [B]
    :return:
    """
    _, sorted_index = lengths.sort(descending = True)

    '''
        Reverse to decreasing order
    '''

    s_inputs = inputs.permute(1,0,2)[sorted_index].permute(1,0,2)
    lengths_list = []
    reverse_indices = [0] * lengths.size(0)
    for j, i in enumerate(sorted_index):
        lengths_list.append(lengths[i].item())
        reverse_indices[i] = j
    packed_seq = pack_padded_sequence(s_inputs,lengths_list)

    return packed_seq, reverse_indices

def unpack_from_rnn_seq(self,packed_seq, reverse_indices,max_len):
    unpacked_seq, _ = pad_packed_sequence(packed_seq,total_length=max_len)
    s_inputs_list = []
    return  unpacked_seq.permute(1,0,2)[reverse_indices].permute(1,0,2)

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