diff --git a/.travis.yml b/.travis.yml index 0344dedbd..70097ede2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: install: - pip install tensorflow + - pip install -r requirements.txt - pip install -r tests/requirements.txt - pip install . diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..28092cbba --- /dev/null +++ b/README.rst @@ -0,0 +1,451 @@ +|TensorLayer Logo| + +|Codacy Badge| |Gitter| |Build Status| |Documentation Status| |Docker Pulls| + +TensorLayer is a deep learning and reinforcement learning library on top +of `TensorFlow `__. It provides rich neural +layers and utility functions to help researchers and engineers build +real-world AI applications. TensorLayer is awarded the 2017 Best Open +Source Software by the prestigious `ACM Multimedia +Society `__. + +- Useful links: `Documentation `__, + `Examples `__, + `中文文档 `__, + `中文书 `__ + +News +==== + +- [10 Apr] Load and visualize MPII dataset in one line of code. +- [05 Apr] Release `models + APIs `__ + for well-known pretained networks. +- [18 Mar] Release experimental APIs for binary networks. +- [18 Jan] + [《深度学习:一起玩转TensorLayer》](http://www.broadview.com.cn/book/5059) + (Deep Learning using TensorLayer) +- [17 Dec] Release experimental APIs for distributed training (by + `TensorPort `__). See `tiny + example `__. +- [17 Nov] Release data augmentation APIs for object detection, see + `tl.prepro `__. +- [17 Nov] Support `Convolutional + LSTM `__, see + `ConvLSTMLayer `__. +- [17 Nov] Support `Deformable + Convolution `__, see + `DeformableConv2dLayer `__. +- [17 Sep] New example `Chatbot in 200 lines of + code `__ for + `Seq2Seq `__. + +Installation +============ + +TensorLayer has pre-requisites including TensorFlow, numpy, matplotlib +and nltk (optional). For GPU support, CUDA and cuDNN are required. The +simplest way to install TensorLayer is: + +.. code:: bash + + # for master version (Recommended) + $ pip install git+https://github.com/tensorlayer/tensorlayer.git + + # for stable version + $ pip install tensorlayer + +Dockerfile is supplied to build images, build as usual + +.. code:: bash + + # for CPU version + $ docker build -t tensorlayer:latest . + + # for GPU version + $ docker build -t tensorlayer:latest-gpu -f Dockerfile.gpu . + +Please check +`documentation `__ +for detailed instructions. + +Examples and Tutorials +====================== + +Examples can be found `in this +folder `__ +and `Github +topic `__. + +Basics +------ + +- Multi-layer perceptron (MNIST) - Classification task, see + `tutorial\_mnist\_simple.py `__. +- Multi-layer perceptron (MNIST) - Classification using Iterator, see + `method1 `__ + and + `method2 `__. + +Computer Vision +--------------- + +- Denoising Autoencoder (MNIST). Classification task, see + `tutorial\_mnist.py `__. +- Stacked Denoising Autoencoder and Fine-Tuning (MNIST). Classification + task, see + `tutorial\_mnist.py `__. +- Convolutional Network (MNIST). Classification task, see + `tutorial\_mnist.py `__. +- Convolutional Network (CIFAR-10). Classification task, see + `tutorial\_cifar10.py `__ + and + `tutorial\_cifar10\_tfrecord.py `__. +- VGG 16 (ImageNet). Classification task, see + `tl.models.VGG16 `__ + or + `tutorial\_vgg16.py `__. +- VGG 19 (ImageNet). Classification task, see + `tutorial\_vgg19.py `__. +- InceptionV3 (ImageNet). Classification task, see + `tutorial\_inceptionV3\_tfslim.py `__. +- SqueezeNet (ImageNet). Model compression, see + `tl.models.SqueezeNetV1 `__ + or + `tutorial\_squeezenet.py `__ +- MobileNet (ImageNet). Model compression, see + `tl.models.MobileNetV1 `__ + or + `tutorial\_mobilenet.py `__. +- BinaryNet. Model compression, see + `mnist `__ + `cifar10 `__. +- Ternary Weight Network. Model compression, see + `mnist `__ + `cifar10 `__. +- DoReFa-Net. Model compression, see + `mnist `__ + `cifar10 `__. +- Wide ResNet (CIFAR) by + `ritchieng `__. +- More CNN implementations of + `TF-Slim `__ + can be connected to TensorLayer via SlimNetsLayer. +- `Spatial Transformer Networks `__ + by + `zsdonghao `__. +- `U-Net for brain tumor + segmentation `__ by + `zsdonghao `__. +- Variational Autoencoder (VAE) for (CelebA) by + `yzwxx `__. +- Variational Autoencoder (VAE) for (MNIST) by + `BUPTLdy `__. +- Image Captioning - Reimplementation of Google's + `im2txt `__ + by `zsdonghao `__. + +Natural Language Processing +--------------------------- + +- Recurrent Neural Network (LSTM). Apply multiple LSTM to PTB dataset + for language modeling, see + `tutorial\_ptb\_lstm.py `__ + and + `tutorial\_ptb\_lstm\_state\_is\_tuple.py `__. +- Word Embedding (Word2vec). Train a word embedding matrix, see + `tutorial\_word2vec\_basic.py `__. +- Restore Embedding matrix. Restore a pre-train embedding matrix, see + `tutorial\_generate\_text.py `__. +- Text Generation. Generates new text scripts, using LSTM network, see + `tutorial\_generate\_text.py `__. +- Chinese Text Anti-Spam by + `pakrchen `__. +- `Chatbot in 200 lines of + code `__ for + `Seq2Seq `__. +- FastText Sentence Classification (IMDB), see + `tutorial\_imdb\_fasttext.py `__ + by `tomtung `__. + +Adversarial Learning +-------------------- + +- DCGAN (CelebA). Generating images by `Deep Convolutional Generative + Adversarial Networks `__ by + `zsdonghao `__. +- `Generative Adversarial Text to Image + Synthesis `__ by + `zsdonghao `__. +- `Unsupervised Image to Image Translation with Generative Adversarial + Networks `__ by + `zsdonghao `__. +- `Improved + CycleGAN `__ with + resize-convolution by + `luoxier `__ +- `Super Resolution GAN `__ by + `zsdonghao `__. +- `DAGAN: Fast Compressed Sensing MRI + Reconstruction `__ by + `nebulaV `__. + +Reinforcement Learning +---------------------- + +- Policy Gradient / Network (Atari Ping Pong), see + `tutorial\_atari\_pong.py `__. +- Deep Q-Network (Frozen lake), see + `tutorial\_frozenlake\_dqn.py `__. +- Q-Table learning algorithm (Frozen lake), see + `tutorial\_frozenlake\_q\_table.py `__. +- Asynchronous Policy Gradient using TensorDB (Atari Ping Pong) by + `nebulaV `__. +- AC for discrete action space (Cartpole), see + `tutorial\_cartpole\_ac.py `__. +- A3C for continuous action space (Bipedal Walker), see + `tutorial\_bipedalwalker\_a3c\*.py `__. +- `DAGGER `__ + for (`Gym Torcs `__) by + `zsdonghao `__. +- `TRPO `__ for continuous and + discrete action space by + `jjkke88 `__. + +Miscellaneous +------------- + +- Distributed Training. + `mnist `__ + and + `imagenet `__ + by `jorgemf `__. +- Merge TF-Slim into TensorLayer. + `tutorial\_inceptionV3\_tfslim.py `__. +- Merge Keras into TensorLayer. + `tutorial\_keras.py `__. +- Data augmentation with TFRecord. Effective way to load and + pre-process data, see + `tutorial\_tfrecord\*.py `__ + and + `tutorial\_cifar10\_tfrecord.py `__. +- Data augmentation with TensorLayer, see + `tutorial\_image\_preprocess.py `__. +- TensorDB by `fangde `__ see + `here `__. +- A simple web service - + `TensorFlask `__ by + `JoelKronander `__. +- Float 16 half-precision model, see + `tutorial\_mnist\_float16.py `__ + +Notes +----- + +TensorLayer provides two set of Convolutional layer APIs, see +`(Advanced) `__ +and +`(Basic) `__ +on readthedocs website. + +Features +======== + +Design Philosophy +----------------- + +As TensorFlow users, we have been looking for a library that can serve +for various development phases. This library is easy for beginners by +providing rich neural network implementations, examples and tutorials. +Later, its APIs shall naturally allow users to leverage the powerful +features of TensorFlow, exhibiting best performance in addressing +real-world problems. In the end, the extra abstraction shall not +compromise TensorFlow performance, and thus suit for production +deployment. TensorLayer is a novel library that aims to satisfy these +requirements. It has three key features: + +- *Simplicity* : TensorLayer lifts the low-level dataflow abstraction + of TensorFlow to **high-level** layers. It also provides users with + massive examples and tutorials to minimize learning barrier. +- *Flexibility* : TensorLayer APIs are transparent: it does not mask + TensorFlow from users; but leaving massive hooks that support diverse + **low-level tuning**. +- *Zero-cost Abstraction* : TensorLayer is able to achieve the **full + performance** of TensorFlow. + +Negligible Overhead +------------------- + +TensorLayer has negligible performance overhead. We benchmark classic +deep learning models using TensorLayer and native TensorFlow on a Titan +X Pascal GPU. Here are the training speeds of respective tasks: + ++---------------+-----------------+-----------------+-----------------+ +| | CIFAR-10 | PTB LSTM | Word2Vec | ++===============+=================+=================+=================+ +| TensorLayer | 2528 images/s | 18063 words/s | 58167 words/s | ++---------------+-----------------+-----------------+-----------------+ +| TensorFlow | 2530 images/s | 18075 words/s | 58181 words/s | ++---------------+-----------------+-----------------+-----------------+ + +Compared with Keras and TFLearn +------------------------------- + +Similar to TensorLayer, Keras and TFLearn are also popular TensorFlow +wrapper libraries. These libraries are comfortable to start with. They +provide high-level abstractions; but mask the underlying engine from +users. It is thus hard to customize model behaviors and touch the +essential features of TensorFlow. Without compromise in simplicity, +TensorLayer APIs are generally more flexible and transparent. Users +often find it easy to start with the examples and tutorials of +TensorLayer, and then dive into the TensorFlow low-level APIs only if +need. TensorLayer does not create library lock-in. Users can easily +import models from Keras, TFSlim and TFLearn into a TensorLayer +environment. + +Documentation +============= + +The documentation +`[Online] `__ +`[PDF] `__ +`[Epub] `__ +`[HTML] `__ +describes the usages of TensorLayer APIs. It is also a self-contained +document that walks through different types of deep neural networks, +reinforcement learning and their applications in Natural Language +Processing (NLP) problems. + +We have included the corresponding modularized implementations of Google +TensorFlow Deep Learning tutorial, so you can read the TensorFlow +tutorial +`[en] `__ +`[cn] `__ along with +our document. `Chinese +documentation `__ is +also available. + +.. raw:: html + + + +Academic and Industry Users +=========================== + +TensorLayer has an open and fast growing community. It has been widely +used by researchers from Imperial College London, Carnegie Mellon +University, Stanford University, Tsinghua University, UCLA, Linköping +University and etc., as well as engineers from Google, Microsoft, +Alibaba, Tencent, Penguins Innovate, ReFULE4, Bloomberg, GoodAILab and +many others. + +- 🇬🇧 If you have any question, we suggest to create an issue to discuss + with us. +- 🇨🇳 我们有中文讨论社区: + 如\ `QQ群 `__\ 和\ `微信群 `__. + +Contribution Guideline +====================== + +`Guideline in 5 lines <./CONTRIBUTING.md>`__ + +Citation +======== + +If you find this project useful, we would be grateful if you cite the +TensorLayer paper: + +:: + + @article{tensorlayer2017, + author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike}, + journal = {ACM Multimedia}, + title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}}, + url = {http://tensorlayer.org}, + year = {2017} + } + +License +======= + +TensorLayer is released under the Apache 2.0 license. + +.. |TensorLayer Logo| image:: https://raw.githubusercontent.com/tensorlayer/tensorlayer/master/img/tl_transparent_logo.png + :width: 50% + +.. |Codacy Badge| image:: https://api.codacy.com/project/badge/Grade/ca2a29ddcf7445588beff50bee5406d9 + :target: https://app.codacy.com/app/tensorlayer/tensorlayer?utm_source=github.com&utm_medium=referral&utm_content=tensorlayer/tensorlayer&utm_campaign=badger +.. |Gitter| image:: https://badges.gitter.im/Join%20Chat.svg + :target: https://gitter.im/tensorlayer/Lobby#?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge +.. |Build Status| image:: https://travis-ci.org/tensorlayer/tensorlayer.svg?branch=master + :target: https://travis-ci.org/tensorlayer/tensorlayer +.. |Documentation Status| image:: https://readthedocs.org/projects/tensorlayer/badge/?version=latest + :target: http://tensorlayer.readthedocs.io/en/latest/?badge=latest +.. |Docker Pulls| image:: https://img.shields.io/docker/pulls/tensorlayer/tensorlayer.svg?maxAge=604800 + :target: https://hub.docker.com/r/tensorlayer/tensorlayer/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..cd2220705 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +numpy +scipy +scikit-image +matplotlib diff --git a/setup.py b/setup.py index 49f150af1..e1ef6b84b 100755 --- a/setup.py +++ b/setup.py @@ -1,27 +1,143 @@ -from setuptools import find_packages, setup +#!/usr/bin/env python +import os +import codecs -install_requires = [ - 'numpy', - # 'tensorflow', # user install it - 'scipy', - 'scikit-image', - 'matplotlib', -] +try: + from setuptools import ( + setup, + find_packages + ) + +except ImportError: + from distutils.core import ( + setup, + find_packages + ) + + +from tensorlayer import ( + __contact_emails__, + __contact_names__, + __description__, + __download_url__, + __homepage__, + __keywords__, + __license__, + __package_name__, + __repository_url__, + __version__ +) + + +# =================== Reading Readme file as TXT files =================== + +if os.path.exists('README.rst'): + # codec is used for consistent encoding + long_description = codecs.open( + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst'), + 'r', 'utf-8' + ).read() + +else: + long_description = 'See ' + __homepage__ + + +# ======================= Reading Requirements files as TXT files ======================= + +def req_file(filename): + with open(filename) as f: + content = f.readlines() + # you may also want to remove whitespace characters + # Example: `\n` at the end of each line + return [x.strip() for x in content] setup( - name="tensorlayer", - version="1.8.4", - include_package_data=True, - author='TensorLayer Contributors', - author_email='hao.dong11@imperial.ac.uk', - url="https://github.com/tensorlayer/tensorlayer", - license="apache", + name=__package_name__, + + # Versions should comply with PEP440. For a discussion on single-sourcing + # the version across setup.py and the project code, see + # https://packaging.python.org/en/latest/single_source_version.html + version=__version__, + + description=__description__, + long_description=long_description, + + # The project's main homepage. + url=__repository_url__, + download_url=__download_url__, + + # Author details + author=__contact_names__, + author_email=__contact_emails__, + + # maintainer Details + maintainer=__contact_names__, + maintainer_email=__contact_emails__, + + # The licence under which the project is released + license=__license__, + + classifiers=[ + # How mature is this project? Common values are + # 1 - Planning + # 2 - Pre-Alpha + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + # 6 - Mature + # 7 - Inactive + 'Development Status :: 5 - Production/Stable', + + # Indicate who your project is intended for + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'Intended Audience :: Information Technology', + + # Indicate what your project relates to + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Image Recognition', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Software Development :: Libraries', + 'Topic :: Utilities', + + # Pick your license as you wish (should match "license" above) + 'License :: OSI Approved :: Apache Software License', + + # Specify the Python versions you support here. In particular, ensure + # that you indicate whether you support Python 2, Python 3 or both. + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + + # Additionnal Settings + 'Environment :: Console', + 'Natural Language :: English', + 'Operating System :: OS Independent', + ], + + keywords=__keywords__, packages=find_packages(), - install_requires=install_requires, + + # List run-time dependencies here. These will be installed by pip when + # your project is installed. For an analysis of "install_requires" vs pip's + # requirements files see: + # https://packaging.python.org/en/latest/requirements.html + install_requires=req_file("requirements.txt"), + + # List additional groups of dependencies here (e.g. development + # dependencies). You can install these using the following syntax, + # $ pip install -e .[test] + extras_require={ + 'test': req_file("tests/requirements.txt") + }, + + zip_safe=True, + include_package_data=True, scripts=[ 'tl', ], - description="Reinforcement Learning and Deep Learning Library for Researcher and Engineer.", - keywords="deep learning, reinforcement learning, tensorflow", platform=['any'], ) diff --git a/tensorlayer/__init__.py b/tensorlayer/__init__.py index 42a2653a7..d93a8b0b3 100644 --- a/tensorlayer/__init__.py +++ b/tensorlayer/__init__.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- """Deep learning and Reinforcement learning library for Researchers and Engineers""" from __future__ import absolute_import @@ -24,7 +26,19 @@ act = activation vis = visualize -__version__ = "1.8.4" +# Use the following formating: (major, minor, patch, prerelease) +VERSION = (1, 8, 4, '') +__version__ = '.'.join(map(str, VERSION[:3])) + "".join(VERSION[3:]) + +__package_name__ = 'tensorlayer' +__contact_names__ = 'TensorLayer Contributors' +__contact_emails__ = 'hao.dong11@imperial.ac.uk' +__homepage__ = 'http://tensorlayer.readthedocs.io/en/latest/' +__repository_url__ = 'https://github.com/tensorlayer/tensorlayer' +__download_url__ = 'https://github.com/tensorlayer/tensorlayer' +__description__ = 'Reinforcement Learning and Deep Learning Library for Researcher and Engineer.' +__license__ = 'apache' +__keywords__ = 'deep learning, machine learning, computer vision, nlp, supervised learning, unsupervised learning, reinforcement learning, tensorflow' global_flag = {} global_dict = {}