Creating a matrix with certain conditions

Viewed 42

I am trying to create a matrix using PyTorch of size 32x10x1. The conditions that I need to fulfill are that

torch.mean(a, dim=0) # size is 10x1 and should be almost 0
torch.mean(a, dim=1) # size is 32x1 and should be almost 0

This is a noise matrix for GANs and I am trying to sample it from Normal Distribution. I tried using torch.MultiVariateNormal() but it didnt give me matrix of that shape

Is there any other function or something in numpy or scikit to get this kind of matrix

1 Answers

Use numpy.random.normal

import numpy.random as npr

mean = 0
std_dev = 0.1
size = (32, 10, 1)

mat = npr.normal(loc=mean, scale=std_dev, size=size)

and set the mean and standard deviation as desired to keep the values close to 0.

Here you can see the effect of changing the mean and standard deviation on the graph enter image description here By Inductiveload - self-made, Mathematica, Inkscape, Public Domain, https://commons.wikimedia.org/w/index.php?curid=3817954

Related