标题介绍运行环境了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. 关于wp数据备份

    差点忘记记录,之前一直用wp数据备份,但是一直发送邮件不成功,后来才发现,原来是因为发送的邮箱没有设置开通那个什么pop鬼的,不记得叫什么了,看下图. 开通这个服务,就可以正常接收wp的数据邮件备份了 ...

  2. ActiveMQ 高可用集群安装、配置(ZooKeeper + LevelDB)

    ActiveMQ 高可用集群安装.配置(ZooKeeper + LevelDB) 1.ActiveMQ 集群部署规划: 环境: JDK7 版本:ActiveMQ 5.11.1 ZooKeeper 集群 ...

  3. Linux之 AWK SED

    AWK系列#awk 中 NF表示取最后一列 NR表示取第几行 NR==3 表示取第三行[root@nodchen-db01-test ~]# free -m | awk 'NR==3 {print $ ...

  4. [UE4]创建多把枪,使用Class,参数的对象类型

    先来说说函数输入参数的区别: 1.Object Reference 2.Class Reference 会出现可以让你选择一个类 3.Soft Object Reference 4.Soft Clas ...

  5. [UE4]ue4 c++学习推荐

    我由易到难推荐,不过在此之前还是先看看官方对于VS设置的推荐: https://docs.unrealengine.com/latest/INT/Programming/Development/Vis ...

  6. Oracle jdk 历史版本官方下载地址及下载方法

    Oracle jdk 历史版本官方下载地址及下载方法 原文转载至:http://blog.csdn.net/chwshuang/article/details/54925950 平时要新装一个系统环境 ...

  7. sklearn中的metrics模块中的Classification metrics

    metrics是sklearn用来做模型评估的重要模块,提供了各种评估度量,现在自己整理如下: 一.通用的用法:Common cases: predefined values 1.1 sklearn官 ...

  8. Javascript中Closure及其相关概念

    我相信学过Javascript这门语言的程序员应该都对Closure这个概念有所了解,然而网上以及各种Javascript书籍里面对Closure这个概念的定义有各种说法.我本人觉得很多地方对Clos ...

  9. docker容器修改时区(java应用log信息与标准容器时间有八个小时时间差)

    在docker容器中运行的java应用打出的日志时间和通过date -R方式获取的容器标准时间有八个小时时间差- 因为docker容器的原生时区为0时区,为了和国内时区保持一致,需要把容器时区调为东八 ...

  10. Python - Django - 登录页面

    登录页 login.html: <!DOCTYPE html> <html lang="zh-CN"> <head> <meta char ...