Santiago Profile picture
27 Dec, 16 tweets, 4 min read
An introduction to one of the the most basic structures used in machine learning: a tensor.

πŸ§΅πŸ‘‡
Tensors are the data structure used by machine learning systems, and getting to know them is an essential skill you should build early on.

A tensor is a container for numerical data. It is the way we store the information that we'll use within our system.

(2 / 16)
Three primary attributes define a tensor:

▫️ Its rank
▫️ Its shape
▫️ Its data type

(3 / 16)
The rank of a tensor refers to the tensor's number of axes.

Examples:

▫️ The rank of a matrix is 2 because it has two axes.
▫️ The rank of a vector is 1 because it has a single axis.

(4 / 16)
The shape of a tensor describes the number of dimensions along each axis.

Example:

▫️ A square matrix may have (3, 3) dimensions.
▫️ A tensor of rank 3 may have (2, 5, 7) dimensions.

(5 / 16)
The data type of a tensor refers to the type of data contained in it.

For example, when thinking about Python 🐍's numpy library, here are some of the supported data types:

▫️ float32
▫️ float64
▫️ uint8
▫️ int32
▫️ int64

(6 / 16)
In the previous tweets I used the terms "vector" and "matrix," to referr to tensors with a specific rank (1 and 2 respectively.)

We can also use these mathematical concepts when describing tensors.

(7 / 16)
A scalar β€”or a 0D tensorβ€” has rank 0 and contains a single number. These are also called "0-dimensional tensors."

The attached image shows how to construct a 0D tensor using numpy. Notice its shape and its rank (.ndim attribute.)

(8 / 16)
A vector β€”or a 1D tensorβ€” has rank 1 and represents an array of numbers.

The attached image shows a vector with shape (4, ). Notice how its rank (.ndim attribute) is 1.

(9 / 16)
A matrix β€”or a 2D tensorβ€” has rank 2 and represents an array of vectors. The two axes of a matrix are usually referred to as "rows" and "columns."

The attached image shows a matrix with shape (3, 4).

(10 / 16)
You can obtain higher-dimensional tensors (3D, 4D, etc.) by packing lower-dimensional tensors in an array.

For example, packing a 2D tensor in an array gives us a 3D tensor. Packing this one in another array gives us a 4D tensor, and so on.

(11 / 16)
Here are some common tensor representations:

▫️ Vectors: 1D - (features)
▫️ Sequences: 2D - (timesteps, features)
▫️ Images: 3D - (height, width, channels)
▫️ Videos: 4D - (frames, height, width, channels)

(12 / 16)
Commonly, machine learning algorithms deal with a subset of data at a time (called "batches.")

When using a batch of data, the tensor's first axis is reserved for the size of the batch (number of samples.)

(13 / 16)
For example, if your handling 2D tensors (matrices), a batch of them will have a total of 3 dimensions:

▫️ (samples, rows, columns)

Notice how the first axis is the number of matrices that we have in our batch.

(14 / 16)
Following the same logic, a batch of images can be represented as a 4D tensor:

▫️ (samples, height, width, channels)

And a batch of videos as a 5D tensor:

▫️ (samples, frames, height, width, channels)

(15 / 16)
If all of this makes sense, you are on your way! If something doesn't click, reply with your question, and I'll try to answer.

Either way, make sure to follow me for more machine learning content! 2021 is going to be great!

(16 / 16)

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Santiago

Santiago Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @svpino

28 Dec
I told everyone that I didn't care.

"Screw math! I've never been great with it, so I'm not starting with machine learning to fail at the end."

That was many years ago.

Math is still hard, but I don't think you should be scared at all. Here is why: πŸ§΅πŸ‘‡
[1] One thing changed my mind: school pushed me to the deep end of the pool, and I was forced to swim.

I had to face my fears, and I started machine learning and realized that the math involved is not as scary (or as much) as some people believe.

πŸ‘‡
[2] Probably one of the most frequent questions I get is around the math needed for machine learning.

Answer:

▫️ Probabilities and Statistics
▫️ Linear Algebra
▫️ Calculus

But it turns out that this is not helpful.

πŸ‘‡
Read 18 tweets
27 Dec
I've worked with Dell, HP, IBM, Cisco, HSBC, Disney, G4S, among other large companies.

Don't think for a minute that they have things figured out.

They have amazing development teams. They also have mediocre and straight-horrible teams.

πŸ§΅πŸ‘‡
[2] In my experience, smaller companies tend to be more selective when hiring: they can't afford to make a mistake.

I've found out that these smaller companies build consistently decent teams. (Although they have a harder time hiring talent.)

πŸ‘‡
[3] Larger companies, on the other hand, build teams across many different departments. Maintaining consistency is hard, if not impossible.

I met excellent teams: sharp, organized, building excellent products using state-of-the-art technology.

πŸ‘‡
Read 6 tweets
26 Dec
11 key concepts of Machine Learning.

β€” Supervised Learning Edition β€”

πŸ§΅πŸ‘‡
😜

Before starting, remember that, if you follow me, one of your enemies will be immediately destroyed (and you'll get to read more of these threads, of course.)

And if you don't follow me, well, you just hurt my feelings.

😜
1. Labels

(Also referred to as "y")

The label is the piece of information that we are predicting.

For example:

- the animal that's shown in a picture
- the price of a house
- whether a message is spam or not

πŸ‘‡
Read 13 tweets
22 Dec
The 8-step quick-start guide to learn Machine Learning.

πŸ§΅πŸ‘‡
1⃣ Start with Python 🐍

Yes, you can do other languages, but Python is by far the most straightforward option.

πŸ‘‡
2⃣ Get familiar with numpy, pandas, and matplotlib

These three libraries are probably the most common Python libraries you'll have to use every day.

(Even if you don't end up doing machine learning, these libraries are awesome and useful.)

πŸ‘‡
Read 10 tweets
21 Dec
Rumors are going around that Twitter cripples tweets that include links.

There's nothing in their official documentation, but a lot of people think that's the case.

I thought this through, and I will not play along.

πŸ§΅πŸ‘‡
Allegedly, if I disable the links, my tweets will get much more impressions because Twitter will push them to more people.

Assuming this is the case, what's the cost?

My followers will have to start copying, then pasting any links that I post.

(2 / 4)
Seems like a small nuance, but reading comments on tweets with disabled links, the process is very error-prone and a lot of people have trouble accessing the content.

This is not what I want.

(3 / 4)
Read 4 tweets
3 Dec
Transitioning from Software Engineering to Machine Learning.

πŸ§΅πŸ‘‡
I'll tell you my story.

It might work for you. It might not.

Hopefully, it gives you another perspective. Hopefully, it helps.

(2 / 14)
Many people see "Software Engineering" and "Machine Learning Engineering" as two completely different specialization areas.

There are many differences, for sure.

But I personally like to think about them as a single, fluid, all-encompassing position.

(3 / 14)
Read 14 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!