-
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was inhomogeneous part. 에러 파이썬 문제 해결python source code 2023. 8. 4. 22:32728x90
파이썬에서 다양한 소스코드들을 활용하여
AI 관련 알고리즘들을 돌려보실 수 있을겁니다.
하지만 종종 오픈소스, 구글링에서 돌아다니는 소스코드 만으로는
원하는 로직을 구현하기가 어렵습니다.
커스터마이징을 적절히 해야 하는데
저 같은 경우에는 deque 메소드를 사용하여 메모리 관리 리스트를 만들던 중
균일하지 않은 3D array data를 활용하다보니
batch 메모리를 별도로 사용할 때 에러가 발생했습니다.. ㅠ
batch = np.random.choice(self.memory, self.batch_size, replace=False)에러 내용은 아래와 같고요...
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1000, 5) + inhomogeneous part.해법을 먼저 소개드립니다.
np.array로 변환하실 때 꼭 dtype=object 로 옵션 설정을 해주셔야 합니다.
memory = np.array(self.memory, dtype=object)오늘의 기록은 여기까지 하도록 하겠습니다
반응형'python source code' 카테고리의 다른 글
강화학습 DQN 파라미터 최적화 관련 (0) 2023.08.22 Keras 케라스 batch predict 예제 및 메소드 사용 (0) 2023.08.05 python numpy multi dimension random choice 에러 해결 (0) 2023.08.04 np zeros 타입에러 'cannot interpret '2' as a data type' (0) 2023.07.30 openAI gym 환경 생성 알아보기 (2) (0) 2023.07.22