Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import torch
- import numpy
- singleton = torch.tensor(8)
- print(singleton.item())
- #random_image_size_tensor = torch.rand(size=(224, 224, 3))
- #print(random_image_size_tensor.shape)
- #print(random_image_size_tensor.ndim)
- # zero = torch.zeros(size=(5, 5))
- # ones = torch.ones(size=(5, 5))
- # similarZeros = torch.zeros_like(zero)
- # toTen = torch.range(0, 10)
- # print(toTen)
- # toTen2 = torch.arange(start=0, end=100, step=3)
- # print(toTen2)
- tensor = torch.tensor([[1, 2, 3], [6, 7, 8]], dtype=torch.int32)
- print(f"Shape of the tensor is: {tensor.shape}")
- print(f"Dimension of the tensor is: {tensor.ndim}")
- print(f"Datatype of the tensor is: {tensor.dtype}")
- datatypecustom = torch.tensor([7, 8, 9], dtype=torch.float64)
- print(f"Custom datatype set to float64: {datatypecustom.dtype}")
- sample = torch.arange(start=0, end=10, step=2)
- print(sample)
- # sample = sample + 1
- # sample = sample * sample
- # Matrix Multiplication
- #new = sample @ sample
- #sample = torch.matmul(sample, sample)
- #print(sample)
- #for i in range(len(sample)):
- # sample = torch.mul(sample, i)
- #Transpose Matrix
- matrix = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
- print(matrix)
- print(matrix.T)
- matrix = torch.matmul(matrix, matrix.T)
- print(matrix)
- mat = torch.randn(3,3)
- det = torch.linalg.det(mat)
- print(det)
- print(mat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement