def data_stl10():
"""
Preprocess STL dataset
:return:
"""
# These values are specific to CIFAR10
img_rows = 96
img_cols = 96
nb_classes = 10
# the data, shuffled and split between train and test sets
#(X_train, y_train), (X_test, y_test) = cifar10.load_data()
X_train = np.load('x_stl10_train.npy')
y_train = np.load('y_stl10_train.npy') - 1
X_test = np.load('x_stl10_test.npy')
y_test = np.load('y_stl10_test.npy') - 1
if keras.backend.image_dim_ordering() == 'th':
X_train = X_train.reshape(X_train.shape[0], 3, img_rows, img_cols)
X_test = X_test.reshape(X_test.shape[0], 3, img_rows, img_cols)
else:
X_train = X_train.reshape(X_train.shape[0], img_rows, img_cols, 3)
X_test = X_test.reshape(X_test.shape[0], img_rows, img_cols, 3)
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255
# np.save("cifar10_legitimate.npy",X_test)
print('X_train shape:', X_train.shape)
print(X_train.shape[0], 'train samples')
print(X_test.shape[0], 'test samples')
# convert class vectors to binary class matrices
Y_train = np_utils.to_categorical(y_train, nb_classes)
Y_test = np_utils.to_categorical(y_test, nb_classes)
return X_train, Y_train, X_test, Y_test
#getting the grid visualization
jsmastl.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录