jucor/torch-distributions — pull request #23 by jucor (2014-01-30 21:44:20+00:00)
Title: Missing support for cat.rnd(p) with p a matrix whose rows define category probabilities

This would be a convenience method. If p is a NxM tensor, the result would be to generate N independent samples from N categorical distributions. The i-th sample would be obtained with probabilities given by the vector p[i].

Use case: sampling from the output of a neural network having a softmax output layer. N in this case corresponds to the size of the minibatch. When used in conjunction with torch.nn, this would allow for the following:

% x: torch.Tensor
sampledOutputs = distributions.cat(module:forward(x))