deanna-emery commited on
Commit
93528c6
β€’
1 Parent(s): 7f74a65
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. app.py +2 -2
  2. modeling/official/core/__init__.py +0 -31
  3. modeling/official/vision/configs/__init__.py +0 -24
  4. modeling/tensorflow_models/nlp/__init__.py +0 -20
  5. modeling/tensorflow_models/tensorflow_models_pypi.ipynb +0 -339
  6. modeling/tensorflow_models/tensorflow_models_test.py +0 -40
  7. {modeling/official β†’ official}/README-TPU.md +0 -0
  8. {modeling/official β†’ official}/README.md +0 -0
  9. {modeling/official β†’ official}/__init__.py +0 -0
  10. {modeling/official β†’ official}/common/__init__.py +0 -0
  11. {modeling/official β†’ official}/common/dataset_fn.py +0 -0
  12. {modeling/official β†’ official}/common/distribute_utils.py +0 -0
  13. {modeling/official β†’ official}/common/distribute_utils_test.py +0 -0
  14. {modeling/official β†’ official}/common/flags.py +0 -0
  15. {modeling/official β†’ official}/common/registry_imports.py +0 -0
  16. {modeling/official β†’ official}/common/streamz_counters.py +0 -0
  17. {modeling/tensorflow_models β†’ official/core}/__init__.py +16 -8
  18. {modeling/official β†’ official}/core/actions.py +4 -4
  19. {modeling/official β†’ official}/core/actions_test.py +0 -0
  20. {modeling/official β†’ official}/core/base_task.py +5 -5
  21. {modeling/official β†’ official}/core/base_trainer.py +4 -4
  22. {modeling/official β†’ official}/core/base_trainer_test.py +0 -0
  23. {modeling/official β†’ official}/core/config_definitions.py +3 -3
  24. {modeling/official β†’ official}/core/exp_factory.py +2 -2
  25. {modeling/official β†’ official}/core/export_base.py +0 -0
  26. {modeling/official β†’ official}/core/export_base_test.py +1 -1
  27. {modeling/official β†’ official}/core/file_writers.py +0 -0
  28. {modeling/official β†’ official}/core/file_writers_test.py +0 -0
  29. {modeling/official β†’ official}/core/input_reader.py +1 -1
  30. {modeling/official β†’ official}/core/registry.py +0 -0
  31. {modeling/official β†’ official}/core/registry_test.py +0 -0
  32. {modeling/official β†’ official}/core/savedmodel_checkpoint_manager.py +0 -0
  33. {modeling/official β†’ official}/core/savedmodel_checkpoint_manager_test.py +0 -0
  34. {modeling/official β†’ official}/core/task_factory.py +1 -1
  35. {modeling/official β†’ official}/core/test_utils.py +0 -0
  36. {modeling/official β†’ official}/core/tf_example_builder.py +0 -0
  37. {modeling/official β†’ official}/core/tf_example_builder_test.py +0 -0
  38. {modeling/official β†’ official}/core/tf_example_feature_key.py +0 -0
  39. {modeling/official β†’ official}/core/tf_example_feature_key_test.py +0 -0
  40. {modeling/official β†’ official}/core/train_lib.py +6 -6
  41. {modeling/official β†’ official}/core/train_lib_test.py +0 -0
  42. {modeling/official β†’ official}/core/train_utils.py +6 -6
  43. {modeling/official β†’ official}/core/train_utils_test.py +0 -0
  44. {modeling/official β†’ official}/legacy/README.md +0 -0
  45. {modeling/official β†’ official}/legacy/__init__.py +0 -0
  46. {modeling/official β†’ official}/legacy/albert/README.md +0 -0
  47. {modeling/official β†’ official}/legacy/albert/__init__.py +0 -0
  48. {modeling/official β†’ official}/legacy/albert/configs.py +0 -0
  49. {modeling/official β†’ official}/legacy/bert/README.md +0 -0
  50. {modeling/official β†’ official}/legacy/bert/__init__.py +0 -0
app.py CHANGED
@@ -9,8 +9,8 @@ import tensorflow as tf, tf_keras
9
  import tensorflow_hub as hub
