Book Image

Hands-On One-shot Learning with Python

By : Shruti Jadon, Ankush Garg
Book Image

Hands-On One-shot Learning with Python

By: Shruti Jadon, Ankush Garg

Overview of this book

One-shot learning has been an active field of research for scientists trying to develop a cognitive machine that mimics human learning. With this book, you'll explore key approaches to one-shot learning, such as metrics-based, model-based, and optimization-based techniques, all with the help of practical examples. Hands-On One-shot Learning with Python will guide you through the exploration and design of deep learning models that can obtain information about an object from one or just a few training samples. The book begins with an overview of deep learning and one-shot learning and then introduces you to the different methods you can use to achieve it, such as deep learning architectures and probabilistic models. Once you've got to grips with the core principles, you'll explore real-world examples and implementations of one-shot learning using PyTorch 1.x on datasets such as Omniglot and MiniImageNet. Finally, you'll explore generative modeling-based methods and discover the key considerations for building systems that exhibit human-level intelligence. By the end of this book, you'll be well-versed with the different one- and few-shot learning methods and be able to use them to build your own deep learning models.
Table of Contents (11 chapters)
1
Section 1: One-shot Learning Introduction
3
Section 2: Deep Learning Architectures
7
Section 3: Other Methods and Conclusion

To get the most out of this book

Knowledge of basic machine learning and deep learning concepts and the underlying math, as well as some exposure to Python programming, will be required for this book.

Software/Hardware covered in this book

OS requirements

Software: Jupyter Notebook, Anaconda

Language and Libraries: Python 3.X and above, PyTorch 1.4, Scikit-learn.

Any OS (Linux environment is preferable).

Hardware: None. But if you wish to increase the speed of training. You can use the same codes with minor modifications on GPU Hardware.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link 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 your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-One-shot-Learning-with-Python. In case there's an update to the code, it will be updated on the existing 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!

Download the color images

Conventions used

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

CodeInText: 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: "Import the iris dataset."

A block of code is set as follows:

# import small dataset
iris = datasets.load_iris()
X = iris.data
y = iris.target

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[2 1 2 1 2 0 1 0 0 0 2 1 1 0 0 0 2 2 1 2 1 0 0 1 2 0 0 2 0 0]

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

pip install -r requirements.txt

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "We can use a new loss function known as triplet loss, which helps the architecture to get better results."

Warnings or important notes appear like this.
Tips and tricks appear like this.