본문 바로가기

파이썬 에러5

AttributeError: 'tuple' object has no attribute 'size' 파이토치를 이용해 학습을 하려는 도중에 아래와 같은 오류가 발생했다. 오류메세지: AttributeError: 'tuple' object has no attribute 'size' 나는 현재 BCEWithLogitsLoss 손실함수를 사용하며 이진분류를 진행하고 있다. 이 에러는 input과 target의 크기가 다른 것으로, 둘 중 하나가 튜플(tuple) 형태로 되어있어 .size() 메소드를 호출할 수 없다는 것을 의미한다. for epoch in range(1, args['epoch'] + 1): model.train() running_corrects = 0 for videos, labels in tqdm(iter(train_loader), leave=False, desc='Train', asci.. 2024. 1. 11.
RuntimeError: Detected a call to `Model.predict` inside a `tf.function`. 파이썬 3.8에 tensorflow-gpu==2.9.0 버전을 사용하는 텐서플로우 환경에서 학습을 진행하는 도중 아래와 같은 오류가 발생했다. 오류메세지: RuntimeError: Detected a call to `Model.predict` inside a `tf.function`. `Model.predict is a high-level endpoint that manages its own `tf.function`. Please move the call to `Model.predict` outside of all enclosing `tf.function`s. Note that you can call a `Model` directly on `Tensor`s inside a `tf.function` lik.. 2024. 1. 4.
Error occurred during the 1 iteration: Unable to serialize [2.0896919 2.1128857 2.1081853] to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'> 텐서플로우 환경에서 EfficientNetB1 모델을 사용해 학습을 진행하는데 아래와 같은 오류가 발생했다. 오류메세지: Error occurred during the 1 iteration: Unable to serialize [2.0896919 2.1128857 2.1081853] to JSON. Unrecognized type pip install tensorflow-gpu==2.10.0으로 설치하였고 tensorflow-gpu의 버전이 2.10.* 일 경우에 이런 오류가 난다. 따라서 pip uninstall tensorflow-gpu를 통해 제거해주고 2.9.0 버전으로 다시 설치하면 해결이 가능하다. 해결방법: pip install tensorflow-gpu==2.9.0 2024. 1. 3.
ImportError: Could not import PIL.Image. The use of `load_img` requires PIL. 오류 메세지: ImportError: Could not import PIL.Image. The use of `load_img` requires PIL. test generator를 생성할 때 load_img를 사용하는데, 이는 PIL.Image에 속해있고 이를 쓰려면 PIL 라이브러리를 설치해야 한다. 따라서 pip나 conda 중 설치할 때 사용한 명령어를 이용해 pillow를 설치해주면 된다. 해결 방법: pip install pillow 2024. 1. 3.