gaussian

Numpy array with different standard deviation per row

风格不统一 提交于 2021-01-27 05:50:48
问题 I'd like to get an NxM matrix where numbers in each row are random samples generated from different normal distributions(same mean but different standard deviations). The following code works: import numpy as np mean = 0.0 # same mean stds = [1.0, 2.0, 3.0] # different stds matrix = np.random.random((3,10)) for i,std in enumerate(stds): matrix[i] = np.random.normal(mean, std, matrix.shape[1]) However, this code is not quite efficient as there is a for loop involved. Is there a faster way to

GaussianDropout vs. Dropout vs. GaussianNoise in Keras

旧街凉风 提交于 2021-01-20 09:33:32
问题 Can anyone explain the difference between the different dropout styles? From the documentation, I assumed that instead of dropping some units to zero (dropout), GaussianDropout multiplies those units by some distribution. However, when testing in practice, all units are touched. The result looks more like the classic GaussianNoise. tf.random.set_seed(0) layer = tf.keras.layers.GaussianDropout(.05, input_shape=(2,)) data = np.arange(10).reshape(5, 2).astype(np.float32) print(data) outputs =

creating a multivariate skew normal distribution python

百般思念 提交于 2021-01-05 11:36:56
问题 How can I create a multivariate skew normal function, where then by inputting x and y points we can create a surface diagram in 3d (x,y and z coordinates) 回答1: I wrote a blog post about this, but here is complete working code: from matplotlib import cm import matplotlib.pyplot as plt import numpy as np from scipy.stats import (multivariate_normal as mvn, norm) class multivariate_skewnorm: def __init__(self, a, cov=None): self.dim = len(a) self.a = np.asarray(a) self.mean = np.zeros(self.dim)