전이 학습을 사용하여 모델을 훈련했습니다. 이제 Colab에서 내 이미지를 예측할 때 오류가 표시됩니다.
WARNING:tensorflow:Model was constructed with shape (None, 128, 128, 3) for input Tensor("xception_input:0", shape=(None, 128, 128, 3), dtype=float32), but it was called on an input with incompatible shape (None, 275, 3).
WARNING:tensorflow:Model was constructed with shape (None, 128, 128, 3) for input Tensor("input_1:0", shape=(None, 128, 128, 3), dtype=float32), but it was called on an input with incompatible shape (None, 275, 3).
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-142a5ca8cbef> in <module>()
1 import numpy as np
----> 2 classes = np.argmax(model.predict(img), axis=-1)
3 print(classes)
.
.
.
ValueError: Input 0 of layer block1_conv1 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, 275, 3]
기본적으로 훈련 중에는 네트워크에 입력으로 이미지 배치를 제공했으며 테스트 / 평가 시간에도 동일하게 필요합니다. 따라서 쉬운 해결책은 img tensor의 차원을 [1, img.shape]
.
img_test = tf.expand_dims(img, axis=0)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다