10
  from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
11
 
12
- from modeling.official.projects.movinet.modeling import movinet
13
- from modeling.official.projects.movinet.modeling import movinet_model_a2_modified as movinet_model_modified
14
 
15
 
16
  movinet_path = 'modeling/movinet_checkpoints_a2_epoch9'
 
9
  import tensorflow_hub as hub
10
  from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
11
 
12
+ from official.projects.movinet.modeling import movinet
13
+ from official.projects.movinet.modeling import movinet_model_a2_modified as movinet_model_modified
14
 
15
 
16
  movinet_path = 'modeling/movinet_checkpoints_a2_epoch9'
modeling/official/core/__init__.py DELETED
@@ -1,31 +0,0 @@
1
- # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """Core is shared by both `nlp` and `vision`."""
16
-
17
- from modeling.official.core import actions
18
- from modeling.official.core import base_task
19
- from modeling.official.core import base_trainer
20
- from modeling.official.core import config_definitions
21
- from modeling.official.core import exp_factory
22
- from modeling.official.core import export_base
23
- from modeling.official.core import file_writers
24
- from modeling.official.core import input_reader
25
- from modeling.official.core import registry
26
- from modeling.official.core import savedmodel_checkpoint_manager
27
- from modeling.official.core import task_factory
28
- from modeling.official.core import tf_example_builder
29
- from modeling.official.core import tf_example_feature_key
30
- from modeling.official.core import train_lib
31
- from modeling.official.core import train_utils
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modeling/official/vision/configs/__init__.py DELETED
@@ -1,24 +0,0 @@
1
- # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """Configs package definition."""
16
-
17
- from modeling.official.vision.configs import backbones
18
- from modeling.official.vision.configs import backbones_3d
19
- from modeling.official.vision.configs import common
20
- from modeling.official.vision.configs import image_classification
21
- from modeling.official.vision.configs import maskrcnn
22
- from modeling.official.vision.configs import retinanet
23
- from modeling.official.vision.configs import semantic_segmentation
24
- from modeling.official.vision.configs import video_classification
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modeling/tensorflow_models/nlp/__init__.py DELETED
@@ -1,20 +0,0 @@
1
- # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """TensorFlow Models NLP Libraries."""
16
-
17
- from official.nlp import tasks
18
- from official.nlp.configs import encoders
19
- from official.nlp.modeling import *
20
- from official.nlp.serving import serving_modules
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modeling/tensorflow_models/tensorflow_models_pypi.ipynb DELETED
@@ -1,339 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {
6
- "id": "bK-7g5sizhg5"
7
- },
8
- "source": [
9
- "## Install Tensorflow-Models packages\n",
10
- "\n",
11
- "The notebook is tested with Google Colab sandbox.\n",
12
- "\n"
13
- ]
14
- },
15
- {
16
- "cell_type": "code",
17
- "execution_count": null,
18
- "metadata": {
19
- "colab": {
20
- "base_uri": "https://localhost:8080/"
21
- },
22
- "executionInfo": {
23
- "elapsed": 9737,
24
- "status": "ok",
25
- "timestamp": 1650513863935,
26
- "user": {
27
- "displayName": "Hongkun Yu",
28
- "userId": "12855578661733349593"
29
- },
30
- "user_tz": 420
31
- },
32
- "id": "eTz93_P2dMty",
33
- "outputId": "d147b4b0-954f-4064-d179-bb82bc3ea4fe"
34
- },
35
- "outputs": [
36
- {
37
- "name": "stdout",
38
- "output_type": "stream",
39
- "text": [
40
- "\u001b[K |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21.8 MB 1.6 MB/s \n",
41
- "\u001b[?25h"
42
- ]
43
- }
44
- ],
45
- "source": [
46
- "!pip3 install -q tf-models-nightly\n",
47
- "# Fix Colab default opencv problem\n",
48
- "!pip3 install -q opencv-python-headless==4.1.2.30\n",
49
- "\n",
50
- "## Colab environment setup. To use a stable TF release version\n",
51
- "## because of the possible breakage in tf-nightly.\n",
52
- "# !pip3 install -U numpy\u003e=1.20\n",
53
- "# !pip3 install -q tensorflow==2.8.0"
54
- ]
55
- },
56
- {
57
- "cell_type": "code",
58
- "execution_count": null,
59
- "metadata": {
60
- "colab": {
61
- "base_uri": "https://localhost:8080/"
62
- },
63
- "executionInfo": {
64
- "elapsed": 2,
65
- "status": "ok",
66
- "timestamp": 1650513867685,
67
- "user": {
68
- "displayName": "Hongkun Yu",
69
- "userId": "12855578661733349593"
70
- },
71
- "user_tz": 420
72
- },
73
- "id": "GHvGWdCcdQqG",
74
- "outputId": "863683b2-6b70-4de9-98bc-5df743619ad5"
75
- },
76
- "outputs": [
77
- {
78
- "name": "stdout",
79
- "output_type": "stream",
80
- "text": [
81
- "1.21.6\n",
82
- "2.10.0-dev20220420\n"
83
- ]
84
- }
85
- ],
86
- "source": [
87
- "import numpy as np\n",
88
- "import tensorflow as tf\n",
89
- "print(np.__version__)\n",
90
- "print(tf.__version__)\n",
91
- "\n",
92
- "import tensorflow_models as tfm"
93
- ]
94
- },
95
- {
96
- "cell_type": "markdown",
97
- "metadata": {
98
- "id": "eYSeQJniztc8"
99
- },
100
- "source": [
101
- "## Check out modules\n",
102
- "\n",
103
- "**Note: As the TensorFlow Models (NLP + Vision) 2.9 release which is tested for this notebook, we partially exported selected modules but the APIs are not stable. Also be aware that, the\n",
104
- "modeling libraries are advancing very fast, so we generally don't guarantee compatability between versions.** "
105
- ]
106
- },
107
- {
108
- "cell_type": "code",
109
- "execution_count": null,
110
- "metadata": {
111
- "colab": {
112
- "base_uri": "https://localhost:8080/"
113
- },
114
- "executionInfo": {
115
- "elapsed": 206,
116
- "status": "ok",
117
- "timestamp": 1650513874596,
118
- "user": {
119
- "displayName": "Hongkun Yu",
120
- "userId": "12855578661733349593"
121
- },
122
- "user_tz": 420
123
- },
124
- "id": "Y1iEMMGTMrQu",
125
- "outputId": "f3da68d7-ecda-471c-c27b-915b80b55131"
126
- },
127
- "outputs": [
128
- {
129
- "name": "stdout",
130
- "output_type": "stream",
131
- "text": [
132
- "Top-level modules: ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'core', 'hyperparams', 'nlp', 'optimization', 'utils', 'vision']\n",
133
- "NLP modules: ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'encoders', 'layers', 'losses', 'models', 'networks', 'ops', 'serving_modules', 'tasks']\n",
134
- "Vision modules: ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'anchor', 'anchor_generator', 'augment', 'backbones', 'box_matcher', 'box_ops', 'classification_model', 'configs', 'decoders', 'factory', 'factory_3d', 'heads', 'iou_similarity', 'layers', 'mask_ops', 'maskrcnn_model', 'nms', 'preprocess_ops', 'preprocess_ops_3d', 'retinanet_model', 'sampling_ops', 'segmentation_model', 'spatial_transform_ops', 'target_gather', 'video_classification_model']\n"
135
- ]
136
- }
137
- ],
138
- "source": [
139
- "print(\"Top-level modules: \", dir(tfm))\n",
140
- "print(\"NLP modules: \", dir(tfm.nlp))\n",
141
- "print(\"Vision modules: \", dir(tfm.vision))"
142
- ]
143
- },
144
- {
145
- "cell_type": "markdown",
146
- "metadata": {
147
- "id": "UMHeJmk_1yUf"
148
- },
149
- "source": [
150
- "## Quick Examples\n",
151
- "\n",
152
- "### 1. Use a tfm.nlp Keras layer"
153
- ]
154
- },
155
- {
156
- "cell_type": "code",
157
- "execution_count": null,
158
- "metadata": {
159
- "colab": {
160
- "base_uri": "https://localhost:8080/"
161
- },
162
- "executionInfo": {
163
- "elapsed": 400,
164
- "status": "ok",
165
- "timestamp": 1650514040957,
166
- "user": {
167
- "displayName": "Hongkun Yu",
168
- "userId": "12855578661733349593"
169
- },
170
- "user_tz": 420
171
- },
172
- "id": "XVWEUozQ1xQY",
173
- "outputId": "5de2aa91-8c38-438e-80b6-481617917c08"
174
- },
175
- "outputs": [
176
- {
177
- "name": "stdout",
178
- "output_type": "stream",
179
- "text": [
180
- "transformer_encoder_block_1\n",
181
- "tf.Tensor(\n",
182
- "[[[-1.063648 1.4375787 -0.79198956 0.4180589 ]\n",
183
- " [-1.063648 1.4375787 -0.79198956 0.4180589 ]\n",
184
- " [-1.063648 1.4375787 -0.79198956 0.4180589 ]]\n",
185
- "\n",
186
- " [[-1.063648 1.4375787 -0.79198956 0.4180589 ]\n",
187
- " [-1.063648 1.4375787 -0.79198956 0.4180589 ]\n",
188
- " [-1.063648 1.4375787 -0.7919895 0.41805887]]], shape=(2, 3, 4), dtype=float32)\n"
189
- ]
190
- }
191
- ],
192
- "source": [
193
- "encoder_block = tfm.nlp.layers.TransformerEncoderBlock(\n",
194
- " num_attention_heads=2, inner_dim=10, inner_activation='relu')\n",
195
- "\n",
196
- "batch, length, hidden_size = 2, 3, 4\n",
197
- "qkv_inputs = tf.ones((batch, length, hidden_size), tf.float32)\n",
198
- "attention_mask = None\n",
199
- "outputs = encoder_block([qkv_inputs, attention_mask])\n",
200
- "print(encoder_block.name)\n",
201
- "print(outputs)"
202
- ]
203
- },
204
- {
205
- "cell_type": "markdown",
206
- "metadata": {
207
- "id": "AOOrWjKkSYM0"
208
- },
209
- "source": [
210
- "### 2. Use a tfm.vision Backbone models"
211
- ]
212
- },
213
- {
214
- "cell_type": "code",
215
- "execution_count": null,
216
- "metadata": {
217
- "colab": {
218
- "base_uri": "https://localhost:8080/"
219
- },
220
- "executionInfo": {
221
- "elapsed": 5979,
222
- "status": "ok",
223
- "timestamp": 1650514078414,
224
- "user": {
225
- "displayName": "Hongkun Yu",
226
- "userId": "12855578661733349593"
227
- },
228
- "user_tz": 420
229
- },
230
- "id": "xwD0UhUdSzNU",
231
- "outputId": "770d46c0-8c71-4f59-ee0b-67430c791380"
232
- },
233
- "outputs": [
234
- {
235
- "name": "stderr",
236
- "output_type": "stream",
237
- "text": [
238
- "WARNING:absl:SpineNet output level out of range [min_level, max_level] = [4, 6] will not be used for further processing.\n",
239
- "WARNING:absl:SpineNet output level out of range [min_level, max_level] = [4, 6] will not be used for further processing.\n",
240
- "WARNING:absl:SpineNet output level out of range [min_level, max_level] = [4, 6] will not be used for further processing.\n"
241
- ]
242
- },
243
- {
244
- "name": "stdout",
245
- "output_type": "stream",
246
- "text": [
247
- "spine_net\n",
248
- "{'4': \u003cKerasTensor: shape=(1, 8, 8, 128) dtype=float32 (created by layer 'spine_net')\u003e, '5': \u003cKerasTensor: shape=(1, 4, 4, 128) dtype=float32 (created by layer 'spine_net')\u003e, '6': \u003cKerasTensor: shape=(1, 2, 2, 128) dtype=float32 (created by layer 'spine_net')\u003e}\n"
249
- ]
250
- }
251
- ],
252
- "source": [
253
- "input_size = 128\n",
254
- "filter_size_scale, block_repeats, resample_alpha, endpoints_num_filters, min_level, max_level = 0.65, 1, 0.5, 128, 4, 6\n",
255
- "input_specs = tf.keras.layers.InputSpec(\n",
256
- " shape=[None, input_size, input_size, 3])\n",
257
- "model = tfm.vision.backbones.SpineNet(\n",
258
- " input_specs=input_specs,\n",
259
- " min_level=min_level,\n",
260
- " max_level=max_level,\n",
261
- " endpoints_num_filters=endpoints_num_filters,\n",
262
- " resample_alpha=resample_alpha,\n",
263
- " block_repeats=block_repeats,\n",
264
- " filter_size_scale=filter_size_scale,\n",
265
- " init_stochastic_depth_rate=0.2,\n",
266
- ")\n",
267
- "\n",
268
- "inputs = tf.keras.Input(shape=(input_size, input_size, 3), batch_size=1)\n",
269
- "endpoints = model(inputs)\n",
270
- "print(model.name)\n",
271
- "print(endpoints)"
272
- ]
273
- },
274
- {
275
- "cell_type": "markdown",
276
- "metadata": {
277
- "id": "HHJs4lRlTk8q"
278
- },
279
- "source": [
280
- "### 3. Use Orbit package for advanced training loops"
281
- ]
282
- },
283
- {
284
- "cell_type": "code",
285
- "execution_count": null,
286
- "metadata": {
287
- "colab": {
288
- "base_uri": "https://localhost:8080/"
289
- },
290
- "executionInfo": {
291
- "elapsed": 215,
292
- "status": "ok",
293
- "timestamp": 1650514185283,
294
- "user": {
295
- "displayName": "Hongkun Yu",
296
- "userId": "12855578661733349593"
297
- },
298
- "user_tz": 420
299
- },
300
- "id": "X4ek9IrJTkP_",
301
- "outputId": "7b31de68-53a0-4b8a-d9ab-109e7c43c933"
302
- },
303
- "outputs": [
304
- {
305
- "name": "stdout",
306
- "output_type": "stream",
307
- "text": [
308
- "Orbit modules: ['AbstractEvaluator', 'AbstractTrainer', 'Action', 'Controller', 'StandardEvaluator', 'StandardEvaluatorOptions', 'StandardTrainer', 'StandardTrainerOptions', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'actions', 'controller', 'runner', 'standard_runner', 'utils']\n"
309
- ]
310
- }
311
- ],
312
- "source": [
313
- "import orbit\n",
314
- "print(\"Orbit modules: \", dir(orbit))"
315
- ]
316
- }
317
- ],
318
- "metadata": {
319
- "colab": {
320
- "collapsed_sections": [],
321
- "name": "tensorflow_models_pypi",
322
- "provenance": [
323
- {
324
- "file_id": "1dm1dUZ2Bo6S6Zom7GTQrIG78Xz7iFeZY",
325
- "timestamp": 1650514452505
326
- }
327
- ]
328
- },
329
- "kernelspec": {
330
- "display_name": "Python 3",
331
- "name": "python3"
332
- },
333
- "language_info": {
334
- "name": "python"
335
- }
336
- },
337
- "nbformat": 4,
338
- "nbformat_minor": 0
339
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modeling/tensorflow_models/tensorflow_models_test.py DELETED
@@ -1,40 +0,0 @@
1
- # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """Tests for tensorflow_models imports."""
16
-
17
- import tensorflow as tf, tf_keras
18
- import tensorflow_models as tfm
19
-
20
-
21
- class TensorflowModelsTest(tf.test.TestCase):
22
-
23
- def testVisionImport(self):
24
- _ = tfm.vision.layers.SqueezeExcitation(
25
- in_filters=8, out_filters=4, se_ratio=1)
26
- _ = tfm.vision.configs.image_classification.Losses()
27
-
28
- def testNLPImport(self):
29
- _ = tfm.nlp.layers.TransformerEncoderBlock(
30
- num_attention_heads=2, inner_dim=10, inner_activation='relu')
31
- _ = tfm.nlp.tasks.TaggingTask(params=tfm.nlp.tasks.TaggingConfig())
32
-
33
- def testCommonImports(self):
34
- _ = tfm.hyperparams.Config()
35
- _ = tfm.optimization.LinearWarmup(
36
- after_warmup_lr_sched=0.0, warmup_steps=10, warmup_learning_rate=0.1)
37
-
38
-
39
- if __name__ == '__main__':
40
- tf.test.main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{modeling/official β†’ official}/README-TPU.md RENAMED
File without changes
{modeling/official β†’ official}/README.md RENAMED
File without changes
{modeling/official β†’ official}/__init__.py RENAMED
File without changes
{modeling/official β†’ official}/common/__init__.py RENAMED
File without changes
{modeling/official β†’ official}/common/dataset_fn.py RENAMED
File without changes
{modeling/official β†’ official}/common/distribute_utils.py RENAMED
File without changes
{modeling/official β†’ official}/common/distribute_utils_test.py RENAMED
File without changes
{modeling/official β†’ official}/common/flags.py RENAMED
File without changes
{modeling/official β†’ official}/common/registry_imports.py RENAMED
File without changes
{modeling/official β†’ official}/common/streamz_counters.py RENAMED
File without changes
{modeling/tensorflow_models β†’ official/core}/__init__.py RENAMED
@@ -12,12 +12,20 @@
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
 
