목록Study (Programming)/Pytorch (3)
akaSonny
모델 돌리고 퇴근하고 와서 봤는데 네트워크 문제 등등으로 모델 훈련이 중단되어 있는 경우 ,, 저장된 checkpoint를 이용해서 다시 훈련시켜보자 - checkpoint 파일: 'checkpoint.pth' model = Model() checkpoint = torch.load('checkpoint.pth') model.load_state_dict(checkpoint) for epoch in range(n_epoch): model.train() ... 그런데 나 같은 경우에는 이렇게 하니까 RuntimeError 가 발생했다. RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict: ~~ Unexpecte..

Linear regression 이란? x(입력값)와 y(출력값)가 $y = x * w + b$ 라는 관계식을 갖고 있다고 가정하고 푸는 문제! 따라서 모델은 $\hat{y} = x * w$ 라는 예측값을 출력하기 위해 1차 계수인 $w$를 학습을 통해 훈련하게 된다. 이제 간단한 linear model을 만들어보자. 1. (완전) 간단한 데이터셋 만들기 import torch import torchvision import numpy as np import matplotlib.pyplot as plt x_data = [1., 2., 3.] y_data = [2., 4., 6.] plt.plot(x_data, y_data) plt.xlabel('Hours') plt.ylabel('Points') plt.s..
5월부터 pytorch를 기초부터 배우게 되었다. 강의를 듣고 후에 복습하고 정리해야 나중에 남게 될 것 같아서 블로그에 정리하기로! 1. torch.ones(), torch.zeros() : 기본으로 실수형으로 나온다 import torch import numpy as np x = torch.ones(3, 2) print(x) # tensor([[1., 1.], # [1., 1.], # [1., 1.]]) x = torch.zeros(3, 2) print(x) # tensor([[0, 0.], # [0., 0.], # [0., 0.]]) 2. seed 고정 : random 변수를 사용할 때 seed를 고정하면 항상 똑같은 변수가 나오게 된다. 딥러닝 모델 훈련 후 reconstruct할 때 중요! to..