前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >卷积神经网络的Helloworld例子

卷积神经网络的Helloworld例子

作者头像
马克java社区
修改2019-09-11 19:07:40
3750
修改2019-09-11 19:07:40
举报
文章被收录于专栏:java大数据java大数据

下面是keras官方的卷积神经网络在github上的例子。和原版的唯一区别是:mnist的数据因为在国外(由于访问外国网站的原因,报错Exception: URL fetch failure on https://s3.amazonaws.com/img-datasets/mnist.npz),可以像我一样,下载数据后,放在本地。

batch_size = 128 num_classes = 10 epochs = 12 # input image dimensions img_rows, img_cols = 28, 28 # the data, split between train and test sets #(x_train, y_train), (x_test, y_test) = mnist.load_data() #把原版的网上的数据下载到本地 path='D://tmp//mnist.npz' f = np.load(path) x_train, y_train = f['x_train'], f['y_train'] x_test, y_test = f['x_test'], f['y_test'] f.close() 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) input_shape = (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)

更多请见:https://blog.csdn.net/qq_43650923/article/details/100739553

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档