15
- """TensorFlow Models Libraries."""
16
- # pylint: disable=wildcard-import
17
- from tensorflow_models import nlp
18
- from tensorflow_models import vision
19
 
20
- from official import core
21
- from official.modeling import hyperparams
22
- from official.modeling import optimization
23
- from official.modeling import tf_utils as utils
 
 
 
 
 
 
 
 
 
 
 
 
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
 
15
+ """Core is shared by both `nlp` and `vision`."""
 
 
 
16
 
17
+ from official.core import actions
18
+ from official.core import base_task
19
+ from official.core import base_trainer
20
+ from official.core import config_definitions
21
+ from official.core import exp_factory
22
+ from official.core import export_base
23
+ from official.core import file_writers
24
+ from official.core import input_reader
25
+ from official.core import registry
26
+ from official.core import savedmodel_checkpoint_manager
27
+ from official.core import task_factory
28
+ from official.core import tf_example_builder
29
+ from official.core import tf_example_feature_key
30
+ from official.core import train_lib
31
+ from official.core import train_utils
{modeling/official β†’ official}/core/actions.py RENAMED
@@ -19,12 +19,12 @@ from typing import List
19
  from absl import logging
20
 
21
  import gin
22
- import modeling.orbit
23
  import tensorflow as tf, tf_keras
