MCPcopy Index your code
hub / github.com/pytorch/tutorials / batch2TrainData

Function batch2TrainData

beginner_source/chatbot_tutorial.py:529–537  ·  view source on GitHub ↗
(voc, pair_batch)

Source from the content-addressed store, hash-verified

527
528# Returns all items for a given batch of pairs
529def batch2TrainData(voc, pair_batch):
530 pair_batch.sort(key=lambda x: len(x[0].split(" ")), reverse=True)
531 input_batch, output_batch = [], []
532 for pair in pair_batch:
533 input_batch.append(pair[0])
534 output_batch.append(pair[1])
535 inp, lengths = inputVar(input_batch, voc)
536 output, mask, max_target_len = outputVar(output_batch, voc)
537 return inp, lengths, output, mask, max_target_len
538
539
540# Example for validation

Callers 2

trainItersFunction · 0.85

Calls 2

inputVarFunction · 0.85
outputVarFunction · 0.85

Tested by

no test coverage detected