Learn how to generate MNIST images with a DCGAN using PyTorch

This post will learn to create a DCGAN using PyTorch on the MNIST dataset.


A basic understanding of CNN

A sample implementation using CNN

Understanding Deep Convolutional GAN

GANs were invented by Ian Goodfellow in 2014 and first described in the paper Generative Adversarial Nets.

Generator and Discriminator

The Generator’s objective is to learn the data distribution for the training data to produce fake images that resemble the training data.

The Discriminator is…

Read to understand how Reinforcement learning is influenced by human learning.

What will you learn here?

  • What is the difference between Supervised Learning, Unsupervised Learning, and Reinforcement Learning?
  • Understand how Reinforcement Learning mimics human behavior,
  • Different components of Reinforcement Learning(RL) and how they interact
  • Applications of Reinforcement Learning(RL) in real-world scenarios.

This article is adapted and inspired from Reinforcement Learning: An Introduction by Richard S. Sutton and Andrew G. Barto.

What is the difference between Supervised Learning, Unsupervised Learning, and Reinforcement Learning?

Supervised Learning

The Supervised algorithm's objective is to find the function(f)…

Train a CNN on MNIST Dataset using Keras and PyTorch

Here you will learn to create a CNN model with similar architecture using Keras and PyTorch on MNIST dataset

Features of Keras and PyTorch.


  • Keras is a simpler, concise deep learning API written in Python that runs on TensorFlow's machine learning platform.
  • It enables fast experimentation.
  • Keras provides abstractions and building blocks for developing deep learning models.
  • The model built using Keras is more readable, and skips the neural network implementation details.
  • Keras can run on TPU or large clusters of GPUs.
  • It implicitly performs computation on GPU.
  • Supported by Google


  • PyTorch is a lower-level API focused to directly work with array expressions
  • PyTorch has…

A Novel Loss to address Class Imbalance for the Object detection

You will learn about Focal loss, how it is used in Object detection to detect hard negative examples, and then implement Focal loss for an imbalanced dataset.

Photo by Elena Taranenko on Unsplash

Focal loss is based on the premise where the training focuses on a sparse set of hard examples and prevents the vast number of easy negatives from overwhelming the object detector during training.

Types of Object Detectors

One-stage detectors are a straightforward, efficient, and elegant architecture; hence they are faster and simpler. The outputs of the object detection network are classification probabilities and box offsets at each spatial position.

Example: YOLO, SSD, RetinaNet, CenterNet, CenterNet, etc.


Deep Learning

Explore DropBlock, a new Regularization technique for Convolutional Neural Networks

DropBlock: A regularization method for convolutional networks

Here we will explore

  • A regularization technique and the different regularization techniques like L1, L2 regularization, Dropout, and Spatial Dropout.
  • What is DropBlock, and how is it different than Dropout
  • Compare the Dropout and DropBlock results on the CIFAR-10 dataset

An effective regularizer reduces the variance significantly while not overly increasing the bias, thus preventing overfitting.

We use regularization techniques like L1 and L2…

Computer Science

An optimization algorithm inspired by natural evolution such as selection, mutation, and cross-over

Learn about the Genetic Algorithm, what role it plays in artificial intelligence, how it works, and finally, look at an implementation.

As per the natural selection theory, the fittest individuals are selected to produce offsprings. The fittest parents' characteristics are then passed on to their offsprings using cross-over and mutation to ensure better chances of survival.

Genetic algorithms are randomized search algorithms that generate high-quality optimization solutions by imitating the biologically inspired natural selection process such as selection, cross-over…

A quick snapshot of new and popular activation functions used in deep neural networks

Understand popular activation functions used in deep neural networks: Sigmoid, Softmax, tanh, ReLU, Softplus, PReLU, ReLU6, ELU, SELU, Swish, and Mish

Working of a Deep Neural Network

A deep neural network performs a linear transformation(z) using the node's input value(x), weight(w), and bias(b).

Learn Generalized IoU, Distance IoU, and Complete IoU Loss used in State of the art object detection algorithms

Object detection, which includes two sub-tasks: object classification and object localization.

Object Localization relies on a bounding box regression (BBR) module to localize objects.

Bounding Box Regression

Bounding-box regression is a popular technique in object detection algorithm used to predict target objects' location using rectangular bounding boxes. It aims to refine the location of a predicted bounding box.

Bounding box regression uses overlap area between the predicted bounding box and the ground truth bounding box referred to as Intersection over Union (IOU) based losses.

Intersection over Union

IoU loss only works when the predicted bounding boxes overlap with the ground truth box. …

Distilling knowledge from a Teacher to a Student in a Deep Neural Network

Photo by Mikael Kristenson on Unsplash

In this article, you will learn.

  • An easy to understand explanation of Teacher-Student knowledge distillation neural networks
  • Benefits of Knowledge distillation
  • Implementation of Knowledge distillation on the CIFAR-10 dataset

Overview of Knowledge Distillation

Large deep neural networks or an ensemble of deep neural networks built for better accuracy are computationally expensive, resulting in longer inference times which may not be ideal for near-real-time inference required at the Edge.

The training requirements for a model are different from requirements at the inference. …

A simplistic explanation of what is Blockchain and how it works

You are in a grocery store and scan the QR code on your favorite coffee. You can view the details of where the coffee beans grew, cleaned, triaged, processed, and then roasted. what-if you can trace the supply and distribution to know the means of transport and how long it took to arrive at the store and so forth

Is there a technology that can help record information at each step and make that information available to everyone transparently?

image by author

Blockchain is an immutable, distributed, decentralized; peer-to-peer ledger replicated across multiple nodes connected in a…

Renu Khandelwal

Loves learning, sharing, and discovering myself. Passionate about Machine Learning and Deep Learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store