keras 入门 --手写数字识别
2017-11-20 22:37
302 查看
深度学习keras库中的helloworld:
#
#搭建一个简单的全连接神经网络,用于手写数字识别
#
from keras.layers import Input,Dense
from keras.models import Model
from keras.datasets import mnist
from keras.utils import np_utils
(X_train,y_train),(X_test,y_test) = mnist.load_data()
X_train = X_train.reshape(X_train.shape[0],784).astype('float32')
X_test = X_test.reshape(X_test.shape[0],784).astype('float32')
y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)
input = Input(shape=(784,))
x = Dense(64, activation='relu')(input)
x = Dense(64, activation='relu')(x)
output = Dense(10, activation='softmax')(x)
model = Model(inputs=input, outputs=output)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(X_train, y_train)
#
#搭建一个简单的全连接神经网络,用于手写数字识别
#
from keras.layers import Input,Dense
from keras.models import Model
from keras.datasets import mnist
from keras.utils import np_utils
(X_train,y_train),(X_test,y_test) = mnist.load_data()
X_train = X_train.reshape(X_train.shape[0],784).astype('float32')
X_test = X_test.reshape(X_test.shape[0],784).astype('float32')
y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)
input = Input(shape=(784,))
x = Dense(64, activation='relu')(input)
x = Dense(64, activation='relu')(x)
output = Dense(10, activation='softmax')(x)
model = Model(inputs=input, outputs=output)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(X_train, y_train)
相关文章推荐
- keras入门实战:手写数字识别
- Keras入门课2 -- 使用CNN识别mnist手写数字
- keras入门 利用卷积神经网络进行手写数字识别
- 基于tensorflow的MNIST手写数字识别(二)--入门篇
- 基于tensorflow的MNIST手写数字识别--入门篇
- 手把手入门神经网络系列(2)_74行代码实现手写数字识别
- 机器学习-实战-入门-MNIST手写数字识别
- Tensorflow高速入门2--实现手写数字识别
- Keras中将LSTM用于mnist手写数字识别
- torch入门笔记4:用torch实现MNIST手写数字识别
- 手把手入门神经网络系列(2)_74行代码实现手写数字识别
- 手把手入门神经网络系列(2)_74行代码实现手写数字识别
- Keras_深度学习_MNIST数据集手写数字识别之各种调参
- 基于tensorflow的MNIST手写数字识别(二)--入门篇
- tensorflow入门实践例子—MNIST手写数字识别
- TensorFlow学习笔记【二】 手写数字识别入门
- 用MXnet入门实战深度学习之一:安装GPU版mxnet并跑一个MNIST手写数字识别
- 用MXnet入门实战深度学习之一:安装GPU版mxnet并跑一个MNIST手写数字识别
- tensorflow 入门小例子(mnist手写数字识别)
- 基于机器学习多种方法的kaggle竞赛入门之手写数字的图像识别预测