Learning Goal: I’m working on a python question and need guidance to help me lea

Learning Goal: I’m working on a python question and need guidance to help me learn.Hello, you can find the requirements bellow, i need the code to write it on my own jupyter Write some code that uses PyTorch tensors. Turn in your ipynb (Jupyter notebook) or py (Python) file.Create tensors with Python lists with the following dimensions (shapes): 1, 2×3, 2x2x2. Show the tensors’ shapes.
Create a 4D tensor with random numbers between 0 and 1. Use the relevant tensor function to do so.
Create a 2D tensor with all zeros and another with all ones. Use the relevant tensor function to do so.
Using a 4D tensor and using indexing: show a single scalar; show a single vector; show the first scalar from each vector.
Demonstrate adding a scalar to every scalar in a 3D tensor (using broadcasting).
Demonstrate element-wise dividing a 3D tensor by a vector (using broadcasting).
Demonstrate the use of the item() and tolist() functions to get Python values.
Demonstrate the use of min() and mean() providing the dim= parameter to find the min/mean over a certain dimension.
Combine two 2D tensors so one is “on top” of the other.
Reshape a 2D tensor to a 3D tensor.
Convert a tensor to single-precision floating point (float32), upload to the gpu, perform an arithmetic operation with another tensor, and then download from the gpu. Demonstrate that these steps worked.
Requirements: full code

Published
Categorized as Python

Leave a comment

Your email address will not be published. Required fields are marked *