Texonom
Texonom
/
Engineering
Engineering
/Data Engineering/Artificial Intelligence/AI Development/AI Framework/Pytorch/Pytorch Error/
RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
Search

RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.

Creator
Creator
Seonglae Cho
Created
Created
2023 Oct 12 11:40
Editor
Editor
Seonglae Cho
Edited
Edited
2023 Oct 12 11:41
Refs
Refs
[Pytorch] 텐서를 넘파이 배열, 리스트로 변환하는 방법 정리
파이토치 tensor를 numpy array나 list로 바꾸기 파이썬 파이토치에서 tensor 자료형을 넘파이 배열 또는 리스트 자료형으로 변환하는 방법에 대하여 케이스별로 정리해보도록 하겠습니다. 1. 기본 텐서의 경우 : numpy() / tolist() 먼저, grad 정보가 없고 gpu에 선언되지 않은 가장 기본적인 텐서의 경우입니다. 아래와 같은 예시의 tensor를 형변환해보도록 하겠습니다. data1 = torch.randn(3, 2) data1 # 출력 결과 tensor([[-0.2370, -1.4314], [-0.7539, 0.5552], [-1.1405, -0.4047]]) 넘파이 배열 자료형으로 바꾸려면 tensor.numpy() 형태로 지정해주시면 됩니다. data1.numpy()..
[Pytorch] 텐서를 넘파이 배열, 리스트로 변환하는 방법 정리
https://jimmy-ai.tistory.com/324
[Pytorch] 텐서를 넘파이 배열, 리스트로 변환하는 방법 정리
 
 
 
 
 
 
 
 
 

Recommendations

Texonom
Texonom
/
Engineering
Engineering
/Data Engineering/Artificial Intelligence/AI Development/AI Framework/Pytorch/Pytorch Error/
RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
Copyright Seonglae Cho