Giter VIP home page Giter VIP logo

chainer / chainer Goto Github PK

View Code? Open in Web Editor NEW
5.9K 288.0 1.4K 52.47 MB

A flexible framework of neural networks for deep learning

Home Page: https://chainer.org

License: MIT License

Python 76.29% PowerShell 0.09% Batchfile 0.05% Dockerfile 0.07% CMake 0.61% C++ 20.02% C 0.01% Cuda 2.27% Shell 0.59%
deep-learning python neural-networks machine-learning gpu cuda cudnn numpy cupy chainer

chainer's Introduction

Notice: As announced, Chainer is under the maintenance phase and further development will be limited to bug-fixes and maintenance only.


Chainer: A deep learning framework

pypi GitHub license travis coveralls Read the Docs Optuna

Website | Docs | Install Guide | Tutorials (ja) | Examples (Official, External) | Concepts | ChainerX

Forum (en, ja) | Slack invitation (en, ja) | Twitter (en, ja)

Chainer is a Python-based deep learning framework aiming at flexibility. It provides automatic differentiation APIs based on the define-by-run approach (a.k.a. dynamic computational graphs) as well as object-oriented high-level APIs to build and train neural networks. It also supports CUDA/cuDNN using CuPy for high performance training and inference. For more details about Chainer, see the documents and resources listed above and join the community in Forum, Slack, and Twitter.

Installation

For more details, see the installation guide.

To install Chainer, use pip.

$ pip install chainer

To enable CUDA support, CuPy is required. Refer to the CuPy installation guide.

Docker image

We are providing the official Docker image. This image supports nvidia-docker. Login to the environment with the following command, and run the Python interpreter to use Chainer with CUDA and cuDNN support.

$ nvidia-docker run -it chainer/chainer /bin/bash

Contribution

See the contribution guide.

ChainerX

See the ChainerX documentation.

License

MIT License (see LICENSE file).

More information

References

Tokui, Seiya, et al. "Chainer: A Deep Learning Framework for Accelerating the Research Cycle." Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. ACM, 2019. URL BibTex

Tokui, S., Oono, K., Hido, S. and Clayton, J., Chainer: a Next-Generation Open Source Framework for Deep Learning, Proceedings of Workshop on Machine Learning Systems(LearningSys) in The Twenty-ninth Annual Conference on Neural Information Processing Systems (NIPS), (2015) URL, BibTex

Akiba, T., Fukuda, K. and Suzuki, S., ChainerMN: Scalable Distributed Deep Learning Framework, Proceedings of Workshop on ML Systems in The Thirty-first Annual Conference on Neural Information Processing Systems (NIPS), (2017) URL, BibTex

chainer's People

Contributors

aksub99 avatar anaruse avatar asi1024 avatar beam2d avatar crcrpar avatar crissman avatar delta2323 avatar dido1998 avatar fukatani avatar gwtnb avatar hakuyume avatar hvy avatar ivanyashchuk avatar keisuke-umezawa avatar keisukefukuda avatar kmaehashi avatar kshitij12345 avatar mergecat[bot] avatar mergify[bot] avatar mitmul avatar niboshi avatar okuta avatar rezoo avatar sonots avatar takagi avatar toslunar avatar unnonouno avatar wkentaro avatar yoshikawamasashi avatar yuyu2172 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chainer's Issues

Result of numpy.ndarray + Variable is not intuitive

In current implementation, results of following operations are (possibly broadcasted) element addition :

  • Variable + scalar
  • scalar + Variable
  • Variable + numpy.ndarray (as long as Variable.data + numpy.ndarray is valid)

It is natural to suppose numpy.ndarray + Variable works in the same way.
But return value of numpy.ndarray + Variable is numpy.ndarray whose elements are Variable as shown in the following example.

In [75]: aa = Variable(np.random.uniform(0,1,3))
In [76]: b = np.random.uniform(0,1,3)
In [77]: b + aa
Out[77]: 
array([<chainer.variable.Variable object at 0x7f2a5e1384d0>,
       <chainer.variable.Variable object at 0x7f2a5e138710>,
       <chainer.variable.Variable object at 0x7f2a5e138950>], dtype=object)
In [78]: (b + aa)[0].data
Out[78]: array([ 0.90954313,  0.60971617,  1.05675581])

I think it would be better (b+aa).data equals to b + aa.data

Write and run a benchmark

Deep learning framework must have enough performance for fast research and development. In order to decide which framework to use, benchmarks are useful to compare different frameworks before solving heavy learning tasks by oneself.

Support tied weight

It is difficult for current Chainer to construct an architecture whose weights are tied (e.g. autoencoder)

