Reader small image

You're reading from  Deep Learning with MXNet Cookbook

Product typeBook
Published inDec 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781800569607
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Andrés P. Torres
Andrés P. Torres
author image
Andrés P. Torres

Andrés P. Torres, is the Head of Perception at Oxa, a global leader in industrial autonomous vehicles, leading the design and development of State-Of The-Art algorithms for autonomous driving. Before, Andrés had a stint as an advisor and Head of AI at an early-stage content generation startup, Maekersuite, where he developed several AI-based algorithms for mobile phones and the web. Prior to this, Andrés was a Software Development Manager at Amazon Prime Air, developing software to optimize operations for autonomous drones.
Read more about Andrés P. Torres

Right arrow

Preface

MXNet is an open-source deep learning framework that allows you to train and deploy neural network models and implement state-of-the-art (SOTA) architectures in Computer Vision, Natural Language Processing, and more. With this cookbook, you will be able to construct fast, scalable deep learning solutions using Apache MXNet.

This book will start by showing you the different versions of MXNet and what version to choose before installing your library. You will learn to start using MXNet/Gluon libraries to solve classification and regression problems and get an idea on the inner workings of these libraries. This book will also show how to use MXNet to analyze toy datasets in the areas of numerical regression, data classification, image classification, and text classification. You’ll also learn to build and train deep-learning neural network architectures from scratch, before moving on to complex concepts like transfer learning. You’ll learn to construct and deploy neural network architectures including CNN, RNN, Transformers, and integrate these models into your applications. You will also learn to analyze the performance of these models, and fine-tune them for increased accuracy, scalability, and speed.

By the end of the book, you will be able to utilize the MXNet and Gluon libraries to create and train deep learning networks using GPUs and learn how to deploy them efficiently in different environments.

Who is this book for?

This book is ideal for Data Scientists, Machine Learning Engineers, and Developers who want to work with Apache MXNet for building fast, scalable deep learning solutions. The reader is expected to have a good understanding of Python programming and a working environment with Python 3.7+. A good theoretical understanding of mathematics for deep learning will be beneficial.

What this book covers

Chapter 1, Up and Running with MXNet, To start working with MXNet, we need to install the library. There are several different versions of MXNet available to be installed, and in this chapter, we will cover how to help you choose the right version. The most important parameter will be the available hardware we have. In order to optimize performance, it is always best to maximize the use of our available Hardware. We will compare the usage of a well-known linear algebra library, NumPy, and how MXNet provides similar operations. We will then compare the performance of the different MXNet versions vs. Numpy.

Chapter 2, Working with MXNet and Visualizing Datasets: Gluon and DataLoader, In this chapter, we will start using MXNet to analyze some toy datasets in the domains of numerical regression, data classification, image classification and text classification. To manage those tasks efficiently, we will see new MXNet libraries and functions such as Gluon and DataLoader.

Chapter 3, Solving Regression Problems, In this chapter, we will learn how to use MXNet and Gluon libraries to apply supervised learning to solve regression problems. We will explore and understand a house prices dataset and will learn how to predict the price of a house. To achieve this objective, we will train neural networks and study the effect of the different hyper-parameters.

Chapter 4, Solving Classification Problems, In this chapter, we will learn how to use MXNet and Gluon libraries to apply supervised learning to solve classification problems. We will explore and understand a flowers dataset and will learn how to predict the type of a flower given some metrics. To achieve this objective, we will train neural networks and study the effect of the different hyper-parameters.

Chapter 5, Analyzing Images with Computer Vision, In this chapter, the reader will understand the different architectures and operations available in MXNet/GluonCV to work with images. Furthermore, the readers will get introduced to classic Computer Vision problems: Image Classification, Object Detection and Semantic Segmentation. They will then learn how to leverage MXNetGluonCV Model Zoo to use pre-existing models to solve these problems.

