写了一个做图像语义分割任务的自编码器,结构如下:
成功训练并且保存了模型,输入一张128*128的图像进行预测,如下:
from tensorflow import keras
# 预测
test_arr = test_arr.astype("float16")/255
pred_arr = (conv_autoencoder.predict(test_arr) > 0.5).astype("int32")
运行后报错:Conv2DSlowBackpropInput: input and out_backprop must have the same batch sizeinput batch:5outbackprop batch: 1batch_dim:0
首先猜一下啥意思,这个batch size应该不是指的训练时梯度下降的batch size。训练模型时没有问题而且我没有传递batch_size参数。
因为这里说input batch,我输入5张图片进行预测,没有报错。