ImportError: No module named decorator

ubgpu@ubgpu:~/github/chainer$ python examples/mnist/train_mnist.py
Traceback (most recent call last):
File "examples/mnist/train_mnist.py", line 10, in
from sklearn.datasets import fetch_mldata
File "/usr/local/lib/python2.7/dist-packages/sklearn/datasets/init.py", line 23, in
from .twenty_newsgroups import fetch_20newsgroups
File "/usr/local/lib/python2.7/dist-packages/sklearn/datasets/twenty_newsgroups.py", line 53, in
from ..feature_extraction.text import CountVectorizer
File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/init.py", line 10, in
from . import text
File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/text.py", line 29, in
from ..preprocessing import normalize
File "/usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/init.py", line 24, in
from .imputation import Imputer
File "/usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/imputation.py", line 9, in
from scipy import stats
File "/usr/lib/python2.7/dist-packages/scipy/stats/init.py", line 324, in
from .stats import *
File "/usr/lib/python2.7/dist-packages/scipy/stats/stats.py", line 247, in
from . import distributions
File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 17, in
from scipy import optimize
File "/usr/lib/python2.7/dist-packages/scipy/optimize/init.py", line 148, in
from ._root import *
File "/usr/lib/python2.7/dist-packages/scipy/optimize/_root.py", line 20, in
from . import nonlin
File "/usr/lib/python2.7/dist-packages/scipy/optimize/nonlin.py", line 122, in
import scipy.sparse.linalg
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/init.py", line 108, in
from .isolve import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/init.py", line 6, in
from .iterative import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py", line 11, in
from scipy.lib.decorator import decorator
ImportError: No module named decorator

                          ^

SyntaxError: invalid syntax
ubgpu@ubgpu:/github/chainer$ sudo pip install scipy
[sudo] password for ubgpu:
You are using pip version 7.0.1, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): scipy in /usr/lib/python2.7/dist-packages
ubgpu@ubgpu:
/github/chainer$

`chainer-cuda-requirements` fails on an invalid environment

chainer-cuda-requirements command imports cuda.requirements. So, when import chainer fails on invalid environment, the command also fails.
This command needs to work on such a case because a user want to fix his invalid environment.

My idea is to write the requirements text in the script directly.

Import models of Model Zoo

