swae icon indicating copy to clipboard operation
swae copied to clipboard

Sample points in a circle are not uniformly distributed.

Open kwonoh opened this issue 7 years ago • 0 comments

Hi,

Thank you for sharing the code.

I found that the function generateZ in MNIST_SlicedWassersteinAutoEncoder_Circle.ipynb does not generate sample points in a circle uniformly. The generated sample points are more dense at the center of a circle. This can affect the resulting latent space.

It can be easily fixed by applying sqrt on random radius samples from a uniform distribution.

def generateZ(batchsize):
    # This function generates 2D samples from a `circle' distribution in 
    # a 2-dimensional space
    # r=np.random.uniform(size=(batchsize)) # before
    r=np.sqrt(np.random.uniform(size=(batchsize))) # after
    theta=2*np.pi*np.random.uniform(size=(batchsize))
    x=r*np.cos(theta)
    y=r*np.sin(theta)
    z_=np.array([x,y]).T
    return z_

Here is an related article: Generate a random point within a circle (uniformly)

Best, Oh-Hyun

kwonoh avatar Sep 28 '18 00:09 kwonoh