24
 
25
- from modeling.official.core import base_trainer
26
- from modeling.official.core import config_definitions
27
- from modeling.official.modeling import optimization
28
 
29
 
30
  class PruningAction:
 
19
  from absl import logging
20
 
21
  import gin
22
+ import orbit
23
  import tensorflow as tf, tf_keras
24
 
25
+ from official.core import base_trainer
26
+ from official.core import config_definitions
27
+ from official.modeling import optimization
28
 
29
 
30
  class PruningAction:
{modeling/official β†’ official}/core/actions_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/base_task.py RENAMED
@@ -20,11 +20,11 @@ from typing import Optional
20
  from absl import logging
21
  import tensorflow as tf, tf_keras
22
 
23
- from modeling.official.core import config_definitions
24
- from modeling.official.modeling import optimization
25
- from modeling.official.modeling import performance
26
- from modeling.official.modeling.privacy import configs
27
- from modeling.official.modeling.privacy import ops
28
 
29
  OptimizationConfig = optimization.OptimizationConfig
30
  RuntimeConfig = config_definitions.RuntimeConfig
 
20
  from absl import logging
21
  import tensorflow as tf, tf_keras
22
 
23
+ from official.core import config_definitions
24
+ from official.modeling import optimization
25
+ from official.modeling import performance
26
+ from official.modeling.privacy import configs
27
+ from official.modeling.privacy import ops
28
 
