Parent

Convolutional Generative Adversarial Network

Latent space 🡒 Image

A
B
A
B

Train in the web browser (slow)

Example training (video)

Network C++

Headers

// Linear                                                                      
Node* Linear(Node* input, std::vector<size_t> output_sizes);                   
Node* Convolution2D(Node* input,                                               
                    const std::vector<size_t> filter_size,                     
                    size_t num_features,                                       
                    size_t stride = 1);                                        
Node* Deconvolution2D(Node* input,                                             
                      std::vector<size_t> filter_size,                         
                      size_t num_filters,                                      
                      size_t stride);                                          
                                                                               
// Activations.                                                                
Node* LeakyRelu(Node* input);                                                  
Node* Sigmoid(Node* input);                                                    

Network

auto generator = [](Node* X) {                                                 
  X = a.Linear(X, {4, 4, 16});                                                 
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Deconvolution2D(X, {5, 5}, 8, 2);                                      
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Deconvolution2D(X, {5, 5}, 8, 2);                                      
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Deconvolution2D(X, {5, 5}, 1, 1);                                      
  X = a.Sigmoid(X);                                                            
  return X;                                                                    
};                                                                             
                                                                               
auto discriminator = [](Node* X) {                                             
  X = a.Convolution2D(X, {5, 5}, 8, 1);                                        
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Convolution2D(X, {5, 5}, 8, 2);                                        
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Convolution2D(X, {5, 5}, 16, 2);                                       
  X = a.LeakyRelu(X);                                                          
                                                                               
  X = a.Linear(X, {1, 1, 1});                                                  
  return X;                                                                    
};