PyTorch

Learn everything about PyTorch, one of the most deep learning framework these days

PyTorch torch.permute() function

Updated: July 23, 2023 By: Frienzied Flame

This concise article is about the torch.permute() function in PyTorch. The fundamentals The torch.permute() function is used to rearrange the dimensions of a tensor according to a given…

PyTorch: Selecting Elements from a Tensor (3 Ways)

Updated: July 23, 2023 By: Khue

This pithy, straightforward article will walk you through three different ways to select elements from a tensor in PyTorch. Without any further ado, let’s get started! Indexing &…

PyTorch: Squeezing and Unsqueezing Tensors

Updated: July 22, 2023 By: Frienzied Flame

Squeezing and unsqueezing a tensor are two operations that can change the shape of a tensor by adding or removing dimensions of size 1. This concise, straight-to-the-point article…

Stacking Tensors in PyTorch: Tutorials & Examples

Updated: July 22, 2023 By: Frienzied Flame

This concise, practical article is about stacking tensors in PyTorch with the torch.stack(), torch.vstack(), and torch.hstack() functions. torch.stack() Syntax & Parameters torch.stack() is a PyTorch function that joins…

How to Flatten a Tensor in PyTorch (2 Ways)

Updated: July 14, 2023 By: Khue

Flattening a tensor in PyTorch means reshaping it into a one-dimensional tensor (1D tensor). This concise, example-based article will show you a couple of different ways to do…

PyTorch Tensor.view() method (with example)

Updated: July 14, 2023 By: Khue

This concise and straight-to-the-point article is about the Tensor.view() method in PyTorch. The fundamentals A view of a tensor is a new tensor that shares the same underlying…

How to Reshape a Tensor in PyTorch (with Examples)

Updated: July 14, 2023 By: Khue

Overview In PyTorch, reshaping a tensor means changing its shape (the number of dimensions and the size of each dimension) while keeping the same data and the number…

Using the torch.prod() and torch.cumprod() functions in PyTorch

Updated: July 8, 2023 By: Khue

The torch.prod() and torch.cumprod() functions in PyTorch are used to calculate the product and the cumulative product of elements in a tensor, respectively. torch.prod() Syntax: Where: Example: torch.cumprod()…

PyTorch RuntimeError: mean(): could not infer output dtype

Updated: July 8, 2023 By: Khue

When working with PyTorch and using the torch.mean() function (or the torch.Torch.mean() method), you might encounter the following error: This error means that you are trying to use…

PyTorch: Find the Sum and Mean of a Tensor

Updated: July 8, 2023 By: Wolf

In PyTorch, to find the sum and mean of a tensor, you can use the torch.sum() and torch.mean() functions, respectively. These functions can operate on the whole tensor…

1 2 3