69d978ed497856d05730c05564597e604713f5c4,beginner_source/chatbot_tutorial.py,,evaluate,#Any#Any#Any#Any#Any#Any#,1266

Before Change


    encoder_outputs, encoder_hidden = encoder(input_batch, lengths)

    // Prepare encoder"s final hidden layer to be first hidden input to the decoder
    decoder_hidden = encoder_hidden[:decoder.n_layers]

    // Decode sentence
    if beam_size == 1:
        return decode(decoder, decoder_hidden, encoder_outputs, voc)
    else:
        return beam_decode(decoder, decoder_hidden, encoder_outputs, voc, beam_size)

After Change


    input_batch = torch.LongTensor(indexes_batch).transpose(0, 1)
    // Use appropriate device
    input_batch = input_batch.to(device)
    lengths = lengths.to(device)
    // Decode sentence with searcher
    tokens, scores = searcher(input_batch, lengths, max_length)
    // indexes -> words
    decoded_words = [voc.index2word[token.item()] for token in tokens]
    return decoded_words


def evaluateInput(encoder, decoder, searcher, voc):
    input_sentence = ""
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: pytorch/tutorials
Commit Name: 69d978ed497856d05730c05564597e604713f5c4
Time: 2018-09-16
Author: minkawhich@fb.com
File Name: beginner_source/chatbot_tutorial.py
Class Name:
Method Name: evaluate


Project Name: dmlc/dgl
Commit Name: cf8a3fb30547d6e980ecd8182f64a51df8e55c62
Time: 2021-02-10
Author: expye@outlook.com
File Name: python/dgl/backend/pytorch/tensor.py
Class Name:
Method Name: pack_padded_tensor


Project Name: pytorch/tutorials
Commit Name: a61996ae5406ddfee4ac65ab647ebe858fc16260
Time: 2018-09-17
Author: matthewinkawhich@gmail.com
File Name: beginner_source/chatbot_tutorial.py
Class Name:
Method Name: evaluate