Giter Site home page Giter Site logo

pyfunt's Introduction

PyFunt (/paɪfʊnt/)

Project frozen Project unmaintained

Pythonic Deep Learning Framework (WIP and CPU only) inspired by Torch's Neural Network package.

Requirements

Installation

Get pip and run:

pip install git+git://github.com/dnlcrl/PyFunt.git

Usage

Check the examples folder

Example: Parametric Residual Model

Parametric models can be built easily thanks to the module structure:

from pyfunt import (SpatialConvolution, SpatialBatchNormalization,
                SpatialAveragePooling, Sequential, ReLU, Linear,
                Reshape, LogSoftMax, Padding, Identity, ConcatTable,
                CAddTable)

def residual_layer(n_channels, n_out_channels=None, stride=None):
    n_out_channels = n_out_channels or n_channels
    stride = stride or 1

    convs = Sequential()
    add = convs.add
    add(SpatialConvolution(
	n_channels, n_out_channels, 3, 3, stride, stride, 1, 1))
    add(SpatialBatchNormalization(n_out_channels))
    add(SpatialConvolution(n_out_channels, n_out_channels, 3, 3, 1, 1, 1, 1))
    add(SpatialBatchNormalization(n_out_channels))

    if stride > 1:
	shortcut = Sequential()
	shortcut.add(SpatialAveragePooling(2, 2, stride, stride))
	shortcut.add(Padding(1, (n_out_channels - n_channels)/2, 3))
    else:
	shortcut = Identity()

    res = Sequential()
    res.add(ConcatTable().add(convs).add(shortcut)).add(CAddTable())
    res.add(ReLU(True))
    return res


def resnet(n_size, num_starting_filters, reg):
    nfs = num_starting_filters
    model = Sequential()
    add = model.add
    add(SpatialConvolution(3, nfs, 3, 3, 1, 1, 1, 1))
    add(SpatialBatchNormalization(nfs))
    add(ReLU())

    for i in xrange(1, n_size):
	add(residual_layer(nfs))
    add(residual_layer(nfs, 2*nfs, 2))

    for i in xrange(1, n_size-1):
	add(residual_layer(2*nfs))
    add(residual_layer(2*nfs, 4*nfs, 2))

    for i in xrange(1, n_size-1):
	add(residual_layer(4*nfs))

    add(SpatialAveragePooling(8, 8))
    add(Reshape(nfs*4))
    add(Linear(nfs*4, 10))
    add(LogSoftMax())
    return model

Check the Torch documentation for more informations about the implemented layers (pyfunt is more or less a python port of torch/nn): https://github.com/torch/nn/blob/master/doc/index.md

pyfunt's People

Contributors

dnlcrl avatar

Watchers

 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.