Turn standard Gaussian noise into samples from a diagonal Gaussian with a given mean and log variance, using the reparameterization trick.
z=μ+exp(21logσ2)⊙ϵHere mean holds the means μ, log_variance holds the natural logarithm logσ2 of each coordinate's variance, and noise holds the standard Gaussian values ϵ. The factor exp(21logσ2) is the standard deviation σ, and ⊙ is elementwise multiplication. The operation is purely elementwise, and the arrays follow NumPy broadcasting rules, so a single mean of shape (D,) can be combined with a batch of noise of shape (N, D) to give N samples at once.
Return a NumPy array of dtype float64 whose shape is the broadcast shape of mean, log_variance and noise.
Input: mean = [0.0,1.0,-2.0], log_variance = [0.0,1.386294,-1.386294], noise = [1.0,-0.5,2.0]
Output: [1.0,0.0,-1.0]
Explanation: The three log variances are log 1, log 4 and log 0.25 to six decimals, so the standard deviations are 1, 2 and 0.5. The noise values 1, -0.5 and 2 then move the means 0, 1 and -2 to 1, 0 and -1.
Input: mean = [1.0,-1.0], log_variance = [-0.6931,0.6931], noise = [[0.0,0.0],[1.0,1.0],[-2.0,0.5]]
Output: [[1.0,-1.0],[1.707123,0.41418],[-0.414247,-0.29291]]
Input: mean = [[0.5,0.25]], log_variance = [[-20.0,-20.0]], noise = [[3.0,-3.0]]
Output: [[0.500136,0.249864]]
np.exp(0.5 * log_variance) turns a log variance into a standard deviation.
A (D,) array broadcasts against an (N, D) array without reshaping.
Avoid += on an input array so the inputs stay unchanged.
Accepts: array
Accepts: array
Accepts: array
Turn standard Gaussian noise into samples from a diagonal Gaussian with a given mean and log variance, using the reparameterization trick.
z=μ+exp(21logσ2)⊙ϵHere mean holds the means μ, log_variance holds the natural logarithm logσ2 of each coordinate's variance, and noise holds the standard Gaussian values ϵ. The factor exp(21logσ2) is the standard deviation σ, and ⊙ is elementwise multiplication. The operation is purely elementwise, and the arrays follow NumPy broadcasting rules, so a single mean of shape (D,) can be combined with a batch of noise of shape (N, D) to give N samples at once.
Return a NumPy array of dtype float64 whose shape is the broadcast shape of mean, log_variance and noise.
Input: mean = [0.0,1.0,-2.0], log_variance = [0.0,1.386294,-1.386294], noise = [1.0,-0.5,2.0]
Output: [1.0,0.0,-1.0]
Explanation: The three log variances are log 1, log 4 and log 0.25 to six decimals, so the standard deviations are 1, 2 and 0.5. The noise values 1, -0.5 and 2 then move the means 0, 1 and -2 to 1, 0 and -1.
Input: mean = [1.0,-1.0], log_variance = [-0.6931,0.6931], noise = [[0.0,0.0],[1.0,1.0],[-2.0,0.5]]
Output: [[1.0,-1.0],[1.707123,0.41418],[-0.414247,-0.29291]]
Input: mean = [[0.5,0.25]], log_variance = [[-20.0,-20.0]], noise = [[3.0,-3.0]]
Output: [[0.500136,0.249864]]
np.exp(0.5 * log_variance) turns a log variance into a standard deviation.
A (D,) array broadcasts against an (N, D) array without reshaping.
Avoid += on an input array so the inputs stay unchanged.
Accepts: array
Accepts: array
Accepts: array