[Python-modules-commits] [python-brainstorm] 01/08: Imported Upstream version 0.5
Daniel Stender
danstender-guest at moszumanska.debian.org
Sun Mar 13 16:12:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
danstender-guest pushed a commit to branch master
in repository python-brainstorm.
commit 99c4696b1fef72329a6ddde3a21239456d6346b2
Author: Daniel Stender <stender at debian.org>
Date: Sun Mar 13 16:38:43 2016 +0100
Imported Upstream version 0.5
---
.travis.yml | 35 +
CONTRIBUTING.rst | 110 +++
HISTORY.rst | 53 ++
LICENSE | 161 ++++
MANIFEST.in | 5 +
Makefile | 70 ++
README.md | 75 ++
brainstorm/__about__.py | 17 +
brainstorm/__init__.py | 25 +
brainstorm/all.py | 19 +
brainstorm/data_iterators.py | 501 ++++++++++++
brainstorm/describable.py | 240 ++++++
brainstorm/handlers/__init__.py | 16 +
brainstorm/handlers/_cpuop.pyx | 309 +++++++
brainstorm/handlers/base_handler.py | 876 ++++++++++++++++++++
brainstorm/handlers/debug_handler.py | 566 +++++++++++++
brainstorm/handlers/numpy_handler.py | 301 +++++++
brainstorm/handlers/pycuda_handler.py | 887 +++++++++++++++++++++
brainstorm/hooks.py | 883 ++++++++++++++++++++
brainstorm/initializers.py | 418 ++++++++++
brainstorm/layers/__init__.py | 29 +
brainstorm/layers/base_layer.py | 226 ++++++
brainstorm/layers/batch_normalization_layer.py | 152 ++++
brainstorm/layers/binomial_cross_entropy_layer.py | 116 +++
brainstorm/layers/clockwork_layer.py | 122 +++
brainstorm/layers/clockwork_lstm_layer.py | 326 ++++++++
brainstorm/layers/convolution_layer_2d.py | 110 +++
brainstorm/layers/deltas_scaling_layer.py | 43 +
brainstorm/layers/dropout_layer.py | 52 ++
brainstorm/layers/elementwise_layer.py | 40 +
brainstorm/layers/fully_connected_layer.py | 78 ++
brainstorm/layers/highway_layer.py | 71 ++
brainstorm/layers/input_layer.py | 47 ++
brainstorm/layers/l1_decay.py | 69 ++
brainstorm/layers/l2_decay.py | 71 ++
brainstorm/layers/loss_layer.py | 58 ++
brainstorm/layers/lstm_layer.py | 278 +++++++
brainstorm/layers/mask_layer.py | 67 ++
brainstorm/layers/merge_layer.py | 57 ++
brainstorm/layers/noop_layer.py | 34 +
brainstorm/layers/pooling_layer_2d.py | 120 +++
brainstorm/layers/recurrent_layer.py | 102 +++
brainstorm/layers/sigmoid_ce_layer.py | 100 +++
brainstorm/layers/softmax_ce_layer.py | 114 +++
brainstorm/layers/squared_difference_layer.py | 67 ++
brainstorm/layers/squared_error_layer.py | 79 ++
brainstorm/optional.py | 54 ++
brainstorm/randomness.py | 111 +++
brainstorm/scorers.py | 110 +++
brainstorm/structure/__init__.py | 8 +
brainstorm/structure/architecture.py | 187 +++++
brainstorm/structure/buffer_structure.py | 297 +++++++
brainstorm/structure/buffer_views.py | 52 ++
brainstorm/structure/buffers.py | 150 ++++
brainstorm/structure/construction.py | 173 ++++
brainstorm/structure/layout.py | 427 ++++++++++
brainstorm/structure/network.py | 566 +++++++++++++
brainstorm/structure/view_references.py | 197 +++++
brainstorm/tests/__init__.py | 3 +
brainstorm/tests/conftest.py | 54 ++
brainstorm/tests/helpers.py | 196 +++++
brainstorm/tests/test_array.py | 63 ++
brainstorm/tests/test_data_iterators.py | 314 ++++++++
brainstorm/tests/test_describable.py | 410 ++++++++++
.../tests/test_finite_differences/__init__.py | 3 +
.../tests/test_finite_differences/test_deltas.py | 113 +++
brainstorm/tests/test_handler_operations.py | 169 ++++
.../tests/test_handlers_against_reference.py | 680 ++++++++++++++++
brainstorm/tests/test_initializers.py | 112 +++
brainstorm/tests/test_integration/__init__.py | 3 +
.../tests/test_integration/test_initialization.py | 138 ++++
brainstorm/tests/test_integration/test_xor.py | 56 ++
brainstorm/tests/test_layers.py | 621 +++++++++++++++
brainstorm/tests/test_network.py | 109 +++
brainstorm/tests/test_randomness.py | 140 ++++
brainstorm/tests/test_schedules.py | 63 ++
brainstorm/tests/test_scorers.py | 74 ++
brainstorm/tests/test_structure/__init__.py | 3 +
.../tests/test_structure/test_architecture.py | 221 +++++
.../tests/test_structure/test_buffer_structure.py | 216 +++++
.../tests/test_structure/test_buffer_view.py | 138 ++++
.../test_structure/test_construction_layer.py | 156 ++++
.../test_structure/test_generate_architecture.py | 140 ++++
brainstorm/tests/test_structure/test_layout.py | 776 ++++++++++++++++++
.../tests/test_structure/test_view_references.py | 169 ++++
brainstorm/tests/test_uniquely_named.py | 116 +++
brainstorm/tests/test_utils.py | 92 +++
brainstorm/tests/test_weight_modifiers.py | 33 +
brainstorm/tests/tools.py | 38 +
brainstorm/tools.py | 648 +++++++++++++++
brainstorm/training/__init__.py | 11 +
brainstorm/training/schedules.py | 146 ++++
brainstorm/training/steppers.py | 145 ++++
brainstorm/training/trainer.py | 191 +++++
brainstorm/training/utils.py | 9 +
brainstorm/utils.py | 222 ++++++
brainstorm/value_modifiers.py | 212 +++++
data/create_cifar10.py | 122 +++
data/create_cifar100.py | 121 +++
data/create_hutter.py | 108 +++
data/create_mnist.py | 97 +++
doc_requirements.txt | 3 +
docs/Makefile | 177 ++++
docs/apidoc.rst | 87 ++
docs/conf.py | 283 +++++++
docs/contributing.rst | 1 +
docs/credits.rst | 16 +
docs/data_format.rst | 88 ++
docs/examples.rst | 3 +
docs/history.rst | 1 +
docs/hooks.rst | 5 +
docs/index.rst | 34 +
docs/installation.rst | 59 ++
docs/internals.rst | 449 +++++++++++
docs/layers.rst | 5 +
docs/make.bat | 242 ++++++
docs/network.rst | 99 +++
docs/quickstart.rst | 8 +
docs/trainer.rst | 5 +
docs/walkthrough.rst | 174 ++++
examples/README.md | 32 +
examples/cifar10_cnn.py | 65 ++
examples/custom_layer.py | 115 +++
examples/hutter_lstm.py | 56 ++
examples/mnist_pi.py | 60 ++
pycuda_requirements.txt | 2 +
requirements.txt | 6 +
setup.cfg | 9 +
setup.py | 133 +++
tox.ini | 51 ++
130 files changed, 20246 insertions(+)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6b8740b
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,35 @@
+# Config file for automatic testing at travis-ci.org
+
+language: python
+
+# Setup anaconda
+before_install:
+ - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
+ - chmod +x miniconda.sh
+ - ./miniconda.sh -b
+ - export PATH=/home/travis/miniconda/bin:$PATH
+ - conda update --yes conda
+# Install packages
+install:
+ - conda install --yes python=$TRAVIS_PYTHON_VERSION numpy
+ - pip install wheel six mock pytest pytest-pep8
+
+# Run test
+script:
+ - py.test $PYTEST_ARGS brainstorm
+
+matrix:
+ include:
+ - python: "2.7"
+ env: PYTEST_ARGS=
+ - python: "3.3"
+ env: PYTEST_ARGS=
+ - python: "3.4"
+ env: PYTEST_ARGS=
+ - python: "2.7"
+ env: PYTEST_ARGS="--pep8 -m pep8"
+
+branches:
+ only:
+ - master
+ - /^release.*$/
\ No newline at end of file
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..8755c87
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,110 @@
+============
+Contributing
+============
+
+Contributions are welcome, and they are greatly appreciated! Every
+little bit helps, and credit will always be given.
+
+You can contribute in many ways:
+
+Types of Contributions
+----------------------
+
+Report Bugs
+~~~~~~~~~~~
+
+Report bugs at https://github.com/IDSIA/brainstorm/issues.
+
+If you are reporting a bug, please include:
+
+* Your operating system name and version.
+* Any details about your local setup that might be helpful in troubleshooting.
+* Detailed steps to reproduce the bug.
+
+Fix Bugs
+~~~~~~~~
+
+Look through the GitHub issues for bugs. Anything tagged with "bug"
+is open to whoever wants to implement it.
+
+Implement Features
+~~~~~~~~~~~~~~~~~~
+
+Look through the GitHub issues for features. Anything tagged with "feature"
+is open to whoever wants to implement it.
+
+Write Documentation
+~~~~~~~~~~~~~~~~~~~
+
+brainstorm could always use more documentation, whether as part of the
+official brainstorm docs, in docstrings, or even on the web in blog posts,
+articles, and such.
+
+Submit Feedback
+~~~~~~~~~~~~~~~
+
+The best way to send feedback is to file an issue at https://github.com/IDSIA/brainstorm/issues.
+
+If you are proposing a feature:
+
+* Explain in detail how it would work.
+* Keep the scope as narrow as possible, to make it easier to implement.
+* Remember that this is a volunteer-driven project, and that contributions
+ are welcome :)
+
+Get Started!
+------------
+
+Ready to contribute? Here's how to set up `brainstorm` for
+local development.
+
+1. Fork_ the `brainstorm` repo on GitHub.
+2. Clone your fork locally::
+
+ $ git clone git at github.com:your_name_here/brainstorm.git
+
+3. Create a branch for local development::
+
+ $ git checkout -b name-of-your-bugfix-or-feature
+
+Now you can make your changes locally.
+
+4. When you're done making changes, check that your changes pass style and unit
+ tests, including testing other Python versions with tox::
+
+ $ tox
+
+To get tox, just pip install it.
+
+5. Commit your changes and push your branch to GitHub::
+
+ $ git add .
+ $ git commit -m "Your detailed description of your changes."
+ $ git push origin name-of-your-bugfix-or-feature
+
+6. Submit a pull request through the GitHub website.
+
+.. _Fork: https://github.com/IDSIA/brainstorm/fork
+
+Pull Request Guidelines
+-----------------------
+
+Before you submit a pull request, check that it meets these guidelines:
+
+1. The pull request should include tests.
+2. If the pull request adds functionality, the docs should be updated. Put
+ your new functionality into a function with a docstring, and add the
+ feature to the list in README.rst.
+3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy.
+ Check https://travis-ci.org/IDSIA/brainstorm
+ under pull requests for active pull requests or run the ``tox`` command and
+ make sure that the tests pass for all supported Python versions.
+
+
+Tips
+----
+
+To run a subset of tests::
+
+ $ py.test test/test_brainstorm.py
+
diff --git a/HISTORY.rst b/HISTORY.rst
new file mode 100644
index 0000000..d3245d8
--- /dev/null
+++ b/HISTORY.rst
@@ -0,0 +1,53 @@
+.. :changelog:
+
+History
+-------
+
+0.5 (2015-12-01)
+++++++++++++++++
+Changed Behaviour
+"""""""""""""""""
+* examples now run on CPU by default
+* added ``brainstorm.tools.shuffle_data`` and ``brainstorm.tools.split`` to help with data preparation
+* ``SigmoidCE`` and ``SquaredDifference`` layers now outputs a loss for each dimension instead of summing over features.
+* ``SquaredDifference`` layer does no longer scale by one half.
+* Added a ``SquaredLoss`` layer that computes half the squared difference and
+ has an interface that is compatible with the ``SigmoidCE`` and ``SigmoidCE`` layers.
+* Output `probabilities` renamed to `predictions` in ``SigmoidCE`` and ``SigmoidCE`` layers.
+
+New Features
+""""""""""""
+* added a `use_conv` option to ``brainstorm.tools.create_net_from_spec``
+* added `criterion` option to ``brainstorm.hooks.EarlyStopper`` hook
+* added ``brainstorm.tools.get_network_info`` function that returns information
+ about the network as a string
+* added ``brainstorm.tools.extract`` function that applies a network to some
+ data and saves a set of requested buffers.
+* ``brainstorm.layers.mask`` layer now supports masking individual features
+* added ``brainstorm.hooks.StopAfterThresholdReached`` hook
+
+Improvements
+""""""""""""
+* EarlyStopper now works for any timescale and interval
+* Recurrent, Lstm, Clockwork, and ClockworkLstm layers now accept inputs of
+ arbitrary shape by implicitly flattening them.
+* several fixes to make building the docs easier
+* some performance improvements of NumpyHandler operations ``binarize_t`` and ``index_m_by_v``
+* sped up tests
+* several improvements to installation scripts
+
+Bugfixes
+""""""""
+* fixed `sqrt` operation for ``PyCudaHandler``. This should fix problems with BatchNormalization on GPU.
+* fixed a bug for task_type='regression' in ``brainstorm.tools.get_in_out_layers``
+ and ``brainstorm.tools.create_net_from_spec``
+* removed defunct name argument from input layer
+* fixed a crash when applying ``brainstorm.hooks.SaveBestNetwork`` to `rolling_training` loss
+* various minor fixes of the ``brainstorm.hooks.BokehVisualizer``
+* fixed a problem with ``sum_t`` operation in ``brainstorm.handlers.PyCudaHandler``
+* fixed a blocksize problem in convolutional and pooling operations in ``brainstorm.handlers.PyCudaHandler``
+
+
+0.5b0 (2015-10-25)
+++++++++++++++++++
+* First release on PyPI.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..86093d7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,161 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 IDSIA and various contributors
+Contributors retain copyright over their contributions to Brainstorm,
+as reflected by the git history of the project.
+
+Brainstorm contains some code from other open source projects:
+Cudarray: MIT License
+Caffe2: MIT License (including some BSD-licenced Caffe code)
+See their respective licenses below the line.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+===============================================================================
+
+Brainstorm contains some code modified from the Cudarray library.
+The Cudarray license is reproduced below:
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Anders Boesen Lindbo Larsen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+===============================================================================
+
+Brainstorm contains some code modified from the Caffe2 library.
+The Caffe2 license is reproduced below:
+
+COPYRIGHT
+
+All contributions by Google:
+Copyright (c) 2015 Google Inc.
+All rights reserved.
+
+All contributions by Yangqing Jia:
+Copyright (c) 2015 Yangqing Jia
+All rights reserved.
+
+All contributions from Caffe:
+Copyright(c) 2013, 2014, 2015, the respective contributors
+All rights reserved.
+
+All other contributions:
+Copyright(c) 2015, the respective contributors
+All rights reserved.
+
+Caffe2 uses a copyright model similar to Caffe: each contributor holds
+copyright over their contributions to Caffe2. The project versioning records
+all such contribution and copyright details. If a contributor wants to further
+mark their specific copyright on a particular contribution, they should
+indicate their copyright solely in the commit message of the change when it is
+committed.
+
+== LICENSE ==
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+== DECLARATION ==
+
+Some parts of the caffe2 code is derived from the original Caffe code, which is
+created by Yangqing Jia and is now a BSD-licensed open-source project. The Caffe
+license is as follows:
+
+*** begin Caffe license ***
+COPYRIGHT
+
+All contributions by the University of California:
+Copyright (c) 2014, The Regents of the University of California (Regents)
+All rights reserved.
+
+All other contributions:
+Copyright (c) 2014, the respective contributors
+All rights reserved.
+
+Caffe uses a shared copyright model: each contributor holds copyright over
+their contributions to Caffe. The project versioning records all such
+contribution and copyright details. If a contributor wants to further mark
+their specific copyright on a particular contribution, they should indicate
+their copyright solely in the commit message of the change when it is
+committed.
+
+LICENSE
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+CONTRIBUTION AGREEMENT
+
+By contributing to the BVLC/caffe repository through pull-request, comment,
+or otherwise, the contributor releases their content to the
+license and copyright terms herein.
+*** end Caffe license ***
+
+===============================================================================
\ No newline at end of file
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..dc995e3
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include CONTRIBUTING.rst
+include HISTORY.rst
+include LICENSE
+include README.md
+recursive-include brainstorm *.c *.h *.pyx
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c44ab2b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,70 @@
+.PHONY: help clean clean-pyc clean-build clean-test clean-docs lint test \
+ test-all coverage docs release dist
+
+help:
+ @echo "clean - remove all build, doc, test, coverage and Python artifacts"
+ @echo "clean-build - remove build artifacts"
+ @echo "clean-pyc - remove Python file artifacts"
+ @echo "clean-test - remove test and coverage artifacts"
+ @echo "clean-doc - remove documentation artifacts"
+ @echo "lint - check style with flake8"
+ @echo "test - run tests quickly with the default Python"
+ @echo "test-all - run tests on every Python version with tox"
+ @echo "coverage - check code coverage quickly with the default Python"
+ @echo "docs - generate Sphinx HTML documentation, including API docs"
+ @echo "release - package and upload a release"
+ @echo "dist - package"
+
+clean: clean-build clean-pyc clean-test clean-docs
+
+clean-build:
+ rm -fr build/
+ rm -fr dist/
+ rm -fr *.egg-info
+
+clean-pyc:
+ find . -name '*.pyc' -exec rm -f {} +
+ find . -name '*.pyo' -exec rm -f {} +
+ find . -name '*~' -exec rm -f {} +
+ find . -name '__pycache__' -exec rm -fr {} +
+
+clean-test:
+ rm -fr .tox/
+ rm -f .coverage
+ rm -fr htmlcov/
+ rm -fr .cache/
+
+clean-docs:
+ $(MAKE) -C docs clean
+
+lint:
+ flake8 brainstorm
+
+test: clean-pyc clean-test
+ python setup.py test
+
+test-all: clean-pyc
+ tox
+
+coverage: clean-pyc
+ coverage run --source brainstorm setup.py test
+ coverage report -m
+ coverage html
+ xdg-open htmlcov/index.html
+
+docs:
+ $(MAKE) -C docs clean
+ python setup.py build_ext --inplace
+ $(MAKE) -C docs html
+ xdg-open docs/_build/html/index.html
+
+release: clean
+ python setup.py build_ext --inplace
+ python setup.py sdist upload
+ python setup.py bdist_wheel upload
+
+dist: clean
+ python setup.py build_ext --inplace
+ python setup.py sdist
+ python setup.py bdist_wheel
+ ls -l dist
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5fbd0aa
--- /dev/null
+++ b/README.md
@@ -0,0 +1,75 @@
+Brainstorm
+==========
+
+[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat-square)](http://brainstorm.readthedocs.org/en/latest)
+[![PyPi Version](https://img.shields.io/pypi/v/brainstorm.svg?style=flat-square)](https://pypi.python.org/pypi/brainstorm)
+[![MIT license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](http://choosealicense.com/licenses/mit)
+![Python Versions](https://img.shields.io/pypi/pyversions/brainstorm.svg?style=flat-square)
+
+Brainstorm makes working with neural networks fast, flexible and fun.
+
+Combining lessons from previous projects with new design elements, and written entirely in Python, Brainstorm has been designed to work on multiple platforms with multiple computing backends.
+
+
+Getting Started
+---------------
+A good point to start is the brief [walkthrough](https://brainstorm.readthedocs.org/en/latest/walkthrough.html) of the ``cifar10_cnn.py`` example.
+More documentation is in progress, and hosted on [ReadTheDocs](https://brainstorm.readthedocs.org/en/latest/).
+If you wish, you can also run the data preparation scripts (``data`` directory) and look at some basic examples (``examples`` directory).
+
+Status
+------
+Brainstorm is under active development and is currently in beta.
+
+The currently available feature set includes recurrent (simple, LSTM, Clockwork), 2D convolution/pooling, Highway and batch normalization layers. API documentation is fairly complete and we are currently working on tutorials and usage guides.
+
+Brainstorm abstracts computations via *handlers* with a consistent API. Currently, two handlers are provided: `NumpyHandler` for computations on the CPU (through Numpy/Cython) and `PyCudaHandler` for the GPU (through PyCUDA and scikit-cuda).
+
+Installation
+------------
+Here are some quick instructions for installing the latest master branch on Ubuntu.
+
+```bash
+# Install pre-requisites
+sudo apt-get update
+sudo apt-get install python-dev libhdf5-dev git python-pip
+# Get brainstorm
+git clone https://github.com/IDSIA/brainstorm
+# Install
+cd brainstorm
+[sudo] pip install -r requirements.txt
+[sudo] python setup.py install
+# Build local documentation (optional)
+sudo apt-get install python-sphinx
+make docs
+# Install visualization dependencies (optional)
+sudo apt-get install graphviz libgraphviz-dev pkg-config
+[sudo] pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"
+```
+To use your CUDA installation with brainstorm:
+```bash
+$ [sudo] pip install -r pycuda_requirements.txt
+```
+Set location for storing datasets:
+```bash
+echo "export BRAINSTORM_DATA_DIR=/home/my_data_dir/" >> ~/.bashrc
+```
+
+Help and Support
+----------------
+
+If you have any suggestions or questions, please post to the [Google group](https://groups.google.com/forum/#!forum/mailstorm).
+
+If you encounter any errors or problems, please let us know by opening an issue.
+
+License
+-------
+
+MIT License. Please see the LICENSE file.
+
+Acknowledgements
+----------------
+
+Klaus Greff and Rupesh Srivastava would like to thank Jürgen Schmidhuber for his continuous supervision and encouragement.
+Funding from EU projects NASCENCE (FP7-ICT-317662) and WAY (FP7-ICT-288551) was instrumental during the development of this project.
+We also thank Nvidia Corporation for their donation of GPUs.
diff --git a/brainstorm/__about__.py b/brainstorm/__about__.py
new file mode 100644
index 0000000..b542079
--- /dev/null
+++ b/brainstorm/__about__.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# coding=utf-8
+"""
+This module contains meta-information about the brainstorm package.
+
+It is kept simple and separate from the main module, because this information
+is also read by the setup.py. And during installation the brainstorm module
+might not be importable yet.
+"""
+from __future__ import division, print_function, unicode_literals
+
+__all__ = ("__version__", "__author__", "__url__", "__license__")
+
+__version__ = "0.5"
+__author__ = "The Swiss AI Lab IDSIA"
+__url__ = "https://github.com/IDSIA/brainstorm"
+__license__ = "MIT"
diff --git a/brainstorm/__init__.py b/brainstorm/__init__.py
new file mode 100644
index 0000000..e010d35
--- /dev/null
+++ b/brainstorm/__init__.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# coding=utf-8
+from __future__ import division, print_function, unicode_literals
+from brainstorm.describable import get_description, create_from_description
+from brainstorm.randomness import global_rnd
+from brainstorm.structure import Network, generate_architecture
+from brainstorm.training import Trainer
+
+from brainstorm import initializers
+from brainstorm import data_iterators
+from brainstorm import value_modifiers
+from brainstorm import tools
+from brainstorm import hooks
+from brainstorm import layers
+from brainstorm import handlers
+from brainstorm import training
+from brainstorm import scorers
+from brainstorm.__about__ import __version__
+
+
+__all__ = ['get_description', 'create_from_description', 'global_rnd',
+ 'Network', 'generate_architecture', 'Trainer',
+ 'initializers', 'data_iterators', 'value_modifiers', 'tools',
+ 'hooks', 'layers', 'handlers', 'training', 'scorers',
+ '__version__']
diff --git a/brainstorm/all.py b/brainstorm/all.py
new file mode 100644
index 0000000..7957e54
--- /dev/null
+++ b/brainstorm/all.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+# coding=utf-8
+"""
+Convenience namespace containing all relevant brainstorm objects and functions.
+"""
+from __future__ import division, print_function, unicode_literals
+
+from brainstorm.data_iterators import *
+from brainstorm.describable import create_from_description, get_description
+from brainstorm.handlers import *
+from brainstorm.hooks import *
+from brainstorm.initializers import *
+from brainstorm.layers import *
+from brainstorm.randomness import global_rnd
+from brainstorm.structure import Network, generate_architecture
+from brainstorm.scorers import *
+from brainstorm.tools import *
+from brainstorm.training import *
+from brainstorm.value_modifiers import *
diff --git a/brainstorm/data_iterators.py b/brainstorm/data_iterators.py
new file mode 100644
index 0000000..63aaaaa
--- /dev/null
+++ b/brainstorm/data_iterators.py
@@ -0,0 +1,501 @@
+#!/usr/bin/env python
+# coding=utf-8
+from __future__ import division, print_function, unicode_literals
+
+import math
+
+import numpy as np
+import six
+from brainstorm.handlers._cpuop import _crop_images
+from brainstorm.randomness import Seedable
+from brainstorm.utils import IteratorValidationError
+
+
+class DataIterator(Seedable):
+ """Base class for Data Iterators.
+
+ Attributes:
+ data_shapes (dict[str, tuple[int]]):
+ List of input names that this iterator provides.
+ length (int | None):
+ Number of iterations that this iterator will run.
+ """
+
+ def __init__(self, data_shapes, length):
+ """
+ Args:
+ data_shapes (dict[str, tuple[int]]):
+ List of input names that this iterator provides.
+ length (int | None):
+ Number of iterations that this iterator will run.
+ """
+ super(DataIterator, self).__init__()
+ self.data_shapes = data_shapes
+ self.length = length
+
+ def __call__(self, handler):
+ pass
+
+
+class AddGaussianNoise(DataIterator):
+ """
+ Adds Gaussian noise to data generated by another iterator, which must
+ provide named data items (such as Online, Minibatches, Undivided). Only
+ Numpy data is supported,
+
+ Supports usage of different means and standard deviations for different
+ named data items.
+ """
+
+ def __init__(self, iter, std_dict, mean_dict=None):
+ """
+ Args:
+ iter (DataIterator):
+ Any DataIterator which iterates over data that noise should be
+ added to.
+ std_dict (dict[str, float]):
+ Specifies the standard deviation of the noise that should be
+ added for some of the named data items.
+ mean_dict (Optional(dict[str, float])):
+ Specifies the mean of the gaussian noise that should be
+ added for some of the named data items.
+ Defaults to None meaning all means are treated as 0.
+ """
+ DataIterator.__init__(self, iter.data_shapes, iter.length)
+ mean_keys = set(mean_dict.keys()) if mean_dict is not None else set()
+ std_keys = set(std_dict.keys())
+ if mean_dict is not None and mean_keys != std_keys:
+ raise IteratorValidationError(
+ "means and standard deviations must be provided for the same "
+ "data names. But {} != {}".format(mean_keys, std_keys))
+ for key in std_keys:
+ if key not in iter.data_shapes:
+ raise IteratorValidationError(
+ "key {} is not present in iterator. Available keys: {"
+ "}".format(key, iter.data_shapes.keys()))
+
+ self.mean_dict = {} if mean_dict is None else mean_dict
+ self.std_dict = std_dict
+ self.iter = iter
+
+ def __call__(self, handler=None):
+ for data in self.iter(handler):
+ for key, std in self.std_dict.items():
+ mean = self.mean_dict.get(key, 0.0)
+ data[key] = data[key] + std * self.rnd.standard_normal(
+ data[key].shape) + mean
+ yield data
+
+
+class AddSaltNPepper(DataIterator):
+ """
+ Adds Salt&Pepper noise to data generated by another iterator, which must
+ provide named data items (such as Online, Minibatches, Undivided). Only
+ Numpy data is supported,
+
+ Supports usage of different amounts and ratios of salt VS pepper for
+ different named data items.
+ """
+
+ def __init__(self, iter, prob_dict, ratio_dict=None):
+ """
+ Args:
+ iter (DataIterator):
+ Any DataIterator which iterates over data that noise should be
+ added to.
+ prob_dict (dict[str, float]):
+ Specifies the probability that an input is affected for some of
+ the named data items. Omitted data items are treated as having
+ an amount of 0.
+ ratio_dict (Optional(dict[str, float])):
+ Specifies the ratio of salt of all corrupted inputs.
+ Defaults to None meaning the ratio is treated as 0.5.
+ """
+ DataIterator.__init__(self, iter.data_shapes, iter.length)
+ ratio_keys = set() if ratio_dict is None else set(ratio_dict.keys())
+ prob_keys = set(prob_dict.keys())
+ if ratio_dict is not None and ratio_keys != prob_keys:
+ raise IteratorValidationError(
+ "probabilities and ratios must be provided for the "
+ "same data names. But {} != {}".format(prob_keys, ratio_keys))
+ for key in prob_keys:
+ if key not in iter.data_shapes:
+ raise IteratorValidationError(
+ "key {} is not present in iterator. Available keys: {"
+ "}".format(key, iter.data_shapes.keys()))
+
+ self.ratio_dict = {} if ratio_dict is None else ratio_dict
+ self.prob_dict = prob_dict
+ self.iter = iter
+
+ def __call__(self, handler=None):
+ for data in self.iter(handler):
+ for key, pr in self.prob_dict.items():
+ ratio = self.ratio_dict.get(key, 0.5)
+ d = data[key].copy()
+ r = self.rnd.rand(*d.shape)
+ d[r >= 1.0 - pr * ratio] = 1.0 # salt
+ d[r <= pr * (1.0 - ratio)] = 0.0 # pepper
+ data[key] = d
+ yield data
+
+
+class Flip(DataIterator):
+ """
+ Randomly flip images horizontally. Images are generated by another
+ iterator, which must provide named data items (such as Online,
+ Minibatches, Undivided). Only 5D Numpy data in TNHWC format is supported.
+
+ Defaults to flipping the 'default' named data item with a probability
+ of 0.5. Note that the last dimension is flipped, which typically
+ corresponds to flipping images horizontally.
+ """
+
+ def __init__(self, iter, prob_dict=None):
+ """
+ Args:
+ iter (DataIterator):
+ Any DataIterator which iterates over data to be flipped.
+ prob_dict (dict[str, float]):
+ Specifies the probability of flipping for some named
+ data items.
+ """
+ Seedable.__init__(self)
+ super(Flip, self).__init__(iter.data_shapes, iter.length)
+ prob_dict = {'default': 0.5} if prob_dict is None else prob_dict
+ for key in prob_dict.keys():
+ if key not in iter.data_shapes:
+ raise IteratorValidationError(
+ "key {} is not present in iterator. Available keys: {"
+ "}".format(key, iter.data_shapes.keys()))
+ if prob_dict[key] > 1.0 or prob_dict[key] < 0.0:
+ raise IteratorValidationError("Invalid probability")
+ if len(iter.data_shapes[key]) != 5:
+ raise IteratorValidationError("Only 5D data is supported")
+ self.prob_dict = prob_dict
+ self.iter = iter
+
+ def __call__(self, handler=None):
+ for data in self.iter(handler):
+ for name in self.prob_dict.keys():
+ assert isinstance(data[name], np.ndarray)
+ for i in range(data[name].shape[1]):
+ if self.rnd.random_sample() < self.prob_dict[name]:
+ data[name][:, i, ...] = data[name][:, i, :, ::-1, :]
+ yield data
+
+
+class OneHot(DataIterator):
+
+ """
+ Convert data to one hot vectors, according to provided vocabulary sizes.
+ If vocabulary size is not provided for some data item, it is yielded as is.
+
+ Currently this iterator only supports 3D data where the last (right-most)
+ dimension is sized 1.
+ """
+
+ def __init__(self, iter, vocab_size_dict):
+ """
+ Args:
+ iter (DataIterator):
+ DataIterator which iterates over the indices to be converted to
+ one hot.
+ vocab_size_dict (dict[str, int]):
+ Specifies the size of one hot vectors (the vocabulary size)
+ for some named data items.
+ """
+ DataIterator.__init__(self, iter.data_shapes, iter.length)
+ for key in vocab_size_dict.keys():
+ if key not in iter.data_shapes:
+ raise IteratorValidationError(
+ "key {} is not present in iterator. Available keys: {"
+ "}".format(key, iter.data_shapes.keys()))
+ if not isinstance(vocab_size_dict[key], int):
+ raise IteratorValidationError("Vocabulary size must be int")
+ shape = iter.data_shapes[key]
+ if not (shape[-1] == 1 and len(shape) == 3):
+ raise IteratorValidationError("Only 3D data is supported")
+ self.vocab_size_dict = vocab_size_dict
+ self.iter = iter
+
+ def __call__(self, handler=None):
+ for data in self.iter(handler):
+ for name in self.vocab_size_dict.keys():
... 20175 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-brainstorm.git
More information about the Python-modules-commits
mailing list