from keras.utils import to_categorical
from keras.layers import *
from keras.models import Sequential
from keras.datasets import cifar10
cifar10 = cifar10.load_data()
(x_train, y_train), (x_test, y_test) = cifar10
# 转变数据格式
y_train = y_train.reshape(y_train.shape[0])
y_test = y_test.reshape(y_test.shape[0])
# 对数据做归一化处理
x_train = x_train.astype("float32")
x_test = x_test.astype("float32")
x_train /= 255
x_test /= 255
# 将标签转变成适合网络输入的值, 想当于one_hot
y_train = to_categorical(y_train, 10)
y_test = to_categorical(y_test, 10)
使用keras下载cifar 10
最新推荐文章于 2024-06-18 14:42:51 发布