TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

Building Your First Network in PyTorch

A summary to kickstart your deep learning career.

Tim Cheng
TDS Archive
Published in
6 min readNov 14, 2021

--

Photo by Max Duzij on Unsplash

Starting a deep learning project sounds scary and difficult? I have read through articles, took lessons, and watched videos about neural networks, but how do I begin programming one? We have all been through that stage, and this is why I am creating this article to tell you everything (or at least most of the things I know) to begin your PyTorch model training project.

The guide is presented in a bottom-up way. I will first describe individual components that are important to training a deep network, then provide examples on how to combine all the components together for training and testing.

Side Note:

The article serves as a bridging medium for converting the theoretical knowledge in ML directly into codes. Prior ML knowledge is assumed.

My projects are mainly in the domain of computer vision, and so what I found to be the most useful functions in PyTorch are also biased towards applications regarding images.

Table of Contents

· Table of Contents
· Import
· Network Components
Fully-Connected Layers
The Convolution Family
Recurrent Networks
Activation functions
· Loss Functions
· Optimisers
· Setting up GPU
· Combining Everything
Import PyTorch
Create Network
Create Dataset and Dataloader
Initialise Networks, Optimisers, and Schedulers
Training, Evaluating, and Saving
· Pretrained Models
· Other Fun PyTorch Functions
· End Note

Import

There are a lot of libraries associated with PyTorch, here I listed out the essential libraries to perform everything underneath:

import torch
import torch.nn as nn
import torch.optim as optim
import torch.utils.data
from…

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Tim Cheng
Tim Cheng

Written by Tim Cheng

Oxford CS | Top Writer in AI | Posting on Deep Learning and Vision

No responses yet

Write a response