Keras 多层感知机 多类别的 softmax 分类模型代码
来源:互联网 发布:淘宝客服售前流程表 编辑:程序博客网 时间:2024/06/05 16:31
Multilayer Perceptron (MLP) for multi-class softmax classification:
from keras.models import Sequentialfrom keras.layers import Dense, Dropout, Activationfrom keras.optimizers import SGD# 生成随机数据import numpy as npx_train = np.random.random((1000, 20))y_train = keras.utils.to_categorical(np.random.randint(10, size=(1000, 1)), num_classes=10)x_test = np.random.random((100, 20))y_test = keras.utils.to_categorical(np.random.randint(10, size=(100, 1)), num_classes=10)model = Sequential()# Dense(64) is a fully-connected layer with 64 hidden units.# in the first layer, you must specify the expected input data shape:# here, 20-dimensional vectors.model.add(Dense(64, activation='relu', input_dim=20))model.add(Dropout(0.5))model.add(Dense(64, activation='relu'))model.add(Dropout(0.5))model.add(Dense(10, activation='softmax'))sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])model.fit(x_train, y_train, epochs=20, batch_size=128)score = model.evaluate(x_test, y_test, batch_size=128)
https://keras.io/getting-started/sequential-model-guide/
更多教程:http://www.tensorflownews.com/
阅读全文
0 0
- Keras 多层感知机 多类别的 softmax 分类模型代码
- 【Keras】MLP多层感知机
- Keras简单实现多层感知机(MLP)代码
- 基于tensortflow的多层感知机模型
- 利用Keras实现多层感知器(MLP)模型和卷积神经网络(CNN)模型并对手写数字图像分类
- 图像的线性分类器(感知机、SVM、Softmax)
- 多层感知机模型在mnist上的例子
- tensorflow 多层感知机 分类mnist
- Keras学习笔记(2)——多层感知机
- softmax的多分类
- 多层感知器的数据分类的过程
- 多层感知器模型(MLP)
- 多层感知器python代码(简单的多层感知器)
- 基于TensorFlow的多层感知机
- 【机器学习】多层感知机的理解
- TensorFlow上实现MLP多层感知机模型
- 神经网络_多层感知机MLP_以mnist为例(tensorflow和keras实现)
- MLP多层感知机
- springmvc的.DispatcherServlet.doDispatch方法解析
- Ubuntu14.04下Anconda3方式快速安装Tensorflow1.2
- Kibana5数据探索使用(Discover功能)
- runtime 深度学习
- 社交系统ThinkSNS V4.5.29 APP更新发布,新增用户认证及系统消息
- Keras 多层感知机 多类别的 softmax 分类模型代码
- android 代码调用代理设置
- python 随笔
- Oracle 数据库 聊天室项目
- Windows管理多个java版本--解决'has value '1.8',but'1.7' is required'的方法
- H.264 NALU语法结构
- Scratch儿童项目式编程--接球游戏 Scratch children program programming
- 系统管理员应该知道的20条Linux命令
- css3 rem为单位