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
9f3b338c
Commit
9f3b338c
authored
Apr 21, 2021
by
Yeqing Li
Committed by
A. Unique TensorFlower
Apr 21, 2021
Browse files
Internal change
PiperOrigin-RevId: 369741002
parent
40b9872a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
official/vision/beta/projects/assemblenet/train_test.py
official/vision/beta/projects/assemblenet/train_test.py
+101
-0
No files found.
official/vision/beta/projects/assemblenet/train_test.py
0 → 100644
View file @
9f3b338c
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
import
json
import
os
import
random
from
absl
import
flags
from
absl
import
logging
from
absl.testing
import
flagsaver
import
tensorflow
as
tf
from
official.vision.beta.dataloaders
import
tfexample_utils
from
official.vision.beta.projects.assemblenet
import
train
as
train_lib
FLAGS
=
flags
.
FLAGS
class
TrainTest
(
tf
.
test
.
TestCase
):
def
setUp
(
self
):
super
(
TrainTest
,
self
).
setUp
()
self
.
_model_dir
=
os
.
path
.
join
(
self
.
get_temp_dir
(),
'model_dir'
)
tf
.
io
.
gfile
.
makedirs
(
self
.
_model_dir
)
data_dir
=
os
.
path
.
join
(
self
.
get_temp_dir
(),
'data'
)
tf
.
io
.
gfile
.
makedirs
(
data_dir
)
self
.
_data_path
=
os
.
path
.
join
(
data_dir
,
'data.tfrecord'
)
# pylint: disable=g-complex-comprehension
examples
=
[
tfexample_utils
.
make_video_test_example
(
image_shape
=
(
36
,
36
,
3
),
audio_shape
=
(
20
,
128
),
label
=
random
.
randint
(
0
,
100
))
for
_
in
range
(
2
)
]
# pylint: enable=g-complex-comprehension
tfexample_utils
.
dump_to_tfrecord
(
self
.
_data_path
,
tf_examples
=
examples
)
def
test_run
(
self
):
saved_flag_values
=
flagsaver
.
save_flag_values
()
train_lib
.
tfm_flags
.
define_flags
()
FLAGS
.
mode
=
'train'
FLAGS
.
model_dir
=
self
.
_model_dir
FLAGS
.
experiment
=
'assemblenet50_kinetics600'
logging
.
info
(
'Test pipeline correctness.'
)
num_frames
=
4
params_override
=
json
.
dumps
({
'trainer'
:
{
'train_steps'
:
1
,
'validation_steps'
:
1
,
},
'task'
:
{
'model'
:
{
'backbone'
:
{
'assemblenet'
:
{
'model_id'
:
'26'
,
'num_frames'
:
num_frames
,
},
},
},
'train_data'
:
{
'input_path'
:
self
.
_data_path
,
'file_type'
:
'tfrecord'
,
'feature_shape'
:
[
num_frames
,
32
,
32
,
3
],
'global_batch_size'
:
2
,
},
'validation_data'
:
{
'input_path'
:
self
.
_data_path
,
'file_type'
:
'tfrecord'
,
'global_batch_size'
:
2
,
'feature_shape'
:
[
num_frames
*
2
,
32
,
32
,
3
],
}
}
})
FLAGS
.
params_override
=
params_override
train_lib
.
main
(
'unused_args'
)
FLAGS
.
mode
=
'eval'
with
train_lib
.
gin
.
unlock_config
():
train_lib
.
main
(
'unused_args'
)
flagsaver
.
restore_flag_values
(
saved_flag_values
)
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
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