标题介绍运行环境了win7

看网上好多keras识别minist 但是一般由于版本问题,无法直接用,,,这里还要特别感谢keras中文文档作者(三当家SCP)。教程整的非常好。还有就是最好你在安装anaconda 之前把原来安装过的PY卸载掉,要不然安装mingw的时候会出问题,,,安装就不详细介绍了网上有很多种----大致流程——anaconda-mingw-theano(注意环境变量,系统变量啥的)-keras。

下边附上一个可用程序哈,亲测可用。。。并附上数据,数据来源于网络,见文章底部,你就不用运行的时候在下载数据,这样很容易出错的。非GPU环境 win7 64bit

好的:其实重点是新的语法的问题。。。。。。。。。。。。。。。。。。。更新地方已标红。。。。。。。

 from __future__ import absolute_import
from __future__ import print_function
import numpy as np
np.random.seed(1337) # for reproducibility
import cPickle as pickle from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD, Adam, RMSprop
from keras.utils import np_utils '''
Train a simple deep NN on the MNIST dataset.
Get to 98.30% test accuracy after 20 epochs (there is *a lot* of margin for parameter tuning).
2 seconds per epoch on a GRID K520 GPU.
''' batch_size = 128
nb_classes = 10
nb_epoch = 10 def read_data(data_file):
24 import gzip
25 f = gzip.open(data_file, "rb")
26 train, val, test = pickle.load(f)
27 f.close()
28 train_x = train[0]
29 train_y = train[1]
30 test_x = test[0]
31 test_y = test[1]
32 return train_x, train_y, test_x, test_y # the data, shuffled and split between tran and test sets
#(X_train, y_train), (X_test, y_test) = mnist.load_data()
train_x, train_y, test_x, test_y = read_data("C:\Users\PC\.spyder2\mnist.pkl.gz")
X_train = train_x
X_test = test_x
X_train = X_train.astype("float32")
X_test = X_test.astype("float32")
X_train /= 255
X_test /= 255
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(train_y, nb_classes)
Y_test = np_utils.to_categorical(test_y, nb_classes) model = Sequential()
model.add(Dense(input_dim=784, output_dim=128))
53 model.add(Activation('relu'))
54 model.add(Dropout(0.2))
55 model.add(Dense(output_dim=128))
56 model.add(Activation('relu'))
57 model.add(Dropout(0.2))
58 model.add(Dense(output_dim=10))
59 model.add(Activation('softmax')) rms = RMSprop()
model.compile(loss='categorical_crossentropy', optimizer=rms,metrics=['accuracy'])
63
64 model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch)
65 score = model.evaluate(X_test, Y_test, batch_size=batch_size)
print('Test score:', score[0])
print('Test accuracy:', score[1])

数据在这里:http://www.cnblogs.com/xueliangliu/archive/2013/04/03/2997437.html。。。由于没法上传有15兆,我看这个大牛有这个数据,而且还附带了安装及原理等,自己看吧。。。。。。。