Chapter 6, Understanding Text with Natural Language Processing, In this chapter, the reader will understand the different architectures and operations available in MXNet/GluonNLP to work with text datasets. Furthermore, the readers will get introduced to classic Natural Language Processing problems: Word Embeddings, Text Classification, Sentiment Analysis and Translation. They will then learn how to leverage GluonNLP Model Zoo to use pre-existing models to solve these problems.

Chapter 7, Optimizing Models with Transfer Learning and Fine-Tuning, In this chapter, the reader will understand how to optimize pre-trained models for specific tasks using Transfer Learning and Fine-Tuning techniques. Furthermore, the readers will compare the performance of these techniques against training a model from scratch and the trade-offs involved. The reader will apply these techniques to problems such as image classifcation, image segmentation and translating text from English to German.

Chapter 8, Improving Training Performance with MXNet, In this chapter, the reader will learn how to leverage MXNet and Gluon libraries to optimize deep learning training loops. The reader will learn how MXNet and Gluon can take advantage of computational paradigms such as Lazy Evaluation and Automatic Parallelization. Furthermore, the reader will also learn to optimize Gluon DataLoaders for CPU and GPU, to apply Automatic Mixed Precision (AMP) and to train with multiple GPUs.

Chapter 9, Improving Inference Performance with MXNet, In this chapter, the reader will learn how to leverage MXNet and Gluon libraries to optimize deep learning inference. The reader will learn how MXNet and Gluon can take advantage of hybridizing Machine Learning models (combining imperative and symbolic programming). Furthermore, the reader will also learn to optimize inference time by applying Float16 data type combined with AMP, quantizing their models and profiling to find out further gains.

To get the most out of this book

The reader is expected to have a good understanding of Python programming and a working environment with Python 3.7+. A good theoretical understanding of mathematics for deep learning will be beneficial. MXNet 1.9.1 and the supplementary GluonCV and GluonNLP libraries will need to be installed as well (versions 0.10). These MXNet/Gluon requirements are described in detail in Chapter 1 and can be followed along by the reader. All code examples have been tested with Ubuntu 20.04, Python 3.10.12, MXNet 1.9.1, GluonCV 0.10 and GluonNLP 0.10. However, they should work with future releases too.

Software/hardware covered in the book

Operating system requirements

Python3.7+

Linux (Ubuntu recommended)

MXNet 1.9.1

GluonCV 0.10

GluonNLP 0.10

In order to reproduce similar results to those described in Chapter 8, the reader will need access to a machine with multiple GPUs installed.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Deep-Learning-with-MXNet-Cookbook. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “We will store the computation time in five dictionaries, one for each compute profile (timings_np, timings_mx_cpu, and timings_mx_gpu).”

A block of code is set as follows:

import mxnet
mxnet.__version__
features = mxnet.runtime.Features()
print(features)
print(features.is_enabled('CUDA'))
print(features.is_enabled('CUDNN'))
print(features.is_enabled('MKLDNN'))

Any command-line input or output is written as follows:

!python3 -m pip install gluoncv gluonnlp
!python3 -m pip install gluoncv gluonnlp

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “For this step, we will use the pyplot module from a library called Matplotlib, which will allow us to create charts easily.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com

Share Your Thoughts

Once you’ve read Deep Learning with MXNet Cookbook, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781800569607

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Deep Learning with MXNet Cookbook
Published in: Dec 2023Publisher: PacktISBN-13: 9781800569607
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Andrés P. Torres

Andrés P. Torres, is the Head of Perception at Oxa, a global leader in industrial autonomous vehicles, leading the design and development of State-Of The-Art algorithms for autonomous driving. Before, Andrés had a stint as an advisor and Head of AI at an early-stage content generation startup, Maekersuite, where he developed several AI-based algorithms for mobile phones and the web. Prior to this, Andrés was a Software Development Manager at Amazon Prime Air, developing software to optimize operations for autonomous drones.
Read more about Andrés P. Torres