반응형

파이토치 51

[Pytorch] 5. 파이토치로 합성곱 신경망(CNN) 구축하기

이전 포스팅에서 torch.nn 모듈을 사용해서 기본적인 신경망을 구축해보았습니다. 이번에는 파이토치를 사용하여 합성곱 신경망(CNN)을 구축하는 방법을 알아보겠습니다. CNN 으로 넘어가기 이제 3개의 합성곱 계층(convolutional layers)을 지닌 신경망을 구축해보겠습니다. 이전 섹션에서 어떤 함수도 모델의 형식에 대해 가정하지 않기 때문에, 수정 없이 CNN을 훈련하기 위해 이전 코드를 사용할 수 있습니다. 합성곱 계층으로서 Pytorch의 사전 정의된 Conv2d 클래스를 사용할 것입니다. 각 합성곱 뒤에 ReLU가 있습니다. 마지막에는 평균 풀링(average pooling)을 수행합니다. (view 는 numpy의 reshape 의 pytorch 버전입니다.) class Mnist_..

카테고리 없음 2020.12.09

[PyTorch] 4. 검증(validation) 추가하고 fit() 와 get_data() 생성하기

실제로 효과적인 모델을 생성하는데 필요한 기본적인 기능들을 추가해보겠습니다. 검증(validation) 추가하기 이전 포스팅에서 훈련 데이터를 사용하기 위해 합리적인 훈련 루프를 설정하려 했습니다. 과적함인지 확인하기 위해 실제로는 항상 검증 데이터 셋을 갖고 있어야 합니다. 배치와 과적합 사이에 상관관계를 방지하기 위해 훈련 데이터를 섞는 것은 중요합니다. 반면에 검증 손실은 검증 셋을 섞었는지 안섞었는지 동일합니다. 따라서 데이터를 섞는 것은 추가 시간이 필요하기 때문에, 검증 데이터를 섞을 필요는 없습니다. 훈련 셋의 배치 크기 2배로 검증 셋에 대한 배치 크기를 사용하겠습니다. 검증 셋은 역전파가 필요없기 때문에 적은 메모리를 사용합니다. (기울기를 저장할 필요가 없기 때문입니다.) 큰 배치 크기..

[PyTorch] 3. 파이토치 Dataset, DataLoader 를 사용하여 깔끔한 코드 작성하기

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. What is torch.nn really? — PyTorch Tutorials 1.7.0 documentation Note Click here to download the full example code What is torch.nn really? by Jeremy Howard, fast.ai. Thanks to Rachel Thomas and Francisco Ingham. We recommend running this tutorial as a notebook, not a script. To download the notebook (.ipynb) file, clic pytorch.org 이전 포스팅에서는 pytorch.nn 모듈을 사용..

[PyTorch] 2. 파이토치 torch.nn을 사용해서 신경망 구축하기

2.공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. What is torch.nn really? — PyTorch Tutorials 1.7.0 documentation Note Click here to download the full example code What is torch.nn really? by Jeremy Howard, fast.ai. Thanks to Rachel Thomas and Francisco Ingham. We recommend running this tutorial as a notebook, not a script. To download the notebook (.ipynb) file, clic pytorch.org 이전 포스팅에서 PyTorch module 없..

[Pytorch] 1. MNIST 데이터를 불러오고 파이토치 없이 신경망 구현하기

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. What is torch.nn really? — PyTorch Tutorials 1.7.0 documentation Note Click here to download the full example code What is torch.nn really? by Jeremy Howard, fast.ai. Thanks to Rachel Thomas and Francisco Ingham. We recommend running this tutorial as a notebook, not a script. To download the notebook (.ipynb) file, clic pytorch.org Torch.NN이 실제로 무엇일까? PyTorch..

[PyTorch] 3. 예제로 배우는 파이토치 - nn 모듈, 가중치 공유, 제어 흐름, 사용자 정의 nn 모듈

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. Learning PyTorch with Examples — PyTorch Tutorials 1.7.0 documentation Learning PyTorch with Examples Author: Justin Johnson This tutorial introduces the fundamental concepts of PyTorch through self-contained examples. At its core, PyTorch provides two main features: An n-dimensional Tensor, similar to numpy but can run on GP pytorch.org 예제로 배우는 파이토치 - Learni..

[PyTorch] 2. 예제로 배우는 파이토치 - 자동미분(Autograd)

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. Learning PyTorch with Examples — PyTorch Tutorials 1.7.0 documentation Learning PyTorch with Examples Author: Justin Johnson This tutorial introduces the fundamental concepts of PyTorch through self-contained examples. At its core, PyTorch provides two main features: An n-dimensional Tensor, similar to numpy but can run on GP pytorch.org 예제로 배우는 파이토치 - Learni..

[PyTorch] 1. 예제로 배우는 파이토치 - Tensors

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. Learning PyTorch with Examples — PyTorch Tutorials 1.7.0 documentation Learning PyTorch with Examples Author: Justin Johnson This tutorial introduces the fundamental concepts of PyTorch through self-contained examples. At its core, PyTorch provides two main features: An n-dimensional Tensor, similar to numpy but can run on GP pytorch.org 예제로 배우는 파이토치 - Learno..

[PyTorch] 파이토치로 신경망 학습하기 - CNN, GPU, CIFAR10, 신경망 평가하기

분류기 학습하기 - Training a classifier 지금까지 신경망을 어떻게 정의하고, 손실을 계산하고, 신경망의 가중치를 갱신하는 것을 살펴보았습니다. 아마 이렇게 생각할 수 있습니다. 데이터는 어떻게 해야하지? - What about Data? 일반적으로 이미지, 문자, 음성, 비티오 데이터를 다룰 때, numpy 배열로 data를 불러오는 표준 python 패키지를 사용할 수 있습니다. 그리고나서 배열을 torch.*Tensor 로 전환할 수 있습니다. 이미지는 Pillow, OpenCV와 같은 패키지가 유용합니다. 오디오는 scipy, librosa와 같은 패키지가 유용합니다. 문자는 그냥 Python 이나 Cython을 사용해도 좋고 NLTK와 SpaCy가 유용합니다. 특히 영상 분야에서..

[PyTorch 튜토리얼] 자동 미분 - AUTOGRAD : Automatic differentiation - backward, requires_grad, detach, autograd

공부 목적으로 PyTorch 튜토리얼 홈페이지를 변역해보았습니다. Autograd: Automatic Differentiation — PyTorch Tutorials 1.7.0 documentation Note Click here to download the full example code Autograd: Automatic Differentiation Central to all neural networks in PyTorch is the autograd package. Let’s first briefly visit this, and we will then go to training our first neural network. The autogra pytorch.org 자동미분 - AUTOGRAD : ..

반응형