anaconda+theano+keras手写字符识别新版的更多相关文章

  1. 李宏毅 Keras手写数字集识别(优化篇)

    在之前的一章中我们讲到的keras手写数字集的识别中,所使用的loss function为‘mse’,即均方差.那我们如何才能知道所得出的结果是不是overfitting?我们通过运行结果中的trai ...

  2. 仅用200个样本就能得到当前最佳结果:手写字符识别新模型TextCaps

    由于深度学习近期取得的进展,手写字符识别任务对一些主流语言来说已然不是什么难题了.但是对于一些训练样本较少的非主流语言来说,这仍是一个挑战性问题.为此,本文提出新模型TextCaps,它每类仅用200 ...

  3. 100天搞定机器学习|day39 Tensorflow Keras手写数字识别

    提示:建议先看day36-38的内容 TensorFlow™ 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edge ...

  4. 【问题解决方案】Keras手写数字识别-ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接

    参考:台大李宏毅老师视频课程-Keras-Demo 在载入数据阶段报错: ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接 Google之 ...

  5. ubuntu 16.04+Anaconda+theano+keras安装【转】

    本文转载自:https://blog.csdn.net/u013786021/article/details/78370138 安装软件部分浪费了好长时间才装好.之前一直各种问题,后来卸卸了radin ...

  6. 利用Tensorflow实现手写字符识别

    模式识别领域应用机器学习的场景非常多,手写识别就是其中一种,最简单的数字识别是一个多类分类问题,我们借这个多类分类问题来介绍一下google最新开源的tensorflow框架,后面深度学习的内容都会基 ...

  7. Caffe2 手写字符识别(MNIST - Create a CNN from Scratch)[8]

    本教程创建一个小的神经网络用于手写字符的识别.我们使用MNIST数据集进行训练和测试.这个数据集的训练集包含60000张来自500个人的手写字符的图像,测试集包含10000张独立于训练集的测试图像.你 ...

  8. Keras手写识别例子(1)----softmax

    转自:https://morvanzhou.github.io/tutorials/machine-learning/keras/2-2-classifier/#测试模型 下载数据: # downlo ...

  9. keras手写数字识别

    import kerasimport timefrom keras.utils import np_utils start = time.time()(x_train, y_train), (x_te ...

随机推荐

  1. Win7_64位 CHM打不开

    (2)在命令行运行regsvr32 itss.dll (3)在命令行运行regsvr32 hhctrl.ocx (4)开始--运行--输入“regedit”,打开注册表,找到以下分支: HKEY_LO ...

  2. Mysql-binlog的移动和归档

    #!/bin/bash # To backup and archive binlogs. declare -i NUM=0 declare -i SUM=0 SUM=`/bin/ls -l mysql ...

  3. 阿里云启用IPV6

    ping过别人的IPv6网址之后,可以确定,局域网是不支持IPv6的.所以要使用隧道技术建立两台机器之间的IPv6连接 1.发现测试用服务器上没有IPv6地址.所以测试服务器的内核应该是没有IPv6模 ...

  4. matlab批量修改图片大小

    转自:http://blog.csdn.net/cike0cop/article/details/53087995 %author:coplin %time:2016-10-10 %function: ...

  5. 第10课 struct 和 union 分析

    1. struct的小秘密 (1)C语言中的struct可以看作变量的集合 (2)struct的问题——空结构体占用多的内存? [实例分析]空结构体的大小 #include <stdio.h&g ...

  6. ICML论文|阿尔法狗CTO讲座: AI如何用新型强化学习玩转围棋扑克游戏

    今年8月,Demis Hassabis等人工智能技术先驱们将来到雷锋网“人工智能与机器人创新大会”.在此,我们为大家分享David Silver的论文<不完美信息游戏中的深度强化学习自我对战&g ...

  7. mysql 更新(-)初始mysql

    01-MySql的前戏   MySql的前戏 在学习Mysql之前,我们先来想一下一开始做的登录注册案例,当时我们把用户的信息保存到一个文件中: #用户名 |密码root|123321 alex|12 ...

  8. 3.2_k-近邻算法案例分析

        k-近邻算法案例分析 本案例使用最著名的”鸢尾“数据集,该数据集曾经被Fisher用在经典论文中,目前作为教科书般的数据样本预存在Scikit-learn的工具包中. 读入Iris数据集细节资 ...

  9. centos已经安装了libestr但在安装libee时却提示未安装

    在loganalyzer+rsyslog日志分析错误总结;

  10. (6/24) 插件配置:轻松配置JS文件压缩

    实际开发中,在项目上线之前,我们编写的js代码是需要进行压缩的,我们可以采取压缩软件或者在线进行压缩,这不是我们的重点,在webpack中实现JS代码的压缩才是本节的核心. 通过webpack中可实现 ...