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)

More from Santiago

More from Machine learning

Really enjoyed digging into recent innovations in the football analytics industry.

>10 hours of interviews for this w/ a dozen or so of top firms in the game. Really grateful to everyone who gave up time & insights, even those that didnt make final cut 🙇‍♂️ https://t.co/9YOSrl8TdN


For avoidance of doubt, leading tracking analytics firms are now well beyond voronoi diagrams, using more granular measures to assess control and value of space.

This @JaviOnData & @LukeBornn paper from 2018 referenced in the piece demonstrates one method
https://t.co/Hx8XTUMpJ5


Bit of this that I nerded out on the most is "ghosting" — technique used by @counterattack9 & co @stats_insights, among others.

Deep learning models predict how specific players — operating w/in specific setups — will move & execute actions. A paper here: https://t.co/9qrKvJ70EN


So many use-cases:
1/ Quickly & automatically spot situations where opponent's defence is abnormally vulnerable. Drill those to death in training.
2/ Swap target player B in for current player A, and simulate. How does target player strengthen/weaken team? In specific situations?

You May Also Like

This is a pretty valiant attempt to defend the "Feminist Glaciology" article, which says conventional wisdom is wrong, and this is a solid piece of scholarship. I'll beg to differ, because I think Jeffery, here, is confusing scholarship with "saying things that seem right".


The article is, at heart, deeply weird, even essentialist. Here, for example, is the claim that proposing climate engineering is a "man" thing. Also a "man" thing: attempting to get distance from a topic, approaching it in a disinterested fashion.


Also a "man" thing—physical courage. (I guess, not quite: physical courage "co-constitutes" masculinist glaciology along with nationalism and colonialism.)


There's criticism of a New York Times article that talks about glaciology adventures, which makes a similar point.


At the heart of this chunk is the claim that glaciology excludes women because of a narrative of scientific objectivity and physical adventure. This is a strong claim! It's not enough to say, hey, sure, sounds good. Is it true?
THE MEANING, SIGNIFICANCE AND HISTORY OF SWASTIK

The Swastik is a geometrical figure and an ancient religious icon. Swastik has been Sanatan Dharma’s symbol of auspiciousness – mangalya since time immemorial.


The name swastika comes from Sanskrit (Devanagari: स्वस्तिक, pronounced: swastik) &denotes “conducive to wellbeing or auspicious”.
The word Swastik has a definite etymological origin in Sanskrit. It is derived from the roots su – meaning “well or auspicious” & as meaning “being”.


"सु अस्ति येन तत स्वस्तिकं"
Swastik is de symbol through which everything auspicios occurs

Scholars believe word’s origin in Vedas,known as Swasti mantra;

"🕉स्वस्ति ना इन्द्रो वृधश्रवाहा
स्वस्ति ना पूषा विश्ववेदाहा
स्वस्तिनास्तरक्ष्यो अरिश्तनेमिही
स्वस्तिनो बृहस्पतिर्दधातु"


It translates to," O famed Indra, redeem us. O Pusha, the beholder of all knowledge, redeem us. Redeem us O Garudji, of limitless speed and O Bruhaspati, redeem us".

SWASTIK’s COSMIC ORIGIN

The Swastika represents the living creation in the whole Cosmos.


Hindu astronomers divide the ecliptic circle of cosmos in 27 divisions called
https://t.co/sLeuV1R2eQ this manner a cross forms in 4 directions in the celestial sky. At centre of this cross is Dhruva(Polestar). In a line from Dhruva, the stars known as Saptarishi can be observed.