热线电话:13121318867

登录
2019-07-08 阅读量: 519
如何检查数据格式

在mnist数据集中,它是28和28.我们还需要检查数据格式,即'channels_first'或'channels_last'。在CNN中,我们可以在数据之前对数据进行标准化,使得大的计算项可以减少到更小的项。比如,我们可以通过将其除以255来规范化x_train和x_test数据。

检查数据格式:

img_rows, img_cols=28, 28

if k.image_data_format() == 'channels_first':

x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)

x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)

inpx = (1, img_rows, img_cols)

else:

x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)

x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)

inpx = (img_rows, img_cols, 1)

x_train = x_train.astype('float32')

x_test = x_test.astype('float32')

x_train /= 255

x_test /= 255

0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子