Skip to content

A collection of deep learning models (PyTorch implemtation)

License

Notifications You must be signed in to change notification settings

Tensor46/TensorMONK

Repository files navigation

TensorMONK

A collection of deep learning architectures (a PyTorch implementation).

Dependencies

  • python 3.6
  • PyTorch > 0.4.1
  • torchvision
  • visdom

How to train ImageNet?

If you have more nvidia graphic cards & cores available, adjust the batch size (BSZ), number of GPUs (gpus), & number of threads (cpus) accordingly in the ./ImageNet.sh. Next, select an available architecture and update your train & validation folder location (trainDataPath and testDataPath). Finally, run ./ImageNet.sh.

How to train CapsuleNet?

To replicate Hinton's paper on MNIST, run the following:

python Capsule.py -A capsule -B 256 -E 500 --optimizer adam --gpus 2 --cpus 6 --trainDataPath ./data --testDataPath ./data --replicate_paper

Ignore the replicate_paper argument to create a deep architecture (with few residual blocks before primary capsule). You can essentially add any block available in NeuralLayers to create a deeper architecture, which is followed by a primary capsule and secondary capsule. However, do consider two things 1. if you do reconstruction, update the reconstruction network relative to tensor_size, 2. capsule nets do require a good amount of gpu ram.

Generative Adversarial Networks GAN

Trained on CIFAR10 (pggan-cifar10.py) -- requires more training (more gpus)!

Generator at 4x4 Generator at 8x8 Generator at 16x16 Generator at 32x32

Details on core (NeuralArchitectures, NeuralEssentials, NeuralLayers)

NeuralArchitectures

NeuralEssentials

  • BaseModel -- A base class that contains networks (embedding, loss or any), meters (loss, accuracy etc), fileName, isCUDA
  • CudaModel -- Converts any model (pytorch module) to run on single gpu or multiple gpu's or cpu
  • LoadModel -- Loads pretrained models (usually, from ./models)
  • SaveModel -- Save models (usually, state_dict of anything that starts with net in BaseModel, and rest as is)
  • MakeModel -- Builds model using base class
    • MakeCNN -- Creates a CNN (netEmbedding) and loss layer (netLoss)
    • MakeAE -- Creates an auto-encoder/vae in netAE
  • FolderITTR -- PyTorch image folder iterator with few extras.
  • MNIST -- MNIST train and test dataset loader
  • CIFAR10 -- CIFAR10 train and test dataset loader
  • MakeGIF -- Given a list of images creates a gif
  • VisPlots -- Visdom wrapper to visualize weight histograms, responses, and weights (see SimpleMNIST.py)

NeuralLayers