'torch' 태그의 글 목록 — 뚝딱이

torch

기타/Docker

도커 인공지능 환경 구성 - NVIDIA/torch

GPU https://pasongsong.tistory.com/429 도커 GPU 설정하기 Nvidia Toolkit docker 19.*.* 부터 nvidia-docker가 아닌 nvidia-container-runtime를 설치하면 GPU인식 및 활용이 가능하다. https://docs.docker.com/config/containers/resource_constraints/#gpu docker-24.0.7 nvidia-container-runtime 설치 $ sudo apt-get ins pasongsong.tistory.com 그 전에 도커 gpu먼저 설정해야한다. torch image https://hub.docker.com/ Docker Hub Container Image Library | A..

Machine Learning/Model

[FNN] numpy를 사용하여 FNN 구현하기

numpy를 활용하여 FNN을 구현해 보자! config class AttrDict(dict): def __init__(self, *args, **kwargs): super(AttrDict, self).__init__(*args, **kwargs) self.__dict__ = self config = AttrDict() config.lr= 0.001 config.bias = 0.7 config.epochs = 500 Data 클래스 0 데이터에 *10을 하여 차별점을 둠 def generate_binary_dataset(num_samples, num_features, random_state=50): np.random.seed(random_state) # 클래스 0 샘플 생성 num_samples_clas..

Python/numpy & Pytorch

[Pytorch] Pytorch 버전 확인과 GPU 연결 확인

버전 확인 import torch print(torch.__version__) GPU 연결 확인 device = 'cuda' if torch.cuda.is_available() else 'cpu' print(device)

Python/numpy & Pytorch

[Pytorch] tensor 합치기는 방법 cat(), stack()

'+' 연산자 list list에서는 '+' 연산자를 쓰면 list가 합쳐진다. x = [1,2] x2 = [3,4] x+x2 [1, 2, 3, 4] Tensor tensor는 합쳐지지 않고 각 원소마다 더해진다. 이는 같은 차원끼리 더하거나 한 차원이 1일 때만 가능함 x = torch.randint(0, 10,(3,1)) x2 = torch.randint(0, 10,(3,1)) x3 = torch.randint(0, 10,(1,1)) x, x2, x+x2, x+x3 tensor([[4], [2], [1]]) tensor([[2], [1], [2]]) tensor([[6], [3], [3]]) tensor([[5], [3], [2]]) x = torch.randint(0, 10,(3,1)) x2 = t..

Python/numpy & Pytorch

[Pytorch] torch 설정, 랜덤 tensor 생성

Pythorch를 모듈을 사용하여 tensor 객체 만드는 방법 tensor numpy의 array와 같지만 GPU 계산에서 사용됨 설정 행렬 사용자가 원하는 값을 넣어 행렬을 만듦 Zeros(size) 0이 들어있는 행렬을 return 함 x = torch.zeros(5, 3) x tensor([[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.]]) x = torch.zeros(2, 5, dtype=torch.bool) x tensor([[False, False, False, False, False], [False, False, False, False, False]]) Ones(size) 1이 들어있는 행렬을 returng 함 x = torch.ones(3,2) x tensor..

기타/etc

[Pytorch] Summary 사용하기

Module from torchsummary import summary 모델 구조 class CNN(nn.Module): def __init__(self): super(CNN, self).__init__() self.conv1 = nn.Conv2d(1, 32, 3, 1) self.conv2 = nn.Conv2d(32, 64, 3, 1) self.dropout1 = nn.Dropout2d(0.25) self.dropout2 = nn.Dropout2d(0.5) self.fc1 = nn.Linear(9216, 128) self.fc2 = nn.Linear(128, 10) def forward(self, x): x = self.conv1(x) x = F.relu(x) x = self.conv2(x) x = F...

Python/numpy & Pytorch

Pytorch Cuda CuDNN 설정하기

TORCH torch version = 1.10.0에서 GPU 설정하기 https://pytorch.org/ 난 pip로 깔았으나 conda를 사용하는 사람은 conda 누르고 깔면 됨. 아래를 terminal에 깔아준다. ' pip3 install torch==1.10.0+cu102 torchvision==0.11.1+cu102 torchaudio===0.10.0+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html ' https://pytorch.org/get-started/previous-versions/ PyTorch An open source machine learning framework that accelerates the pa..

파송송
'torch' 태그의 글 목록