29
  OptimizationConfig = optimization.OptimizationConfig
30
  RuntimeConfig = config_definitions.RuntimeConfig
{modeling/official β†’ official}/core/base_trainer.py RENAMED
@@ -22,12 +22,12 @@ import functools
22
  from typing import Union, Optional
23
  from absl import logging
24
  import gin
25
- import modeling.orbit as orbit
26
  import tensorflow as tf, tf_keras
27
 
28
- from modeling.official.core import base_task
29
- from modeling.official.core import config_definitions
30
- from modeling.official.modeling import optimization
31
 
32
  ExperimentConfig = config_definitions.ExperimentConfig
33
  TrainerConfig = config_definitions.TrainerConfig
 
22
  from typing import Union, Optional
23
  from absl import logging
24
  import gin
25
+ import orbit
26
  import tensorflow as tf, tf_keras
27
 
28
+ from official.core import base_task
29
+ from official.core import config_definitions
30
+ from official.modeling import optimization
31
 
32
  ExperimentConfig = config_definitions.ExperimentConfig
33
  TrainerConfig = config_definitions.TrainerConfig
{modeling/official β†’ official}/core/base_trainer_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/config_definitions.py RENAMED
@@ -17,9 +17,9 @@
17
  import dataclasses
18
  from typing import Optional, Sequence, Union
