Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Working version of the deepy backend (for dense MLPs) using the new…
Browse files Browse the repository at this point in the history
… architecture.
  • Loading branch information
alexjc committed Jun 12, 2015
1 parent e16f591 commit 4d95abe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 11 additions & 0 deletions sknn/backend/base.py
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, unicode_literals, print_function)


class BackendBase(object):

def __init__(self, spec):
self.spec = spec

def __getattr__(self, key):
return getattr(self.spec, key)
9 changes: 5 additions & 4 deletions sknn/backend/deepy/mlp.py
Expand Up @@ -26,16 +26,17 @@
from deepy.trainers import MomentumTrainer, LearningRateAnnealer

from ...nn import Layer, Convolution, ansi
from ...nn import NeuralNetwork
from ..base import BackendBase


class MultiLayerPerceptron(NeuralNetwork):
class MultiLayerPerceptron(BackendBase):
"""
Abstract base class for wrapping the multi-layer perceptron functionality
from ``deepy``.
"""

def _setup(self):
def __init__(self, spec):
super(MultiLayerPerceptron, self).__init__(spec)
self.iterations = 0
self.trainer = None
self.mlp = None
Expand Down Expand Up @@ -95,7 +96,7 @@ def _create_mlp(self):
model.stack_layer(Softmax())
self.mlp = model

def _initialize(self, X, y=None):
def _initialize_impl(self, X, y=None):
assert not self.is_initialized,\
"This neural network has already been initialized."
self._create_specs(X, y)
Expand Down
8 changes: 2 additions & 6 deletions sknn/backend/pylearn2/nn.py
Expand Up @@ -16,14 +16,10 @@
from .pywrap2 import learning_rule as lr, termination_criteria as tc
from .dataset import SparseDesignMatrix, FastVectorSpace

from ..base import BackendBase

class NeuralNetwork(object):

def __init__(self, spec):
self.spec = spec

def __getattr__(self, key):
return getattr(self.spec, key)
class NeuralNetwork(BackendBase):

def _create_input_space(self, X):
if self.is_convolution:
Expand Down

0 comments on commit 4d95abe

Please sign in to comment.