PyTorch

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

PyTorch: How to Find the Min and Max in a Tensor

Updated: July 8, 2023 By: Wolf

torch.min() and torch.max() In PyTorch, you can make use of the built-in functions torch.min() and torch.max() to find the minimum and maximum values of the whole tensor or…

PyTorch Error: mat1 and mat2 shapes cannot be multiplied

Updated: July 7, 2023 By: Wolf

Overview When working with PyTorch, you might encounter the following error: This error occurs when you try to perform a matrix multiplication using torch.matmul() or torch.mm() with two…

Working with the torch.matmul() function in PyTorch

Updated: July 7, 2023 By: Wolf

Overview The behavior of the torch.matmul() function The torch.matmul() function performs a matrix product of two tensors. The behavior depends on the dimensionality of the tensors as follows:…

How to Transpose a Tensor in PyTorch

Updated: July 7, 2023 By: Wolf

In the world of PyTorch and deep learning, transposing a tensor means rearranging its dimensions. For example, a tensor with a shape (3, 4) becomes (4, 3) after…

PyTorch tensor shape, rank, and element count

Updated: April 18, 2023 By: Khue

The shape of a PyTorch tensor The shape of a PyTorch tensor is the number of elements in each dimension. You can use the shape attribute or the…

PyTorch: Determine the memory usage of a tensor (in bytes)

Updated: April 18, 2023 By: Khue

In order to calculate the memory used by a PyTorch tensor in bytes, you can use the following formula: his will give you the size of the tensor…

PyTorch: How to change the data type of a tensor

Updated: April 17, 2023 By: Goodman

When working with PyTorch, there might be cases where you need to change the data type of a tensor for some reason, such as to match the data…

How to Create a Tensor Range in PyTorch

Updated: April 15, 2023 By: Goodman

A tensor range in PyTorch is a sequence of numbers that are stored in a one-dimensional tensor. In order to create a tensor range, you can use the…

Ways to Create Random Tensors in PyTorch

Updated: April 15, 2023 By: Goodman

When developing neural networks with PyTorch, there might be cases where you find random tensors are useful, such as when you need synthetic data for testing or experimentation…

PyTorch: How to create tensors with zeros and ones

Updated: April 15, 2023 By: Goodman

PyTorch is a popular framework for creating and manipulating tensors for deep learning and other applications. Tensors are multidimensional arrays that can store numerical data and perform various…

1 2 3