19
 
20
- from modeling.official.modeling.hyperparams import base_config
21
- from modeling.official.modeling.optimization.configs import optimization_config
22
- from modeling.official.modeling.privacy import configs as dp_configs
23
 
24
  OptimizationConfig = optimization_config.OptimizationConfig
25
 
 
17
  import dataclasses
18
  from typing import Optional, Sequence, Union
19
 
20
+ from official.modeling.hyperparams import base_config
21
+ from official.modeling.optimization.configs import optimization_config
22
+ from official.modeling.privacy import configs as dp_configs
23
 
24
  OptimizationConfig = optimization_config.OptimizationConfig
25
 
{modeling/official β†’ official}/core/exp_factory.py RENAMED
@@ -14,8 +14,8 @@
14
 
15
  """Experiment factory methods."""
16
 
17
- from modeling.official.core import config_definitions as cfg
18
- from modeling.official.core import registry
19
 
20
 
21
  _REGISTERED_CONFIGS = {}
 
14
 
15
  """Experiment factory methods."""
16
 
17
+ from official.core import config_definitions as cfg
18
+ from official.core import registry
19
 
20
 
21
  _REGISTERED_CONFIGS = {}
{modeling/official β†’ official}/core/export_base.py RENAMED
File without changes
{modeling/official β†’ official}/core/export_base_test.py RENAMED
@@ -18,7 +18,7 @@ from typing import Any, Dict, Mapping, Text
18
 
