Skip to content

Commit

Permalink
Merge pull request #109 from bartvm/move_examples
Browse files Browse the repository at this point in the history
Move examples to separate folder
  • Loading branch information
bartvm committed Jan 17, 2015
2 parents 32e9554 + f4901e7 commit 856c5de
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 28 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

1 change: 0 additions & 1 deletion blocks/bricks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ def lazy(func):
Examples
--------
>>> from __future__ import print_function
>>> class SomeBrick(Brick):
... @lazy
... def __init__(self, a, b, c='c', d=None):
Expand Down
1 change: 0 additions & 1 deletion blocks/extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
from abc import ABCMeta, abstractmethod

from six import add_metaclass
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions blocks/pylearn2/__init__.py → blocks/pylearn2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
training and monitoring to Pylearn2.
"""
from __future__ import absolute_import

import logging
from collections import OrderedDict

Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions blocks/examples/mnist/train.py → examples/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from theano import tensor

from blocks.datasets import DataStream
from blocks.datasets.mnist import MNIST
from blocks.datasets.schemes import SequentialScheme
from blocks.algorithms import GradientDescent, SteepestDescent
from blocks.bricks import MLP, Tanh, Identity
from blocks.bricks.cost import CategoricalCrossEntropy
from blocks.main_loop import MainLoop
from blocks.datasets import DataStream
from blocks.datasets.mnist import MNIST
from blocks.datasets.schemes import SequentialScheme
from blocks.extensions import FinishAfter, Printing
from blocks.main_loop import MainLoop


def main():
Expand Down
File renamed without changes.
File renamed without changes.
Empty file removed tests/examples/__init__.py
Empty file.
Empty file removed tests/examples/mnist/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions tests/examples/mnist/test_train.py

This file was deleted.

Empty file removed tests/pylearn2/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import logging
import os

import pylearn2

import blocks
from examples.mnist import main as mnist_test
from examples.pylearn2.markov_chain import main as pylearn2_test


def setup():
# Silence Pylearn2's logger
logger = logging.getLogger(pylearn2.__name__)
logger.setLevel(logging.ERROR)

# Silence Block's logger
logger = logging.getLogger(blocks.__name__)
logger.setLevel(logging.ERROR)


def test_mnist():
mnist_test()

test_mnist.setup = setup


def test_pylearn2():
filename = 'unittest_markov_chain'
pylearn2_test('train', filename, 0, 3, False)
os.remove(filename)

test_pylearn2.setup = setup
12 changes: 0 additions & 12 deletions tests/pylearn2/test_pylearn2.py → tests/test_pylearn2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os

import numpy
import pylearn2
Expand All @@ -11,7 +10,6 @@
from blocks.bricks.cost import SquaredError
from blocks.initialization import IsotropicGaussian, Constant
from blocks.pylearn2 import Pylearn2Model, Pylearn2Cost, Pylearn2Train
from blocks.pylearn2.examples.markov_chain import main


def test_pylearn2_training():
Expand Down Expand Up @@ -39,13 +37,3 @@ def test_pylearn2_training():
monitoring_dataset=valid_dataset)
train = Pylearn2Train(train_dataset, block_model, algorithm=sgd)
train.main_loop(time_budget=3)


def test_markov_chain():
# Silence Pylearn2's logger
logger = logging.getLogger(pylearn2.__name__)
logger.setLevel(logging.ERROR)

filename = 'unittest_markov_chain'
main('train', filename, 0, 3, False)
os.remove(filename)

0 comments on commit 856c5de

Please sign in to comment.