Coder Social home page Coder Social logo

lbtoolbox's Introduction

Lucas' Python Toolbox

Just a collection of python functions I think I'll need more than once.

The quality varies wildly across functions and I do not intend to make this usable by anyone besides myself in the foreseeable future. You've been warned.

plotting.py

A bunch of matplotlib plots that I seem to use over and over again.

filterbank.py

Create filterbanks as tuples of np.arrays. Available filterbanks:

  • Difference of oriented Gaussians (DooG)

progress.py

IPython interactive progressbar. TODO: update to new interactive widget.

chrono.py

Utility to very simply time things, including parts of loops. Use as follows:

c = Chrono()

for e in range(10):
    with c.measure("transmogrifying"):
        tm = transmogrify(e)
    with c.measure("plotting"):
        plot(tm)

print(c)
print(c.avgtime("plotting"))

nnet*

Layers and other stuff for making neural networks with Theano.

This stuff is still highly in flux while I'm figuring out The Right Way to implement most of this stuff in a as reusable and as orthogonal way as possible.

I will soon add example notebooks and scripts. The following are quick references to get the big picture.

Training a model

Create a model class or use one of those in nnet_models.py, then:

model = MyModel(imshape=(1,28,28), batchsize=1000, npred=10)
model_bgd = lbnn.BatchGradDescent(model)
model_bgd_trainer = lbnn.BGDTrainer(model_bgd)
'{:.3f}M params'.format(lbthutil.count_params(model)/1000000)
model_bgd_trainer.fit(Xtr, ytr, Xva, yva, Xte, yte,
                      lr0=0.01, lr_decrease=2, max_reducs=20, valid_freq=5, test_freq=10,
                      skip_initial=True, skip_final=True)

Creating an augmentation pipeline

Create the pipeline via

aug = lbaug.AugmentationPipeline((32,32), Xtr, ytr,
    lbaug.HorizontalFlipper(),
    lbaug.Rotator(0, 180, 5),
    lbaug.Cropper((28,28))
)

then pass it to the fit function as parameter aug=aug and, if it includes a resizing augmentation, be sure to create the model using aug.outshape() as image-shape, not the original image-shape.

thutil.py

Minor utilities for working with Theano. Currently checks for GPU.

monitor.py

Install nanomsg, then pip install nnpy (needs libffi-dev).

lbtoolbox's People

Contributors

lucasb-eyer 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.