TORCH (2) 썸네일형 리스트형 [Pytorch] GPU elapsed time / torch.cuda.Event() 딥러닝 모델이 실행되는 시간을 체크하려면 일반적으로 사용하는import timestart = time.time()output = model(input_tensor)elapsed_time = time.time()-start혹은import timestart = time.perf_counter()output = model(input_tensor)end = time.perf_counter()다음과 같은 방식으로 접근하는 것은 정확하지 않다. 그 이유는 우리가 일반적으로 딥러닝 모델에 대한 연산을 진행할 때 GPU를 사용하기 때문이다. 딥러닝 모델에 대한 연산이 진행되는 개괄적인 흐름은 다음과 같다.CPU에서 모델 학습/추론에 사용될 input tensor를 준비준비된 input tensor를 모델에서 연산이때 .. [Pytorch] torch.Tensor.expand() & torch.Tensor.repeat() torch 사용 중에 expand와 repeat을 몇번 접하게 되었는데, 사용하게 되면 어떤 결과가 나오는지에 대한 naive한 느낌은 있지만 명확하게 기억나지 않을때가 있어서 정리해놓으려고 한다. torch.Tensor.expand()https://pytorch.org/docs/stable/generated/torch.Tensor.expand.html#torch.Tensor.expand torch.Tensor.expand — PyTorch 2.4 documentationShortcutspytorch.orgPytorch 공식문서에 따르면, expand 메소드는 '차원 수가 1인 dim에 대해 그 수를 늘려준 view를 반환한다' 라고 설명되어있다.import torchtensor = torch.tenso.. 이전 1 다음