Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Open In Colab   Open in Kaggle

Tutorial 3: Generalization in Cognitive Science

Week 1, Day 1: Generalization

By Neuromatch Academy

Content creators: Samuele Bolotta, Patrick Mineault

Content reviewers: Samuele Bolotta, Lily Chamakura, RyeongKyung Yoon, Yizhou Chen, Ruiyi Zhang, Aakash Agrawal, Alish Dipani, Hossein Rezaei, Yousef Ghanbari, Mostafa Abdollahi, Hlib Solodzhuk, Alex Murphy

Production editors: Konstantine Tsafatinos, Ella Batty, Spiros Chavlis, Samuele Bolotta, Hlib Solodzhuk, Alex Murphy


Tutorial Objectives

Estimated timing of tutorial: 30 minutes

This tutorial will introduce you to generalization in the context of cognitive science. We’ll close the loop of our exploration of different views of handwriting with a model that combines aspects of the models we covered in the neuroscience and AI tutorials, including both generative and discriminative components.

In particular, we’ll be looking at the Omniglot dataset, and how it can be used to infer how humans and machines generalize in a handwritten symbol recognition task. We’ll try our hand at one-shot learning, and we’ll measure our sample complexity. We’ll then discuss how one cognitive model, Feinman and Lake (2020), attempts to solve the problem of handwritten symbol recognition using a neuro-symbolic method.

By the end of this tutorial, participants will be able to:

  1. Explore the goals of cognitive science. Understand the aims of cognitive science such as unraveling the complexities of human cognition.

  2. Define one-shot learning and sample complexity. Perform a task that involves one-shot learning.

  3. Explore how a neurosymbolic model with strong inductive biases could explain one-shot learning on Omniglot.


Setup

Install and import feedback gadget

Source

Import dependencies

Source

Figure settings

Source

Plotting functions

Source

Data retrieval for zip files

Source

Data retrieval for torch models

Source

Helper functions

Source

Video 1: Overview

Youtube
Bilibili

Section 1: How people recognize new characters

Let’s put ourselves in the mindset of a cognitive scientist studying handwriting. We’re interested in how people learn to recognize new characters. Indeed, humans display low sample complexity when learning new visual concepts: they seem to grasp new concepts with very few presentations, generalizing effortlessly. In AI, learning from kk labeled examples is known as kk-shot learning; one-shot and few-shot learning refer to learning from one or a few labeled examples.

A good dataset to investigate one-shot learning is the Omniglot dataset. Omniglot has sometimes been described as MNIST, transposed. Instead of thousands of examples from 10 digit classes (many examples, few classes), Omniglot consists of 20 instances from 1623 character classes (few examples, many classes). These character classes are sourced from 50 alphabets, both natural (e.g. Cherokee or Greek) and constructed (e.g. the alien alphabet from the TV show Futurama).

Sample characters from the Omniglot dataset

Let’s see if you’re a good one-shot classifier by trying the Omniglot task yourself. Observing human behavior in the lab to infer their strategies is an important way that cognitive scientists make progress in understanding human cognition.

Your task is to conduct a series of trials to explore the Omniglot dataset. Here’s how the experiment goes:

  1. Click Start

  2. Look at the reference character at the top

  3. Look at 9 different potential matches at the bottom. These include one more instance of the reference character class, and 8 distractors from other characters of the same alphabet.

  4. Click the button corresponding to the best match. The selection buttons are on the right of the grid.

  5. Repeat for multiple trials. Get to 10 or 20 to get an estimate of how well you perform.

Loading...
Loading...

How well did you do?

Reflection activity 1.1

Sample complexity N(ε,δ)N(\varepsilon, \delta) is formally defined as:

the number of examples NN that a learner must see in order to perform a task with an error rate smaller than ε\varepsilon with probability greater than 1−δ1-\delta.

Based on this definition, what is your sample complexity on the Omniglot task?

Reflection activity 1.2

How do you think you, as a human, are performing a task like Omniglot?


Section 2: Model of one-shot learning

Video 2: GNS Model

Youtube
Bilibili

Feinman and Lake (2020) propose a cognitive model to explain how humans perform one-shot recognition tasks like Omniglot. Their model is based on the insight handwriting characters are highly structured: if we could infer how a character was generated, we could figure out the writer’s intent, and perform one-shot recognition of characters.

When we write down a character on a piece of paper or a screen, we might implicitly perform a sequence of steps:

  1. Prepare a global motor plan to write a character based on prior experience

  2. Decide where to put down the pen for the first stroke

  3. Draw a stroke in an appropriate direction.

    a. Look at the sheet of paper during the writing to adjust the direction of the stroke

  4. Find a location for the second strike, and so on...

  5. When satisfied, stop drawing strokes

Feinman and Lake (2020) propose to embed these assumptions into a generative model for how a single character is generated from strokes.

The result is a highly structured Bayesian generative model containing both discrete components (e.g. strokes) and continuous components (e.g. the location of the next stroke is a continuous variable). It combines symbolic primitives (strokes) as well as standard ANN components. This combination of using symbols and neural networks is known as a neuro-symbolic approach.

This is an example of a model with strong inductive biases.


The Big Picture

  • Cognitive science seeks to understand how human cognition works.

  • Humans display one-shot learning on Omniglot, a character recognition task. This requires extensive generalization.

  • Sample complexity measures the minimum number of examples needed to reach a specific performance with some probability; a sample complexity of 1 indicates one-shot learning at a specific performance level.

  • A generative neurosymbolic model with strong inductive biases exhibits human-level performance on Omniglot.