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
b5574d2a
Commit
b5574d2a
authored
Mar 15, 2018
by
Christopher Shallue
Browse files
Replace dict.iteritems() with dict.items() for Python3 compatibility
parent
f5a953c8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
14 additions
and
14 deletions
+14
-14
research/astronet/astronet/astro_cnn_model/astro_cnn_model.py
...arch/astronet/astronet/astro_cnn_model/astro_cnn_model.py
+1
-1
research/astronet/astronet/astro_fc_model/astro_fc_model.py
research/astronet/astronet/astro_fc_model/astro_fc_model.py
+1
-1
research/astronet/astronet/data/generate_input_records.py
research/astronet/astronet/data/generate_input_records.py
+1
-1
research/astronet/astronet/ops/dataset_ops.py
research/astronet/astronet/ops/dataset_ops.py
+3
-3
research/astronet/astronet/ops/input_ops.py
research/astronet/astronet/ops/input_ops.py
+3
-3
research/astronet/astronet/ops/input_ops_test.py
research/astronet/astronet/ops/input_ops_test.py
+1
-1
research/astronet/astronet/ops/testing.py
research/astronet/astronet/ops/testing.py
+2
-2
research/astronet/astronet/util/config_util.py
research/astronet/astronet/util/config_util.py
+1
-1
research/astronet/astronet/util/configdict.py
research/astronet/astronet/util/configdict.py
+1
-1
No files found.
research/astronet/astronet/astro_cnn_model/astro_cnn_model.py
View file @
b5574d2a
...
@@ -130,7 +130,7 @@ class AstroCNNModel(astro_model.AstroModel):
...
@@ -130,7 +130,7 @@ class AstroCNNModel(astro_model.AstroModel):
self.time_series_hidden_layers
self.time_series_hidden_layers
"""
"""
time_series_hidden_layers
=
{}
time_series_hidden_layers
=
{}
for
name
,
time_series
in
self
.
time_series_features
.
iter
items
():
for
name
,
time_series
in
self
.
time_series_features
.
items
():
time_series_hidden_layers
[
name
]
=
self
.
_build_cnn_layers
(
time_series_hidden_layers
[
name
]
=
self
.
_build_cnn_layers
(
inputs
=
time_series
,
inputs
=
time_series
,
hparams
=
self
.
hparams
.
time_series_hidden
[
name
],
hparams
=
self
.
hparams
.
time_series_hidden
[
name
],
...
...
research/astronet/astronet/astro_fc_model/astro_fc_model.py
View file @
b5574d2a
...
@@ -151,7 +151,7 @@ class AstroFCModel(astro_model.AstroModel):
...
@@ -151,7 +151,7 @@ class AstroFCModel(astro_model.AstroModel):
self.time_series_hidden_layers
self.time_series_hidden_layers
"""
"""
time_series_hidden_layers
=
{}
time_series_hidden_layers
=
{}
for
name
,
time_series
in
self
.
time_series_features
.
iter
items
():
for
name
,
time_series
in
self
.
time_series_features
.
items
():
time_series_hidden_layers
[
name
]
=
self
.
_build_local_fc_layers
(
time_series_hidden_layers
[
name
]
=
self
.
_build_local_fc_layers
(
inputs
=
time_series
,
inputs
=
time_series
,
hparams
=
self
.
hparams
.
time_series_hidden
[
name
],
hparams
=
self
.
hparams
.
time_series_hidden
[
name
],
...
...
research/astronet/astronet/data/generate_input_records.py
View file @
b5574d2a
...
@@ -180,7 +180,7 @@ def _process_tce(tce):
...
@@ -180,7 +180,7 @@ def _process_tce(tce):
_set_float_feature
(
ex
,
"local_view"
,
local_view
)
_set_float_feature
(
ex
,
"local_view"
,
local_view
)
# Set other columns.
# Set other columns.
for
col_name
,
value
in
tce
.
iter
items
():
for
col_name
,
value
in
tce
.
items
():
if
np
.
issubdtype
(
type
(
value
),
np
.
integer
):
if
np
.
issubdtype
(
type
(
value
),
np
.
integer
):
_set_int64_feature
(
ex
,
col_name
,
[
value
])
_set_int64_feature
(
ex
,
col_name
,
[
value
])
else
:
else
:
...
...
research/astronet/astronet/ops/dataset_ops.py
View file @
b5574d2a
...
@@ -60,7 +60,7 @@ def _recursive_pad_to_batch_size(tensor_or_collection, batch_size):
...
@@ -60,7 +60,7 @@ def _recursive_pad_to_batch_size(tensor_or_collection, batch_size):
if
isinstance
(
tensor_or_collection
,
dict
):
if
isinstance
(
tensor_or_collection
,
dict
):
return
{
return
{
name
:
_recursive_pad_to_batch_size
(
t
,
batch_size
)
name
:
_recursive_pad_to_batch_size
(
t
,
batch_size
)
for
name
,
t
in
tensor_or_collection
.
iter
items
()
for
name
,
t
in
tensor_or_collection
.
items
()
}
}
if
isinstance
(
tensor_or_collection
,
collections
.
Iterable
):
if
isinstance
(
tensor_or_collection
,
collections
.
Iterable
):
...
@@ -197,7 +197,7 @@ def build_dataset(file_pattern,
...
@@ -197,7 +197,7 @@ def build_dataset(file_pattern,
# Set specifications for parsing the features.
# Set specifications for parsing the features.
data_fields
=
{
data_fields
=
{
feature_name
:
tf
.
FixedLenFeature
([
feature
.
length
],
tf
.
float32
)
feature_name
:
tf
.
FixedLenFeature
([
feature
.
length
],
tf
.
float32
)
for
feature_name
,
feature
in
input_config
.
features
.
iter
items
()
for
feature_name
,
feature
in
input_config
.
features
.
items
()
}
}
if
include_labels
:
if
include_labels
:
data_fields
[
input_config
.
label_feature
]
=
tf
.
FixedLenFeature
([],
data_fields
[
input_config
.
label_feature
]
=
tf
.
FixedLenFeature
([],
...
@@ -217,7 +217,7 @@ def build_dataset(file_pattern,
...
@@ -217,7 +217,7 @@ def build_dataset(file_pattern,
# Reorganize outputs.
# Reorganize outputs.
output
=
{}
output
=
{}
for
feature_name
,
value
in
parsed_features
.
iter
items
():
for
feature_name
,
value
in
parsed_features
.
items
():
if
include_labels
and
feature_name
==
input_config
.
label_feature
:
if
include_labels
and
feature_name
==
input_config
.
label_feature
:
label_id
=
label_to_id
.
lookup
(
value
)
label_id
=
label_to_id
.
lookup
(
value
)
# Ensure that the label_id is nonnegative to verify a successful hash
# Ensure that the label_id is nonnegative to verify a successful hash
...
...
research/astronet/astronet/ops/input_ops.py
View file @
b5574d2a
...
@@ -37,9 +37,9 @@ def prepare_feed_dict(model, features, labels=None, is_training=None):
...
@@ -37,9 +37,9 @@ def prepare_feed_dict(model, features, labels=None, is_training=None):
feed_dict: A dictionary of input Tensor to numpy array.
feed_dict: A dictionary of input Tensor to numpy array.
"""
"""
feed_dict
=
{}
feed_dict
=
{}
for
feature
,
tensor
in
model
.
time_series_features
.
iter
items
():
for
feature
,
tensor
in
model
.
time_series_features
.
items
():
feed_dict
[
tensor
]
=
features
[
"time_series_features"
][
feature
]
feed_dict
[
tensor
]
=
features
[
"time_series_features"
][
feature
]
for
feature
,
tensor
in
model
.
aux_features
.
iter
items
():
for
feature
,
tensor
in
model
.
aux_features
.
items
():
feed_dict
[
tensor
]
=
features
[
"aux_features"
][
feature
]
feed_dict
[
tensor
]
=
features
[
"aux_features"
][
feature
]
if
labels
is
not
None
:
if
labels
is
not
None
:
...
@@ -65,7 +65,7 @@ def build_feature_placeholders(config):
...
@@ -65,7 +65,7 @@ def build_feature_placeholders(config):
"""
"""
batch_size
=
None
# Batch size will be dynamically specified.
batch_size
=
None
# Batch size will be dynamically specified.
features
=
{
"time_series_features"
:
{},
"aux_features"
:
{}}
features
=
{
"time_series_features"
:
{},
"aux_features"
:
{}}
for
feature_name
,
feature_spec
in
config
.
iter
items
():
for
feature_name
,
feature_spec
in
config
.
items
():
placeholder
=
tf
.
placeholder
(
placeholder
=
tf
.
placeholder
(
dtype
=
tf
.
float32
,
dtype
=
tf
.
float32
,
shape
=
[
batch_size
,
feature_spec
.
length
],
shape
=
[
batch_size
,
feature_spec
.
length
],
...
...
research/astronet/astronet/ops/input_ops_test.py
View file @
b5574d2a
...
@@ -39,7 +39,7 @@ class InputOpsTest(tf.test.TestCase):
...
@@ -39,7 +39,7 @@ class InputOpsTest(tf.test.TestCase):
for
feature_type
in
features
:
for
feature_type
in
features
:
actual_shapes
[
feature_type
]
=
{
actual_shapes
[
feature_type
]
=
{
feature
:
tensor
.
shape
.
as_list
()
feature
:
tensor
.
shape
.
as_list
()
for
feature
,
tensor
in
features
[
feature_type
].
iter
items
()
for
feature
,
tensor
in
features
[
feature_type
].
items
()
}
}
self
.
assertDictEqual
(
expected_shapes
,
actual_shapes
)
self
.
assertDictEqual
(
expected_shapes
,
actual_shapes
)
...
...
research/astronet/astronet/ops/testing.py
View file @
b5574d2a
...
@@ -50,11 +50,11 @@ def fake_features(feature_spec, batch_size):
...
@@ -50,11 +50,11 @@ def fake_features(feature_spec, batch_size):
features
=
{}
features
=
{}
features
[
"time_series_features"
]
=
{
features
[
"time_series_features"
]
=
{
name
:
np
.
random
.
random
([
batch_size
,
spec
[
"length"
]])
name
:
np
.
random
.
random
([
batch_size
,
spec
[
"length"
]])
for
name
,
spec
in
feature_spec
.
iter
items
()
if
spec
[
"is_time_series"
]
for
name
,
spec
in
feature_spec
.
items
()
if
spec
[
"is_time_series"
]
}
}
features
[
"aux_features"
]
=
{
features
[
"aux_features"
]
=
{
name
:
np
.
random
.
random
([
batch_size
,
spec
[
"length"
]])
name
:
np
.
random
.
random
([
batch_size
,
spec
[
"length"
]])
for
name
,
spec
in
feature_spec
.
iter
items
()
if
not
spec
[
"is_time_series"
]
for
name
,
spec
in
feature_spec
.
items
()
if
not
spec
[
"is_time_series"
]
}
}
return
features
return
features
...
...
research/astronet/astronet/util/config_util.py
View file @
b5574d2a
...
@@ -110,7 +110,7 @@ def unflatten(flat_config):
...
@@ -110,7 +110,7 @@ def unflatten(flat_config):
A dictionary nested according to the keys of the input dictionary.
A dictionary nested according to the keys of the input dictionary.
"""
"""
config
=
{}
config
=
{}
for
path
,
value
in
flat_config
.
iter
items
():
for
path
,
value
in
flat_config
.
items
():
path
=
path
.
split
(
"."
)
path
=
path
.
split
(
"."
)
final_key
=
path
.
pop
()
final_key
=
path
.
pop
()
nested_config
=
config
nested_config
=
config
...
...
research/astronet/astronet/util/configdict.py
View file @
b5574d2a
...
@@ -41,7 +41,7 @@ class ConfigDict(dict):
...
@@ -41,7 +41,7 @@ class ConfigDict(dict):
parameters.
parameters.
"""
"""
if
initial_dictionary
:
if
initial_dictionary
:
for
field
,
value
in
initial_dictionary
.
iter
items
():
for
field
,
value
in
initial_dictionary
.
items
():
initial_dictionary
[
field
]
=
_maybe_convert_dict
(
value
)
initial_dictionary
[
field
]
=
_maybe_convert_dict
(
value
)
super
(
ConfigDict
,
self
).
__init__
(
initial_dictionary
)
super
(
ConfigDict
,
self
).
__init__
(
initial_dictionary
)
...
...
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