My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
OfflineNetworkTraining  
The initial network weights are calculated by ffnet
Updated Feb 4, 2010 by paulrei...@gmail.com

Introduction

The ffnet Python module is a simple API wrapping neural network training algorithms written in Fortran (wrapped with f2py). This yields competitive performance for training large networks, and allows multiple training methods to be used on the same neural net.

After importing a neural network from a previous training session, ffnet can train the network using forward-prop, back-prop, TNC, genetic algorithms, and other fast gradient descent techniques. The following code snippet shows importing weights from an intermediate results cache for each DisCo job, initially training the network with a two-part genetic algorithm, and completing the training with TNC-based method.

Using the cache for offline ffnet raining

import cPickle as pickle

net = pickle.loads(memc.get('nn_default/weights'))

# Read data file
imgs, labels = read_mnist_dir('../datasets')

lim = len(imgs)/10

imgs = imgs.reshape((len(imgs), imgs[0].size))
nominal_labels = numpy.zeros((len(labels), 10))

# Convert labels (i.e. 2 -> [0, 0, 1, 0, ..])
for i,label in enumerate(labels):
  nominal_labels[i][label] = 1

# Genetic Training
net.train_genetic(imgs[:lim], nominal_labels[:lim], individuals=20, generations=500)

# TNC training
net.train_tnc(imgs[:lim], nominal_labels[:lim], maxfun = 2000, messages=1)

# Store improved weights back into the cache
memc.set('nn_default/weights', pickle.dumps(net))

Here the cPickle Python module is used to quickly serialize and deserialize a neural net into a memcached cluster.

Powered by Google Project Hosting