eifuentes / swae-pytorch Goto Github PK
View Code? Open in Web Editor NEWImplementation of the Sliced Wasserstein Autoencoder using PyTorch
License: MIT License
Implementation of the Sliced Wasserstein Autoencoder using PyTorch
License: MIT License
Hi, thanks so much for the pytorch implementation of SWAE.
By the way, do you have any results such as FID score?
Thank you for creating a PyTorch version of the novel SWAE project.
Encountered an exception during runtime in line 48 of _sliced_wasserstein_distance
encoded_projections = encoded_samples.matmul(projections.transpose(0, 1))
with device
being set to "cuda" in main()
Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for arguement #2 'mat2'.
encoded_samples
is a <Tensor, len() = 500>
with is_cuda: True
whereas
projections
is a <Tensor, len() = 50>
with is_cuda: False
System:
PyTorch 0.4.0
CUDA 9.0
Python 3.6.3 Anaconda/Intel
VS Code 1.25.1
Ubuntu Linux 18.04 x64
Regards.
After I ran python3 setup.py install, I modified the code to run again, but I found that it was still running code that was not modified before. Why? If you can answer it, I would be grateful.
Hi,
Thank you for sharing the code.
In the original implementation, 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.
I made an issue in the original implementation repository.
For this PyTorch implementation, It can be easily fixed by applying sqrt
on random radius samples from a uniform distribution in rand_cirlce2d
.
def rand_cirlce2d(batch_size):
""" This function generates 2D samples from a filled-circle distribution in a 2-dimensional space.
Args:
batch_size (int): number of batch samples
Return:
torch.Tensor: tensor of size (batch_size, 2)
"""
# r = np.random.uniform(size=(batch_size)) # before
r = np.sqrt(np.random.uniform(size=(batch_size))) # after
theta = 2 * np.pi * np.random.uniform(size=(batch_size))
x = r * np.cos(theta)
y = r * np.sin(theta)
z = np.array([x, y]).T
return torch.from_numpy(z).type(torch.FloatTensor)
Here is an related article: Generate a random point within a circle (uniformly)
Best,
Oh-Hyun
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.