对 mnist 数据集使用预训练模型

问题描述 投票:0回答:2

当我想使用预训练的 VGG16 时,问题是期望 shape=(None, 224, 224, 3),但发现 shape=(32, 28, 28)。 我该怎么做才能使用该模型?或者我不应该对 244 x 244 像素以下的图像使用卷积网络?

python tensorflow keras mnist
2个回答
1
投票

使用张量流调整大小,如下所示:

(x_train, y_train), (_, _) = tf.keras.datasets.mnist.load_data()

print(x_trian.shape) # (60000, 28, 28)

# train set / data 
x_train = np.expand_dims(x_train, axis=-1)
x_train = tf.image.resize(x_train, [224,224]) 

print(x_train.shape) # (60000, 224, 224, 1)

-1
投票

但是增加尺寸也会增加负载。应该还有别的办法。

© www.soinside.com 2019 - 2024. All rights reserved.