Skip to content

Instantly share code, notes, and snippets.

{{ define "slack.default.title" }}
[ {{ .Status | toUpper }} ]
{{ end }}
{{ define "slack.default.message" }}
{{ range . }}
{{ if gt (len .Annotations.summary) 0 }}Alert Summary: {{ .Annotations.summary }} {{ end }}
{{ if gt (len .Annotations.runbook_url) 0 }}Alert Runbook: {{ .Annotations.runbook_url }} {{ end }}
Labels:
@ritchie46
ritchie46 / rnn_minibatch.py
Created June 20, 2018 09:28
minibatches in pytorch
"""
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])