본문 바로가기

Error and Solve

[에러 해결] Boolean value of Tensor with more than one value is ambiguous / cuda에서 cpu로

반응형

 

 

Boolean value of Tensor with more than one value is ambiguous

 

 

Boolean value of Tensor with more than one value is ambiguous

Boolean value of Tensor with more than one value is ambiguous

 

 

np.any(mylist, axis=1) <- 코드를 돌리고 있었는데 

 

Tensor boolean 이 모호하다 라는 에러가 발생했다

 

 

 

 

 

해결: type cuda를 cpu로 바꾸

 

 

원래 type이 cuda() device에 있었는데 cpu로 바꾸니까 np.any 코드가 돌아갔다. 

 

결국 문제가 되는 mylist.cpu() 를 해서 해결했다

 

 


 

Reference

https://velog.io/@xdfc1745/Bool-value-of-Tensor-with-more-than-one-value-is-ambiguous-in-Pytorch

 

Bool value of Tensor with more than one value is ambiguous in Pytorch

GPU를 이용한 pytorch를 사용하다보면 이런 에러를 만날 수도 있다.이 에러는 tensor값을 boolen 값으로 비교하려고 할 떄 발생하는 에러이다. 예를 들면 다음과 같은 상황이다.위의 코드와 같이 tensor

velog.io

 

 

끝.

 

반응형