| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

基于Theano的深度学习库:Keras

Keras是一个简约,高度模块化的神经网络库。采用Python / Theano开发。

使用Keras如果你需要一个深度学习库:

  • 可以很容易和快速实现原型(通过总模块化,极简主义,和可扩展性)
  • 同时支持卷积网络(vision)和复发性的网络(序列数据)。以及两者的组合。
  • 无缝地运行在CPU和GPU上。

Guiding principles

  • Modularity. A model is understood as a sequence of standalone, fully-configurable modules that can be plugged together with as little restrictions as possible. In particular, neural layers, cost functions, optimizers, initialization schemes, activation functions and dropout are all standalone modules that you can combine to create new models.

  • Minimalism. Each module should be kept short and simple (<100 lines of code). Every piece of code should be transparent upon first reading. No black magic: it hurts iteration speed and ability to innovate.

  • Easy extensibility. A new feature (a new module, per the above definition, or a new way to combine modules together) are dead simple to add (as new classes/functions), and existing modules provide ample examples.

  • Work with Python. No separate models configuration files in a declarative format (like in Caffe or PyLearn2). Models are described in Python code, which is compact, easier to debug, benefits from syntax highlighting, and most of all, allows for ease of extensibility. See for yourself with the examples below.

示例

Multilayer Perceptron (MLP):

from keras.models import Sequential  from keras.layers.core import Dense, Dropout, Activation  from keras.optimizers import SGD    model = Sequential()  model.add(Dense(20, 64, init='uniform'))  model.add(Activation('tanh'))  model.add(Dropout(0.5))  model.add(Dense(64, 64, init='uniform'))  model.add(Activation('tanh'))  model.add(Dropout(0.5))  model.add(Dense(64, 1, init='uniform'))  model.add(Activation('softmax'))    sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)  model.compile(loss='mean_squared_error', optimizer=sgd)    model.fit(X_train, y_train, nb_epoch=20, batch_size=16)  score = model.evaluate(X_test, y_test, batch_size=16)

Alternative implementation of MLP:

model = Sequential()  model.add(Dense(20, 64, init='uniform', activation='tanh'))  model.add(Dropout(0.5))  model.add(Dense(64, 64, init='uniform', activation='tanh'))  model.add(Dropout(0.5))  model.add(Dense(64, 1, init='uniform', activation='softmax')    sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)  model.compile(loss='mean_squared_error', optimizer=sgd)

项目主页:http://www.open-open.com/lib/view/home/1427618731971

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1427618731971.html
Keras 机器学习