활연개랑

[ERROR 해결] Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received 본문

Python

[ERROR 해결] Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received

승해tmdhey 2022. 5. 9. 09:18
반응형
Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received:

inference 를 하는 과정에서 predict 값을 구하기 위해 model에 x값을 넣어주었을 때 다음과 같은 오류가 발생하였습니다.

x의 shape은 (300,400)이었으나, model로 들어갈 때 (batch, width,height, channel)형태로 들어가 주어야 하기 때문입니다. 

 

t_x = t_x.reshape(1, t_x.shape[0], t_x.shape[1], 1)
pred = model(t_x)

위와 같이 reshape을 해주면 잘 들어갑니다!