- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Shahid Akhtar Khan has Published 216 Articles
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
410 Views
torch.logical_xor() computes the element-wise logical XOR of the given two input tensors. In a tensor, the elements with zero values are treated as False and non-zero elements are treated as True. It takes two tensors as input parameters and returns a tensor with values after computing the logical XOR.Syntaxtorch.logical_xor(tensor1, tensor2)where ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
639 Views
torch.narrow() method is used to perform narrow operation on a PyTorch tensor. It returns a new tensor that is a narrowed version of the original input tensor.For example, a tensor of [4, 3] can be narrowed to a tensor of size [2, 3] or [4, 2]. We can narrow down ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
3K+ Views
torch.permute() method is used to perform a permute operation on a PyTorch tensor. It returns a view of the input tensor with its dimension permuted. It doesn't make a copy of the original tensor.For example, a tensor with dimension [2, 3] can be permuted to [3, 2]. We can also ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
2K+ Views
Tensor.expand() attribute is used to perform expand operation. It expands the Tensor to new dimensions along the singleton dimension.Expanding a tensor only creates a new view of the original tensor; it doesn't make a copy of the original tensor.If you set a particular dimension as -1, the tensor will not ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
4K+ Views
To create a tensor with gradients, we use an extra parameter "requires_grad = True" while creating a tensor.requires_grad is a flag that controls whether a tensor requires a gradient or not.Only floating point and complex dtype tensors can require gradients.If requires_grad is false, then the tensor is same as the ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
219 Views
Element-wise remainder when a tensor is divided by other tensor is computed using the torch.remainder() method. We can also apply torch.fmod() to find the remainder.The difference between these two methods is that in torch.remainder(), when the sign of result is different than the sign of divisor, then the divisor is ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
768 Views
torch.linalg.svd() computes the singular value decomposition (SVD) of a matrix or a batch of matrices. Singular value decomposition is represented as a named tuple (U, S, Vh).U and Vh are orthogonal for real matrix and unitary for input complex matrix.Vh is transpose of V when V is a real value ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
1K+ Views
In-place operations directly change the content of a tensor without making a copy of it. Since it does not create a copy of the input, it reduces the memory usage when dealing with high-dimensional data. An in-place operation helps to utilize less GPU memory.In PyTorch, in-place operations are always post-fixed ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
364 Views
To compute the sine of elements of a tensor, we use the torch.sin() method. It returns a new tensor with the sine values of the elements of the original input tensor. It takes a tensor as the input parameter and outputs a tensor.StepsImport the required library. In all the following ... Read More
![Shahid Akhtar Khan](https://www.tutorialspoint.com/assets/profiles/394091/profile/60_2508042-1636180991.jpg)
Shahid Akhtar Khan
10K+ Views
To compare two tensors element-wise in PyTorch, we use the torch.eq() method. It compares the corresponding elements and returns "True" if the two elements are same, else it returns "False". We can compare two tensors with same or different dimensions, but the size of both the tensors must match at non-singleton ... Read More