Obras son amores y no buenas razones

La pregunta de ese doctor de la ley a Jesús en el evangelio de hoy sobre cuál es el mandamiento más grande de la ley es muy oportuna, pues los judíos tenían centenares de preceptos: exactamente 365…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

PyTorch Basics in 4 Minutes

This is Part 1 of the PyTorch Primer Series.

Topics Discussed:

It’s a Python based package for serving as a replacement of Numpy and to provide flexibility as a Deep Learning Development Platform.

Or simply put:

Tensors are similar to numpy’s ndarrays, with the addition being that Tensors can also be used on a GPU to accelerate computing.

Tensors are multi dimensional Matrices.

This will create a X by Y dimensional Tensor that has been instantiated with random values.

To Create a 5x3 Tensor with values randomly selected from a Uniform Distribution between -1 and 1,

Tensors have a size attribute that can be called to check their size

PyTorch supports various Tensor Functions with different syntax:

Consider Addition:

Inline functions are denoted by an underscore following their name. Note: These have faster execution time (With a higher memory complexity tradeoff)

All Numpy Indexing, Broadcasting and Reshaping functions are supported

Note: PyTorch doesn’t support a negative hop so [::-1] will result in an error

PyTorch supports various types of Tensors:

Note: Be careful when working with different Tensor Types to avoid type errors

Types supported:

Converting a torch Tensor to a numpy array and vice versa is a breeze.

Note: The torch Tensor and numpy array will share their underlying memory locations, and changing one will change the other.

Moving the Tensors to GPU can be done as:

Central to all neural networks in PyTorch is the autograd package. Let’s first briefly visit this, and we will then go to training our first neural network.

The autograd package provides automatic differentiation for all operations on Tensors. It is a define-by-run framework, which means that your backprop is defined by how your code is run, and that every single iteration can be different.

Let us see this in more simple terms with some examples.

autograd.Variable is the central class of the package. It wraps a Tensor, and supports nearly all of operations defined on it. Once you finish your computation you can call .backward() and have all the gradients computed automatically.

You can access the raw tensor through the .data attribute, while the gradient w.r.t. this variable is accumulated into .grad.

Source: PyTorch Docs

Calling the Backward function

Feel free to ask any questions below.
Also drop us a comment on the tutorials that you’d love to read, I will try to have that up ASAP.

The Next Part in the Series will discuss about Linear Regression.

Add a comment

Related posts:

Strings of Lostalgia

In the hushed obscurity of dawn, I would often find myself strumming the strings of my dambura, its familiar sound serving as a mournful hymn of lostalgia, evoking memories of a life now hidden…

NVIDIA for the future!

In this Voices of VR podcast, Omer Shapira, a senior VR designer and engineer at NVIDIA, talks about training artificial intelligence and robots in VR. Shapira’s main focus is designing human aspects…