Git Product home page Git Product logo

theanodl's Introduction

image

Deep Learning Library based on Theano

Design Philosophy

Totally speaking, in every task, _the operation flow/process is unchanged_ and _the only changing thing is just the specific operation in each operation_. (业务流程是不变的,变化的只是 具体的业务。)

Every artificial intelligence(AI) task involves four components: Model, Data, Execution and Evaluation.

The process of AI task is as follows:

So, by extracting the unchanged process, we got our deep learning framework.

Thdl framework contains four modules:

  • data: for processing AND providing data;
  • model: for building neural models;
  • exeval: for executing and evaluating models using provided data;
  • task: for building a task.

Features

  • Support commonly used models, including convnets, RNNs and LSTMS.
  • Support visualization of evaluation results.

Documentation

Preparing.

Requirements

  • Python3
  • Theano >= 0.9
  • scipy
  • Numpy
  • Matplotlib
  • xlwt
  • nltk

Example

from thdl.data import text_classification as corpus
from thdl import model
from thdl.exeval import ClassifyExeEval
from thdl.task import ClassificationTask


# data
data_getter = corpus.SentenceGetter('./files/handled/trec.data')
data_processor = corpus.SentenceProcessor()
data_module = corpus.SentenceProvider(shuffle=True)
data_module.set_getter(data_getter)
data_module.set_processor(data_processor)
data_module.build()

# model
model_module = model.Model()
model_module.set_input_tensor(model.tensors.imatrix())
model_module.add_layer(model.layers.Embedding(data_module.get_embedding()))
model_module.add_layer(model.layers.Dropout(0.5))
model_module.add_layer(model.layers.LSTM(n_out=200))
model_module.add_layer(model.layers.Mean(axis=1))
model_module.add_layer(model.layers.Softmax(n_out=len(data_module.index_to_tag)))
model_module.set_output_tensor(model.tensors.fmatrix())
model_module.set_objective(model.objective.CategoricalCrossEntropy())
model_module.set_optimizer(model.optimizer.Adam(learning_rate=0.0001))
model_module.set_metrics([model.metrics.CategoricalAccuracy(),
                          model.metrics.Loss()],
                         model.metrics.Regularizer())
model_module.build()

# execution and evaluation
exeval_module = ClassifyExeEval(batch_size=50)
exeval_module.set_aspects('training', 'valid', 'test')

# task
task = ClassificationTask()
task.set_model(model_module)
task.set_data(data_module)
task.set_exeval(exeval_module)
task.set_logfile("temp.log")
task.hold_out_validation()

theanodl's People

Contributors

oujago avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.