diff --git a/11/3.py b/11/3.py new file mode 100644 index 0000000..0b2da0e --- /dev/null +++ b/11/3.py @@ -0,0 +1,20 @@ +import torch + +print(f"PyTorch Version: {torch.__version__}") + +matrix1 = torch.tensor( + [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]], dtype=torch.float32 +) + +matrix2 = torch.tensor( + [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], dtype=torch.float32 +) + +result = matrix1 @ matrix2 + +print("\nMatrix 1 (5 x 3):") +print(matrix1) +print("\nMatrix 2 (3 x 4):") +print(matrix2) +print("\nResult of matrix multiplication (5 x 4):") +print(result) diff --git a/11/4.py b/11/4.py new file mode 100644 index 0000000..4fde49a --- /dev/null +++ b/11/4.py @@ -0,0 +1,35 @@ +import torch + +zeros = torch.zeros(3, 3) +ones = torch.ones(3, 3) +random_matrix = torch.rand(3, 3) + +print("Zeros matrix:") +print(zeros) +print("\nOnes matrix:") +print(ones) +print("\nRandom matrix:") +print(random_matrix) + +print("\nAbsolute value of random matrix:") +print(torch.abs(random_matrix)) + +print("\nAddition of ones and random matrix:") +print(ones + random_matrix) + +print("\nDivision of random matrix by ones:") +print(random_matrix / ones) + +print("\nDot product of random matrix with ones:") +print(random_matrix * ones) + +print("\nCross product of random matrix with ones:") +print(random_matrix @ ones) + +print("\nExponentiation of random matrix:") +print(torch.exp(random_matrix)) + +print("\nSize of matrices:") +print(f"Shape: {random_matrix.size()}") +print(f"Dimensions: {random_matrix.dim()}") +print(f"Total elements: {random_matrix.numel()}")