import torch
import pandas as pd
import numpy as np
x=torch.tensor([3.0])
y=torch.tensor([2.0])
x+y,x*y,x/y,x**y
x=torch.arange(4,dtype=torch.float32)
print(x)
print(x[3])
print(len(x))
print(x.shape)
a=torch.arange(20,dtype=torch.float32).reshape(5,4)
b=a.T
b=torch.tensor([[1,2,3],[2,0,4],[3,4,5]])
print(b==b.T)
x=torch.arange(24,dtype=torch.float32).reshape(2,3,4)
print(x)
a=torch.arange(20,dtype=torch.float32).reshape(5,4)
b=a.clone()
a,a+b
a*b
a=2
x=torch.arange(24).reshape(2,3,4)
print(a+x)
print((a*x).shape)
x=torch.arange(4,dtype=torch.float32)
print(x.sum())
a=torch.arange(20*2,dtype=torch.float32).reshape(2,5,4)
print(a.shape)
print(a.sum())
sum_a0=a.sum(axis=0)
print(sum_a0)
print(sum_a0.shape)
sum_a1=a.sum(axis=1)
print(sum_a1)
print(sum_a1.shape)
print(a.sum(axis=[0,1]))
a.mean(),a.sum()/a.numel()
a.mean(axis=0),a.sum(axis=0)/a.shape[0]
sum_a=a.sum(axit=1,keepdim=True)
b=a/sum_a
y=torch.ones(4,dtype=torch.float32)
x,y,torch.dot(x,y)
torch.sum(x*y)
b=torch.mv(a,x)
b=torch.ones(4,3)
torch.mm(a,b)
u=torch.tensor([3.0,-4.0])
torch.norm(u)
torch.abs(u).sum()
torch.norm(torch.ones(4,9))