455.space / 455.py.space
antitheft159's picture
Create 455.py.space
d34fb25 verified
raw
history blame contribute delete
915 Bytes
import torch
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
print(torch.__version__)
scalar = torch.tensor(7)
scalar
scalar.ndim
scalar.item()
vector = torch.tensor([7, 7])
vector.ndim
vector.shape
MATRIX = torch.tensor[[7, 8],[9, 10]]
MATRIX
MATRIX.ndim
MATRIX[1]
MATRIX.shape
TENSOR = torch.tensor([[[1, 2, 3],
[3, 6, 9],
[2, 4, 5]]])
TENSOR.ndim
TENSOR.shape
TENSOR[0]
random_tensor = torch.rand(3, 4)
random_tensor
random_tensor.ndim
random_image_size_tensor = torch.rand(size=(224, 224, 3))
random_image_size_tensor.shape, random_image_size_tensor.ndim
zeros = torch.zeros(size=(3, 4))
zeros
ones = torch.ones(size=(3, 4))
ones
ones.dtype
random_tensor.dtype
one_to_ten = torch.arange(start=1, end=11, step=1)
ten_zeros = torch.zeros_like(input=one_to_ten)
ten_zeros
float_32_tensor - torch.tensor([3.0, 6.0, 9.0],
dtype=None,
device=None,
requires_grad=False)