본문 바로가기
  • Hello_
728x90
반응형

Python/Error14

[Python_Error] ValueError: all the input arrays must have same number of dimensions (np.concatenate 오류) 본 포스팅은 업무 중 발생했던 오류들을 예시를 통해 어떻게 해결을 하는지 작성했다. ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 3 dimension(s) and the array at index 1 has 4 dimension(s) 해당 오류는 np.concatenate()을 사용할때 발생했던 오류이며, 특히 3차원 이상의 어레이들을 concat할때 많이 보이는 오류이다. 특히 2차원 이미지에 배치, 채널이 포함된 데이터의 경우 자주 발생했다. [예시_1] 다음과 같이 np.concatenate는 사용할 때 특정 축을 기준으로 결합이 되기 때문에 axis 인자에 입력한 특.. 2022. 10. 4.
[Python_Error] TypeError: '>' not supported between instances of 'list' and 'int' 본 포스팅은 업무 중 발생했던 오류들을 예시를 통해 어떻게 해결을 하는지 작성했다. TypeError: '>' not supported between instances of 'list' and 'int' 본 오류는 리스트 형태의 어레이를 관계 연산자('>', '=', '' not supported between instances of 'list' and 'int' """ [해결 방법] 이는 단순히 리스트 형태의 어레이를 np.array를 통해 싸주고 넘파이 형태로 바꿔주면 해결이 가능하다. nums = np.array([1,2,3,4,5,6,7,8,9,10]) print(nums > 3) # [False False False True True True True True True True] 혹은 같은 리스.. 2022. 10. 1.
[Python_Error] TypeError: slice indices must be integers or None or have an __index__ method 본 포스팅은 업무 중 발생했던 오류들을 예시를 통해 어떻게 해결을 했는지 적을 예정이다. TypeError: slice indices must be integers or None or have an __index__ method 해당 오류는 list를 슬라이싱 할 때 int의 조합이 아니라 실수의 조합으로 입력이 되면 발생하는 오류이다. 필자는 //을 사용하여 입력을 정수로 만들고 슬라이싱을 진행하고자 했으나 float로 출력이 되어서 발생했던 오류이다. [예시] import numpy as np rand = [77, 84, 39, 42, 64] print(rand) # [77, 84, 39, 42, 64] ori_idx = np.array([3.,9.]) half_idx = ori_idx // 2 pr.. 2022. 9. 29.
[Python_Error] TypeError: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' 본 포스팅은 업무 중 발생했던 오류들을 예시를 통해 어떻게 해결을 했는지 적을 예정이다. TypeError: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' 이 오류는 숫자와 np.array로 싸인 string 변수를 나눌 때 발생했던 오류이다. [예시] import numpy as np number_1 = np.array([3,6,9]) # float array number_2 = np.array(str(3)) # string number_1/number_2 """ T.. 2022. 9. 29.
728x90
반응형