首页 > 解决方案 > 更改图像的形状以匹配模型输入形状的尺寸

问题描述

我训练了一个期望输入形状为(None, 9, 100, 100, 3). 当我运行以下代码时:

                    start_frame = 1
                    while success:
                       vid.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
                       success, image = vid.read()

                       image = np.array(image).astype('float32')/255
                       image = image.reshape(1,*image.shape)
                       image = np.expand_dims(image, axis=0)
                       preds = model.predict(image)

我收到以下警告/错误:WARNING:tensorflow:Model was constructed with shape (None, 9, 100, 100, 3) for input Tensor("conv3d_1_input:0", shape=(None, 9, 100, 100, 3), dtype=float32), but it was called on an input with incompatible shape (1, 1, 100, 100, 3).

有没有什么办法解决这一问题?

标签: python-3.xtensorflowimage-processingkeras

解决方案


推荐阅读