Skip to content

Instantly share code, notes, and snippets.

@yjchun
yjchun / gist:78277364d3955321746d5fec3dd46824
Last active December 4, 2018 02:30
pytorch memory usage
# from https://discuss.pytorch.org/t/how-to-debug-causes-of-gpu-memory-leaks/6741/19
# collect tensors and could calculate memory size
# like following
import torch
import gc
from functools import reduce
import operator as op
@yjchun
yjchun / rnn_t_beamsearch.py
Last active September 9, 2021 04:11
rnn transducer inference beam search
import math
import numpy
import torch
import torch.nn as nn
import torch.nn.functional as F
import itertools
class BeamSearch(object):
def __init__(self, model, henc):