19
  import tensorflow as tf, tf_keras
20
 
21
- from modeling.official.core import export_base
22
 
23
 
24
  class TestModule(export_base.ExportModule):
 
18
 
19
  import tensorflow as tf, tf_keras
20
 
21
+ from official.core import export_base
22
 
23
 
24
  class TestModule(export_base.ExportModule):
{modeling/official β†’ official}/core/file_writers.py RENAMED
File without changes
{modeling/official β†’ official}/core/file_writers_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/input_reader.py RENAMED
@@ -21,7 +21,7 @@ from absl import logging
21
  import tensorflow as tf, tf_keras
22
  import tensorflow_datasets as tfds
23
 
24
- from modeling.official.core import config_definitions as cfg
25
 
26
 
27
  def _get_random_integer():
 
21
  import tensorflow as tf, tf_keras
22
  import tensorflow_datasets as tfds
23
 
24
+ from official.core import config_definitions as cfg
25
 
26
 
27
  def _get_random_integer():
{modeling/official β†’ official}/core/registry.py RENAMED
File without changes
{modeling/official β†’ official}/core/registry_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/savedmodel_checkpoint_manager.py RENAMED
File without changes
{modeling/official β†’ official}/core/savedmodel_checkpoint_manager_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/task_factory.py RENAMED
@@ -14,7 +14,7 @@
14
 
