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
a7b60ec8
Commit
a7b60ec8
authored
Sep 04, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Sep 04, 2020
Browse files
Specify loader for yaml loading.
PiperOrigin-RevId: 330119437
parent
ffc18dfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
official/modeling/hyperparams/base_config.py
official/modeling/hyperparams/base_config.py
+1
-1
official/modeling/hyperparams/params_dict.py
official/modeling/hyperparams/params_dict.py
+3
-3
No files found.
official/modeling/hyperparams/base_config.py
View file @
a7b60ec8
...
...
@@ -227,7 +227,7 @@ class Config(params_dict.ParamsDict):
def
from_yaml
(
cls
,
file_path
:
str
):
# Note: This only works if the Config has all default values.
with
tf
.
io
.
gfile
.
GFile
(
file_path
,
'r'
)
as
f
:
loaded
=
yaml
.
load
(
f
)
loaded
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
config
=
cls
()
config
.
override
(
loaded
)
return
config
...
...
official/modeling/hyperparams/params_dict.py
View file @
a7b60ec8
...
...
@@ -317,7 +317,7 @@ class ParamsDict(object):
def
read_yaml_to_params_dict
(
file_path
):
"""Reads a YAML file to a ParamsDict."""
with
tf
.
io
.
gfile
.
GFile
(
file_path
,
'r'
)
as
f
:
params_dict
=
yaml
.
load
(
f
)
params_dict
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
return
ParamsDict
(
params_dict
)
...
...
@@ -438,12 +438,12 @@ def override_params_dict(params, dict_or_string_or_yaml_file, is_strict):
nested_csv_str_to_json_str
(
dict_or_string_or_yaml_file
))
except
ValueError
:
pass
params_dict
=
yaml
.
load
(
dict_or_string_or_yaml_file
)
params_dict
=
yaml
.
load
(
dict_or_string_or_yaml_file
,
Loader
=
yaml
.
FullLoader
)
if
isinstance
(
params_dict
,
dict
):
params
.
override
(
params_dict
,
is_strict
)
else
:
with
tf
.
io
.
gfile
.
GFile
(
dict_or_string_or_yaml_file
)
as
f
:
params
.
override
(
yaml
.
load
(
f
),
is_strict
)
params
.
override
(
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
),
is_strict
)
else
:
raise
ValueError
(
'Unknown input type to parse.'
)
return
params
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