Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
How to do minibatches for RNNs in pytorch | |
Assume we feed characters to the model and predict the language of the words. | |
""" | |
def prepare_batch(x, y): | |
# determine the maximum word length per batch and zero pad the tensors | |
n_max = max([a.shape[0] for a in x]) |