README.md 5.2 KB
Newer Older
1
2
# TensorFlow Official Models

Chen Chen's avatar
Chen Chen committed
3
The TensorFlow official models are a collection of models that use
Hongkun Yu's avatar
Hongkun Yu committed
4
5
6
TensorFlow's high-level APIs. They are intended to be well-maintained, tested,
and kept up to date with the latest TensorFlow API. They should also be
reasonably optimized for fast performance while still being easy to read.
7

Hongkun Yu's avatar
Hongkun Yu committed
8
These models are used as end-to-end tests, ensuring that the models run with the
Rajagopal Ananthanarayanan's avatar
Rajagopal Ananthanarayanan committed
9
same or improved speed and performance with each new TensorFlow build.
10
11

## Tensorflow releases
12

13
14
The master branch of the models are **in development** with TensorFlow 2.x, and
they target the
Hongkun Yu's avatar
Hongkun Yu committed
15
16
17
[nightly binaries](https://github.com/tensorflow/tensorflow#installation) built
from the
[master branch of TensorFlow](https://github.com/tensorflow/tensorflow/tree/master).
18
You may start from installing with pip:
19
20

```shell
ayushmankumar7's avatar
ayushmankumar7 committed
21
pip3 install tf-nightly
22
```
Hongkun Yu's avatar
Hongkun Yu committed
23
24
25
26
27

**Stable versions** of the official models targeting releases of TensorFlow are
available as tagged branches or
[downloadable releases](https://github.com/tensorflow/models/releases). Model
repository version numbers match the target TensorFlow release, such that
Hongkun Yu's avatar
Hongkun Yu committed
28
[release v2.1.0](https://github.com/tensorflow/models/releases/tag/v2.1.0) are
Hongkun Yu's avatar
Hongkun Yu committed
29
compatible with
Hongkun Yu's avatar
Hongkun Yu committed
30
[TensorFlow v2.1.0](https://github.com/tensorflow/tensorflow/releases/tag/v2.1.0).
Hongkun Yu's avatar
Hongkun Yu committed
31
32
33

If you are on a version of TensorFlow earlier than 1.4, please
[update your installation](https://www.tensorflow.org/install/).
34

35
## Requirements
36

Hongkun Yu's avatar
Hongkun Yu committed
37
Please follow the below steps before running models in this repo:
38

Hongkun Yu's avatar
Hongkun Yu committed
39
40
1.  TensorFlow
    [nightly binaries](https://github.com/tensorflow/tensorflow#installation)
41

Hongkun Yu's avatar
Hongkun Yu committed
42
43
44
45
46
47
48
49
50
2.  If users would like to clone this repo but do not care about change history,
please consider:

  ```shell
  export repo_version="master"
  git clone -b ${repo_version} https://github.com/tensorflow/models.git --depth=1
  ```

3.  Add the top-level ***/models*** folder to the Python path with the command:
51

Hongkun Yu's avatar
Hongkun Yu committed
52
53
54
  ```shell
  export PYTHONPATH=$PYTHONPATH:/path/to/models
  ```
55

Hongkun Yu's avatar
Hongkun Yu committed
56
57
58
  Using Colab:

  ```python
Gonzalo Gasca Meza's avatar
Gonzalo Gasca Meza committed
59
60
  import os
  os.environ['PYTHONPATH'] += ":/path/to/models"
Hongkun Yu's avatar
Hongkun Yu committed
61
62
  ```

Hongkun Yu's avatar
Hongkun Yu committed
63
4.  Install dependencies:
Hongkun Yu's avatar
Hongkun Yu committed
64
65
66
67
68

  ```shell
  pip3 install --user -r official/requirements.txt
  ```

69

Hongkun Yu's avatar
Hongkun Yu committed
70
71
72
To make Official Models easier to use, we are planning to create a pip
installable Official Models package. This is being tracked in
[#917](https://github.com/tensorflow/models/issues/917).
73

74
## Available models
75

76
77
**NOTE: For Officially Supported TPU models please check [README-TPU](README-TPU.md).**

Hongkun Yu's avatar
Hongkun Yu committed
78
79
**NOTE:** Please make sure to follow the steps in the
[Requirements](#requirements) section.
80

Hongkun Yu's avatar
Hongkun Yu committed
81
### Natural Language Processing
82
83
84
85

*   [bert](nlp/bert): A powerful pre-trained language representation model:
    BERT, which stands for Bidirectional Encoder Representations from
    Transformers.
Julius Simonelli's avatar
Julius Simonelli committed
86
*   [transformer](nlp/transformer): A transformer model to translate the WMT English
Hongkun Yu's avatar
Hongkun Yu committed
87
    to German dataset.
88
*   [xlnet](nlp/xlnet): XLNet: Generalized Autoregressive Pretraining for
Hongkun Yu's avatar
Hongkun Yu committed
89
    Language Understanding.
90
91
92

### Computer Vision

93
94
*   [mnist](vision/image_classification): A basic model to classify digits from
    the MNIST dataset.
95
96
*   [resnet](vision/image_classification): A deep residual network that can be
    used to classify both CIFAR-10 and ImageNet's dataset of 1000 classes.
97
*   [retinanet](vision/detection): A fast and powerful object detector.
98
99
100

### Others

Hongkun Yu's avatar
Hongkun Yu committed
101
102
*   [ncf](recommendation): Neural Collaborative Filtering model for
    recommendation tasks.
103

Hongkun Yu's avatar
Hongkun Yu committed
104
105
Models that will not update to TensorFlow 2.x stay inside R1 directory:

Hongkun Yu's avatar
Hongkun Yu committed
106
107
108
109
110
111
112
113
114
*   [boosted_trees](r1/boosted_trees): A Gradient Boosted Trees model to
    classify higgs boson process from HIGGS Data Set.
*   [wide_deep](r1/wide_deep): A model that combines a wide model and deep
    network to classify census income data.

## More models to come!

We are in the progress to revamp official model garden with TensorFlow 2.0 and
Keras. In the near future, we will bring:
Hongkun Yu's avatar
Hongkun Yu committed
115

Hongkun Yu's avatar
Hongkun Yu committed
116
117
118
119
120
*   State-of-the-art language understanding models: XLNet, GPT2, and more
    members in Transformer family.
*   Start-of-the-art image classification models: EfficientNet, MnasNet and
    variants.
*   A set of excellent objection detection models.
Hongkun Yu's avatar
Hongkun Yu committed
121

Hongkun Yu's avatar
Hongkun Yu committed
122
123
If you would like to make any fixes or improvements to the models, please
[submit a pull request](https://github.com/tensorflow/models/compare).
124

125
## New Models
126

Hongkun Yu's avatar
Hongkun Yu committed
127
128
129
The team is actively working to add new models to the repository. Every model
should follow the following guidelines, to uphold the our objectives of
readable, usable, and maintainable code.
130

Rajagopal Ananthanarayanan's avatar
Rajagopal Ananthanarayanan committed
131
132
133
134
135
**General guidelines**

* Code should be well documented and tested.
* Runnable from a blank environment with relative ease.
* Trainable on: single GPU/CPU (baseline), multiple GPUs, TPU
Hongkun Yu's avatar
Hongkun Yu committed
136
137
* Compatible with Python 3 (using [six](https://pythonhosted.org/six/) when
  being compatible with Python 2 is necessary)
Rajagopal Ananthanarayanan's avatar
Rajagopal Ananthanarayanan committed
138
* Conform to [Google Python Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md)
139

140
**Implementation guidelines**
141

Hongkun Yu's avatar
Hongkun Yu committed
142
143
These guidelines exist so the model implementations are consistent for better
readability and maintainability.
144

Hongkun Yu's avatar
Hongkun Yu committed
145
146
147
148
149
*   Use [common utility functions](utils)
*   Export SavedModel at the end of training.
*   Consistent flags and flag-parsing library
    ([read more here](utils/flags/guidelines.md))
*   Produce benchmarks and logs ([read more here](utils/logs/guidelines.md))