bb9b23bb210fbe363687d992e769bb1b23c21107,magenta/models/nsynth/wavenet/fastgen.py,,sample_categorical,#Any#,31
Before Change
def sample_categorical(pmf):
cdf = np.cumsum(pmf)
idx = np.random.rand()
i = cdf.searchsorted(idx)
return i
def load_nsynth(batch_size=1, sample_length=64000):
After Change
def sample_categorical(pmf):
if pmf.ndim == 1:
pmf = np.expand_dims(pmf, 0)
batch_size = pmf.shape[0]
cdf = np.cumsum(pmf, axis=1)
rand_vals = np.random.rand(batch_size)
idxs = np.zeros([batch_size, 1])
for i in range(batch_size):
idxs[i] = cdf[i].searchsorted(rand_vals[i])
return idxs
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: tensorflow/magenta
Commit Name: bb9b23bb210fbe363687d992e769bb1b23c21107
Time: 2017-06-15
Author: jesse.engel@gmail.com
File Name: magenta/models/nsynth/wavenet/fastgen.py
Class Name:
Method Name: sample_categorical
Project Name: acoular/acoular
Commit Name: 97a346493ac31f120102d4cb3cf8586333d1a1ec
Time: 2010-09-16
Author: sarradj@tu-cottbus.de
File Name: beamfpy/beamfpy.py
Class Name:
Method Name: synthetic
Project Name: nilearn/nilearn
Commit Name: c90d4b0fc9de45b75ce1532309f83b1bde948cc3
Time: 2014-02-21
Author: virgile.fritsch@gmail.com
File Name: nilearn/mass_univariate/permuted_least_squares.py
Class Name:
Method Name: permuted_ols