15
  """A global factory to register and access all registered tasks."""
16
 
17
- from modeling.official.core import registry
18
 
19
  _REGISTERED_TASK_CLS = {}
20
 
 
14
 
15
  """A global factory to register and access all registered tasks."""
16
 
17
+ from official.core import registry
18
 
19
  _REGISTERED_TASK_CLS = {}
20
 
{modeling/official β†’ official}/core/test_utils.py RENAMED
File without changes
{modeling/official β†’ official}/core/tf_example_builder.py RENAMED
File without changes
{modeling/official β†’ official}/core/tf_example_builder_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/tf_example_feature_key.py RENAMED
File without changes
{modeling/official β†’ official}/core/tf_example_feature_key_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/train_lib.py RENAMED
@@ -21,14 +21,14 @@ from typing import Any, List, Mapping, Optional, Tuple
21
  # Import libraries
22
 
23
  from absl import logging
24
- import modeling.orbit
25
  import tensorflow as tf, tf_keras
26
 
27
- from modeling.official.core import actions
28
- from modeling.official.core import base_task
29
- from modeling.official.core import base_trainer
30
- from modeling.official.core import config_definitions
31
- from modeling.official.core import train_utils
32
 
33
  maybe_create_best_ckpt_exporter = train_utils.maybe_create_best_ckpt_exporter
34
 
 
21
  # Import libraries
22
 
23
  from absl import logging
24
+ import orbit
25
  import tensorflow as tf, tf_keras
26
 
27
+ from official.core import actions
28
+ from official.core import base_task
29
+ from official.core import base_trainer
30
+ from official.core import config_definitions
31
+ from official.core import train_utils
32
 
33
  maybe_create_best_ckpt_exporter = train_utils.maybe_create_best_ckpt_exporter
34
 
{modeling/official β†’ official}/core/train_lib_test.py RENAMED
File without changes
{modeling/official β†’ official}/core/train_utils.py RENAMED
@@ -24,18 +24,18 @@ from typing import Any, Callable, Dict, List, Optional, Union
24
  from absl import logging
25
  import gin
26
  import numpy as np
27
- import modeling.orbit
28
  import tensorflow as tf, tf_keras
29
 
30
  # pylint: disable=g-direct-tensorflow-import
31
  from tensorflow.python.framework import ops
32
  from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2_as_graph
33
  # pylint: enable=g-direct-tensorflow-import
34
- from modeling.official.core import base_task
35
- from modeling.official.core import base_trainer
36
- from modeling.official.core import config_definitions
37
- from modeling.official.core import exp_factory
38
- from modeling.official.modeling import hyperparams
39
 
40
 
41
  BEST_CHECKPOINT_NAME = 'best_ckpt'
 
24
  from absl import logging
25
  import gin
26
  import numpy as np
27
+ import orbit
28
  import tensorflow as tf, tf_keras
29
 
30
  # pylint: disable=g-direct-tensorflow-import
31
  from tensorflow.python.framework import ops
32
  from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2_as_graph
33
  # pylint: enable=g-direct-tensorflow-import
34
+ from official.core import base_task
35
+ from official.core import base_trainer
36
+ from official.core import config_definitions
37
+ from official.core import exp_factory
38
+ from official.modeling import hyperparams
39
 
40
 
41
  BEST_CHECKPOINT_NAME = 'best_ckpt'
{modeling/official β†’ official}/core/train_utils_test.py RENAMED
File without changes
{modeling/official β†’ official}/legacy/README.md RENAMED
File without changes
{modeling/official β†’ official}/legacy/__init__.py RENAMED
File without changes
{modeling/official β†’ official}/legacy/albert/README.md RENAMED
File without changes
{modeling/official β†’ official}/legacy/albert/__init__.py RENAMED
File without changes
{modeling/official β†’ official}/legacy/albert/configs.py RENAMED
File without changes
{modeling/official β†’ official}/legacy/bert/README.md RENAMED
File without changes
{modeling/official β†’ official}/legacy/bert/__init__.py RENAMED
File without changes