ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() 해결법
if문 넘파이 배열 비교 연산자 ValueError 디버깅 비교문에서 numpy array 등 자료형에 대한 ==, != 연산 적용 시 등장할 수 있는 "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
jimmy-ai.tistory.com
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Let x be a NumPy array. The following: (x > 1) and (x < 3) Gives the error message: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ...
stackoverflow.com
- 배열 비교시 (and 연산자 사용) 발생하는 듯 하다.
- 배열의 값을 비교하는 것인지? 배열 자체를 비교하는 것인지? (확실하진 않음) 모호함이 있어서 정확히 어떤걸 비교할지 정확하게 명령을 내려줘야한다.
- 해결방법
- (~~ & ~~).any()
- (~~ & ~~).all()
- 로 특정지어줌
◐문제
if (mask_black[randH, randW] == 1) && (mask_black[randH + blocksize, randW + blocksize] == 1):
break
◐해결
if ((mask_black[randH, randW] == 1) & (mask_black[randH + blocksize, randW + blocksize] == 1)).all():
break
'프로젝트 에러 > [CGVR] texture-synthesis' 카테고리의 다른 글
pytorch - gpu 사용하기 (0) | 2023.07.14 |
---|---|
파이썬 python 주석 단축키 [ ctrl + / ] 안 될 때 (0) | 2023.04.27 |
cv2.error: ~~ !_src.empty() in function 'cv::cvtColor' (0) | 2023.04.26 |
cannot import name 'model_urls' from 'torchvision.models.vgg' (0) | 2023.04.25 |