import torch
import numpy as np
# data to tensor
data = [[1, 2],[3,5]]
x_data = torch.tensor(data)
# ndarray to tensor
nd_array_ex = np.array(data)
tensor_array = torch.from_numpy(nd_array_ex)
pytorch의 tensor은 gpu에 올려서 사용 가능
x_data.device
# >>> device(type='cpu')
if torch.cuda.is_avaliable():
x_data_cuda = x_data.to('cuda')
x_data.device
# >>> device(type='cuda', index = 0)
view : reshape와 동일하게 tensor의 shape 변환squeeze : 차원의 개수가 1인 차원 삭제(압축)unsqueeze : 차원의 개수가 1인 차원 추가t1.mm(t2), t1.matmul(t2)w = torch.tensor(2.0,requires_grad=True)
y = w ** 2
z = 10 * y + 2
z.backward()
w.grad
https://github.com/FrancescoSaverioZuppichini/PyTorch-Deep-Learning-Template
https://github.com/PyTorchLightning/deep-learning-project-template
https://github.com/victoresque/pytorch-template
모듈 구성

참고
pytorch 튜토리얼
https://tutorials.pytorch.kr/beginner/blitz/autograd_tutorial.html
autograd
https://gaussian37.github.io/dl-pytorch-gradient/
출처 - 부스트캠프 AI tech 교육자료
[부스트캠프 AI Tech] Week 2 - Day 1