(Model Zoo)[https://github.com/BVLC/caffe/wiki/Model-Zoo] is a great place to use existing researches for further researches and applications. It will enhance the usability.

The interface should be generalized to models added into Model Zoo in the future, though we do not need perfect compatibility to Caffe (especially on some functionalities of Caffe not used by the models in Model Zoo).

Add unit test for gradient_check

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for gradient_check, especially,

  • gradient_check.numerical_grad

Add unit test for Optimizer

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for Optimizer, especially,

  • Optimizer.setup
  • Optimizer.init_state
  • Optimizer.zero_grads
  • Optimizer.compute_grads_norm
  • Optimizer.clip_grads
  • Optimizer.weight_decay
  • Optimizer.accumulate_grads
  • Optimizer.update

How to train with CUDA in AWS

I tried to use GPU in AWS and failed.
I used g2.2xlarge with Amazon Linux AMI with NVIDIA GRID GPU Driver, which I think the easiest way to use cuda.

The commands I tried:

install Anaconda

wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda-2.2.0-Linux-x86_64.sh
bash Anaconda-2.2.0-Linux-x86_64.sh -b
echo 'export PATH=$HOME/anaconda/bin:$PATH' >> .bashrc
echo 'export PYTHONPATH=$HOME/anaconda/lib/python2.7/site-packages:$PYTHONPATH' >> .bashrc
source .bashrc
conda update conda -y

install chainer

pip install chainer
sudo apt-get install git
git clone https://github.com/pfnet/chainer.git
pip install -r chainer/chainer/requirements/cuda-requirements.txt
python chainer/examples/mnist/train_mnist.py --gpu 1

The error I encountered:

Traceback (most recent call last):
File "chainer/examples/mnist/train_mnist.py", line 40, in
cuda.init(args.gpu)
File "/home/ec2-user/anaconda/lib/python2.7/site-packages/chainer/cuda.py", line 119, in init
device = Device(device)
pycuda._driver.LogicError: cuDeviceGet failed: invalid device

Could you help me?
I think it is better to release the official chainer AMI for GPU instances.

Rename examples/imagenet/inception.py

In previous implementation, examples/imagenet/inception.py contains not only GoogLeNet but also inception module, which is building block of GoogLeNet. Now that inception is moved to chainer/functions/, I think we should rename this file (like googlenet.py).

AttributeError: 'GPUArray' object has no attribute 'argmax'

ubgpu@ubgpu:~/github/chainer$ python examples/sentiment/train_sentiment.py --gpu=0
Epoch: 0
loss: 270866.15
11.64 iters/sec, 734.28 sec

Epoch: 1
loss: 232619.31
10.74 iters/sec, 795.38 sec

Epoch: 2
loss: 218530.70
10.43 iters/sec, 819.13 sec

Epoch: 3
loss: 208379.96
10.66 iters/sec, 801.55 sec

Epoch: 4
loss: 199109.27
10.76 iters/sec, 793.75 sec

Train data evaluation:
Traceback (most recent call last):
File "examples/sentiment/train_sentiment.py", line 185, in
evaluate(train_trees)
File "examples/sentiment/train_sentiment.py", line 124, in evaluate
traverse(tree, train=False, evaluate=result)
File "examples/sentiment/train_sentiment.py", line 93, in traverse
left_loss, left = traverse(left_node, train=train, evaluate=evaluate, root=False)
File "examples/sentiment/train_sentiment.py", line 93, in traverse
left_loss, left = traverse(left_node, train=train, evaluate=evaluate, root=False)
File "examples/sentiment/train_sentiment.py", line 93, in traverse
left_loss, left = traverse(left_node, train=train, evaluate=evaluate, root=False)
File "examples/sentiment/train_sentiment.py", line 93, in traverse
left_loss, left = traverse(left_node, train=train, evaluate=evaluate, root=False)
File "examples/sentiment/train_sentiment.py", line 108, in traverse
predict = y.data.argmax(1)
AttributeError: 'GPUArray' object has no attribute 'argmax'
ubgpu@ubgpu:~/github/chainer$

Visualize the computational graph

Verifying the graph topology is hard for complex networks, so it is worthwile to generate the visual computational graph based on the actual forward implementation.

Run numerical test multiple times

Related #80

To reduce undesired failure of numerical tests like optimizers or backward_{cpu,gnu}, we should add some mechanism in which we run targeted test multiple times and assert fails only if targeted one fails at all attempts.

One of possible implementation is to use decorator like:

@test_n_times(10, 8):
def test_something(self):
    ....

Write a contribution guide document

It should include following topics:

  • Release policy (revision/minor scheduling and milestones)
  • Issue labels
  • Link to style guides
  • Testing guide
    Any other topics that should be included?

Check function signature

Checking the signature (and types of return values) of each function automatically makes it easy to debug type errors. There are three direction of design:

  1. Simply add asserts to forward functions.
  2. Use decorators.
  3. Pass the type information to Function.__init__

It must follow DRY rule and should have flexibility to support "variadic" functions (such as concat).

Add unit test for Variable

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for Variable, especially,

  • Variable.set_creator
  • Variable.unchain_backward.

Variable.__rsub__(Variable) stores Variable instance to data attribute when it is called directly.

Example:

In [89]: a = Variable(np.random.uniform(-1, 1, 3))
In [90]: b = Variable(np.random.uniform(-1, 1, 3))
In [91]: c = a.__rsub__(b)
In [92]: c.data
Out[92]: <chainer.variable.Variable at 0x7f2a5e12fa50>
In [93]: c.data.data
Out[93]: array([-0.91797078,  0.28034073,  0.441827  ])

Note that this method is not used as long as Variable.__sub__ is defined.
So it is not problematic if we do not call it directly.

Same is true for __rmul__, __rdiv__, __rpow__

cannot use GPU

ubgpu@ubgpu:~/github/chainer$ python examples/mnist/train_mnist.py
fetch MNIST dataset
epoch 1
train mean loss=0.27774727401, accuracy=0.914516667798
test mean loss=0.11268276395, accuracy=0.966000006199
epoch 2
train mean loss=0.136812622429, accuracy=0.958366669913
test mean loss=0.0904840060783, accuracy=0.973000006676
epoch 3
train mean loss=0.108749408927, accuracy=0.966883340677
test mean loss=0.073886228106, accuracy=0.976000006199
epoch 4
train mean loss=0.093579410448, accuracy=0.971016674836
test mean loss=0.0809730870945, accur

it is fine!!! but...

ubgpu@ubgpu:/github/chainer$ python examples/mnist/train_mnist.py --gpu=0
fetch MNIST dataset
Traceback (most recent call last):
File "examples/mnist/train_mnist.py", line 40, in
cuda.init(args.gpu)
File "/usr/local/lib/python2.7/dist-packages/chainer/cuda.py", line 107, in init
'The original import error said: ' + str(_import_error))
RuntimeError: CUDA environment is not correctly set up. The original import error said: cannot import name intern
ubgpu@ubgpu:
/github/chainer$ which nvcc
/usr/local/cuda/bin/nvcc
ubgpu@ubgpu:/github/chainer$ sudo pip install pyCUDA
[sudo] password for ubgpu:
You are using pip version 7.0.1, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): pyCUDA in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): pytools>=2011.2 in /usr/local/lib/python2.7/dist-packages (from pyCUDA)
Requirement already satisfied (use --upgrade to upgrade): pytest>=2 in /usr/local/lib/python2.7/dist-packages (from pyCUDA)
Requirement already satisfied (use --upgrade to upgrade): decorator>=3.2.0 in /usr/local/lib/python2.7/dist-packages (from pyCUDA)
Requirement already satisfied (use --upgrade to upgrade): appdirs>=1.4.0 in /usr/local/lib/python2.7/dist-packages (from pytools>=2011.2->pyCUDA)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from pytools>=2011.2->pyCUDA)
Requirement already satisfied (use --upgrade to upgrade): py>=1.4.25 in /usr/local/lib/python2.7/dist-packages (from pytest>=2->pyCUDA)
ubgpu@ubgpu:
/github/chainer$

