Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
166f887c
Commit
166f887c
authored
Jun 16, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Jun 16, 2020
Browse files
Make the base task as metaclass and decorate methods not implemented.
PiperOrigin-RevId: 316712226
parent
802488f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
official/core/base_task.py
official/core/base_task.py
+5
-3
No files found.
official/core/base_task.py
View file @
166f887c
...
...
@@ -14,15 +14,18 @@
# limitations under the License.
# ==============================================================================
"""Defines the base task abstraction."""
import
abc
import
functools
from
typing
import
Any
,
Callable
,
Optional
import
six
import
tensorflow
as
tf
from
official.modeling.hyperparams
import
config_definitions
as
cfg
from
official.utils
import
registry
@
six
.
add_metaclass
(
abc
.
ABCMeta
)
class
Task
(
tf
.
Module
):
"""A single-replica view of training procedure.
...
...
@@ -54,14 +57,13 @@ class Task(tf.Module):
"""
pass
@
abc
.
abstractmethod
def
build_model
(
self
)
->
tf
.
keras
.
Model
:
"""Creates the model architecture.
Returns:
A model instance.
"""
# TODO(hongkuny): the base task should call network factory.
pass
def
compile_model
(
self
,
model
:
tf
.
keras
.
Model
,
...
...
@@ -98,6 +100,7 @@ class Task(tf.Module):
model
.
test_step
=
functools
.
partial
(
validation_step
,
model
=
model
)
return
model
@
abc
.
abstractmethod
def
build_inputs
(
self
,
params
:
cfg
.
DataConfig
,
input_context
:
Optional
[
tf
.
distribute
.
InputContext
]
=
None
):
...
...
@@ -112,7 +115,6 @@ class Task(tf.Module):
Returns:
A nested structure of per-replica input functions.
"""
pass
def
build_losses
(
self
,
labels
,
model_outputs
,
aux_losses
=
None
)
->
tf
.
Tensor
:
"""Standard interface to compute losses.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment