Deep (learning) like Jacques Cousteau - Part 1 - Sets

3 minute read

(TL;DR: I’m going to go deep into deep learning. Sets are collections of things.)

I will be using a lot of LaTeX rendered with MathJax which doesn’t show up in the RSS feed. Please visit my site directly to see equations and all that goodness!

Mural of Ol' Dirty Bastard

Here I go, deep type flow
Jacques Cousteau could never get this low

Ol’ Dirty Bastard from Wu-Tang Clan’s “Da Mystery of Chessboxin’”

Motivation for this series

I love deep learning. But a lot of the time I don’t feel comfortable with it at a foundational level. I need to do something about this! I’d describe my learning style as one of ‘obsessive detail orientation’. So let’s get into the detail together!

Our aim

Our aim is to develop an understanding of deep learning at a foundational level before moving onto deep learning itself. This means we will be starting with mathematics! We will learn how to apply these ideas in R.

What I write may not be as academically rigorous. However, to make sure that what I write is somewhat correct, I will be referring to these great books:

  • Goodfellow, Ian, et al. Deep Learning
  • Strang, Gilbert. Linear Algebra and Its Applications
  • Shilov, Georgii Evgen’evich. Linear Algebra
  • Lipschutz, Seymour. Schaum’s Outlines - Beginning Linear Algebra
  • Stewart, Ian, and David Tall. The Foundations of Mathematics.

I will follow the notation outlined in Goodfellow, Ian, et al.

Let’s get started on our adventure!

Today’s topic: Sets

Before we touch any linear algebra, let’s (very) briefly describe what a set is in maths. Sets will become important when we encounter scalars!

A set is a collection of ‘things’

Here are some examples of sets:

  • the integers between 1 and 10
  • the letters in the English alphabet

The things inside our sets are called elements or members of their sets. Some sets may not contain any elements. This is the empty set, which is depicted using the symbol .

The above two sets are finite sets. However sets can also be infinite.

What notation is used to depict sets?

Sets are normally descibed using curly braces. For example, the integers between 1 and 10 can be written like this:

where each element of our set is explicitly listed.

But sometimes it may be easier to use an ellipsis so that we don’t have to write out all of the elements of our set. For example, we could write the previous set like this:

Sometimes it may be impossible to write out all members of our set because it is an infinite set. For example - how can we depict all positive, even numbers using our set notation? We can do this!

What are some important, infinite sets?

Natural numbers

The set of natural numbers is the set of all ‘whole’, positive numbers starting with 1 and increasing with no upperbound.

This set is depicted using an uppercase ‘N’:

Examples of some natural numbers are .

Integers

The set of integers is the set of:

  • all natural numbers,
  • all natural numbers preceded with a negative sign, and
  • zero.

This set is depicted using an uppercase ‘Z’:

Examples of some integers are .

Rational numbers

The set of rational numbers consists of numbers that can be described by dividing one integer by another (except for dividing an integer by zero).

This set is depicted using an uppercase ‘Q’ for ‘quotient’:

Examples of some rational numbers are

Real numbers

The set of real numbers consists of all rational numbers, along with those numbers that cannot be expressed by dividing two integers which are not ‘imaginary’ numbers. This additional set of numbers is called irrational numbers.

(Let’s ignore imaginary numbers as they aren’t important to us in achieving our goal!)

The set of real numbers is depicted using an upper case ‘R’:

Examples of some real numbers are

How can we create sets in R?

One way is to use the sets package

library(sets)

Let’s define a set:

set_one <- set(1, 2, 3)
print(set_one)
## {1, 2, 3}

The order in which the elements of the set are depicted doesn’t make a set unique. For example, these two sets are equivalent:

set_two <- set(3, 2, 1)
print(set_one == set_two)
## [1] TRUE

We also discover that listing elements of a set multiple times doesn’t make a set unique:

set_three <- set(1, 1, 1)
set_four <- set(1)
print(set_three == set_four)
## [1] TRUE

We could also use some base R functions to emulate sets and their operations, but let’s leave it at this.

Conclusion

The area of set theory is huge and I could easily get lost in it. But we have covered off enough to talk about scalars so let’s move on.

WU-TANG!!!

Justin