关于报错ValueError: Error when checking input: expected conv2d_input to have 4 dimensions

报错
ValueError: Error when checking input: expected conv2d_input to have 4 dimensions, but got array with shape (150, 150, 3)

源代码:

image = mpimg.imread("./ima/b.jpg")
image = image/255
classe = model.predict(image, batch_size=1)

原因:
输入的格式不对
解决办法:
将数据集标准化

具体解决办法:

image = mpimg.imread("./ima/b.jpg")
image = image.reshape(image.shape(1,150,150,3)/255
classe = model.predict(image, batch_size=1)

你可能感兴趣的:(人工智能,机器学习,python,深度学习,计算机视觉,人工智能)