Python 3 compatibility

I attempted to install chainer on Python 3.4, but it failed due to incompatibility with Python 3. The entire Python scientific stack is Python 3 compatible these days, so I'm hoping there are plans to make chainer compatible as well. I'm looking forward to using it.

Add unit test for FunctionSet

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for FunctionSet, especially,

  • FunctionSet.to_gpu
  • FunctionSet.to_cpu

Support CPU-only tests

The test codes of CPU forward/backward and GPU forward/backward are currently mixed and cannot be executed separately. This makes it hard to verify installation on non-GPU environment.

Add a function for summation along axes

sum function reduces all elements, while there are many cases that I want to take a summation over some axes. This is analogous to numpy.sum with the axis argument.

The implementation should contain a general function for GPU to compute a reduction over specified axes.

Live monitoring

Thanks for sharing the great package. It's nice if we can monitor the real-time progress like othe DL packages, though I only know some of them.

I've created an example using Bokeh in sinhrks/chainer@fbc933f :

  1. Install Bokeh

    pip install bokeh

  2. Run bokeh-server

    $ bokeh-server&

  3. Run examples/mnist/train_mnist_monitoring.py

  4. Web-browser is automatically open displaying the real-time progress of the training.

    2015-06-21 18 10 43

    Bokeh allows us to perform zoom/move charts interactively.

    2015-06-21 18 25 02

If this can be a focus of the project, would like to discuss how this can be handled (standardize or put it to example / document, etc).

Add a dot product function

It should handle inner-product, matrix-vector product, and matrix-matrix product functions. It is better if it supports a batch mode.

Add unit test for utils package

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for utils.

Comparison operation involving Variable

Following result is at least not intuitive.

>>> a = Variable([1,2,3,4])
>>> b = np.array([4,3,2,1])
>>> a > b
array([ True,  True,  True,  True], dtype=bool)
>>> a = Variable([1,2,3,4])
>>> b = Variable([4,3,2,1])
>>> a > b
False

We should determine operations to be defined and what are desired result of them

Add unit test for Function

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for Function, especially,

  • Direct usage of Function.forward and Function.backward
  • Function.unchain
  • Function.to_gpu
  • Function.to_cpu
  • Function.parameters
  • Function.gradients
  • Split.add_branch
  • Split.backward

Show a warning message on suspected usages of parameter GPU migration

Function.to_gpu and FunctionSet.to_gpu involves array copying, while an Optimizer object does not know this event. Consequently, user must migrate parameters onto devices BEFORE passing them to the optimizer. Violating this rule does not emit any messages currently, which ends up to making the training code meaningless.

So how about show a warning message if FunctionSet.collect_parameters is called after FunctionSet.to_gpu?

Non-parameterized versions of Linear and Convolution2D

Current implementation of Linear and Convolution2D use their own parameter arrays. It lacks flexibility of the architecture design. Non-parameterized Linear is a fully-connected layer that uses some of input variables as its parameter. It should look like:

x, W, b = Variable(...), Variable(...), Variable(...)
y = F.linear(x, W=W, b=b)

Non-parameterized Convolution2D should have similar interface.

Add unit test for cuda package

Related to #5

As discussed in #63, we open new issues about implementation of unit tests separately for each remaining core modules.

This issue is to add unittest for cuda package.

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.