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
7fb8b0f2
Commit
7fb8b0f2
authored
Jan 09, 2017
by
Christopher Shallue
Browse files
Replace deprecated functions
parent
2fa6057a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
im2txt/im2txt/ops/image_processing.py
im2txt/im2txt/ops/image_processing.py
+1
-1
im2txt/im2txt/ops/inputs.py
im2txt/im2txt/ops/inputs.py
+4
-4
im2txt/im2txt/show_and_tell_model.py
im2txt/im2txt/show_and_tell_model.py
+5
-5
im2txt/im2txt/show_and_tell_model_test.py
im2txt/im2txt/show_and_tell_model_test.py
+2
-2
No files found.
im2txt/im2txt/ops/image_processing.py
View file @
7fb8b0f2
...
@@ -92,7 +92,7 @@ def process_image(encoded_image,
...
@@ -92,7 +92,7 @@ def process_image(encoded_image,
# only logged in thread 0.
# only logged in thread 0.
def
image_summary
(
name
,
image
):
def
image_summary
(
name
,
image
):
if
not
thread_id
:
if
not
thread_id
:
tf
.
image_
summary
(
name
,
tf
.
expand_dims
(
image
,
0
))
tf
.
summary
.
image
(
name
,
tf
.
expand_dims
(
image
,
0
))
# Decode image into a float32 Tensor of shape [?, ?, 3] with values in [0, 1).
# Decode image into a float32 Tensor of shape [?, ?, 3] with values in [0, 1).
with
tf
.
name_scope
(
"decode"
,
values
=
[
encoded_image
]):
with
tf
.
name_scope
(
"decode"
,
values
=
[
encoded_image
]):
...
...
im2txt/im2txt/ops/inputs.py
View file @
7fb8b0f2
...
@@ -116,7 +116,7 @@ def prefetch_input_data(reader,
...
@@ -116,7 +116,7 @@ def prefetch_input_data(reader,
enqueue_ops
.
append
(
values_queue
.
enqueue
([
value
]))
enqueue_ops
.
append
(
values_queue
.
enqueue
([
value
]))
tf
.
train
.
queue_runner
.
add_queue_runner
(
tf
.
train
.
queue_runner
.
QueueRunner
(
tf
.
train
.
queue_runner
.
add_queue_runner
(
tf
.
train
.
queue_runner
.
QueueRunner
(
values_queue
,
enqueue_ops
))
values_queue
,
enqueue_ops
))
tf
.
s
calar_summary
(
tf
.
s
ummary
.
scalar
(
"queue/%s/fraction_of_%d_full"
%
(
values_queue
.
name
,
capacity
),
"queue/%s/fraction_of_%d_full"
%
(
values_queue
.
name
,
capacity
),
tf
.
cast
(
values_queue
.
size
(),
tf
.
float32
)
*
(
1.
/
capacity
))
tf
.
cast
(
values_queue
.
size
(),
tf
.
float32
)
*
(
1.
/
capacity
))
...
@@ -197,8 +197,8 @@ def batch_with_dynamic_pad(images_and_captions,
...
@@ -197,8 +197,8 @@ def batch_with_dynamic_pad(images_and_captions,
if
add_summaries
:
if
add_summaries
:
lengths
=
tf
.
add
(
tf
.
reduce_sum
(
mask
,
1
),
1
)
lengths
=
tf
.
add
(
tf
.
reduce_sum
(
mask
,
1
),
1
)
tf
.
s
calar_summary
(
"caption_length/batch_min"
,
tf
.
reduce_min
(
lengths
))
tf
.
s
ummary
.
scalar
(
"caption_length/batch_min"
,
tf
.
reduce_min
(
lengths
))
tf
.
s
calar_summary
(
"caption_length/batch_max"
,
tf
.
reduce_max
(
lengths
))
tf
.
s
ummary
.
scalar
(
"caption_length/batch_max"
,
tf
.
reduce_max
(
lengths
))
tf
.
s
calar_summary
(
"caption_length/batch_mean"
,
tf
.
reduce_mean
(
lengths
))
tf
.
s
ummary
.
scalar
(
"caption_length/batch_mean"
,
tf
.
reduce_mean
(
lengths
))
return
images
,
input_seqs
,
target_seqs
,
mask
return
images
,
input_seqs
,
target_seqs
,
mask
im2txt/im2txt/show_and_tell_model.py
View file @
7fb8b0f2
...
@@ -311,14 +311,14 @@ class ShowAndTellModel(object):
...
@@ -311,14 +311,14 @@ class ShowAndTellModel(object):
batch_loss
=
tf
.
div
(
tf
.
reduce_sum
(
tf
.
mul
(
losses
,
weights
)),
batch_loss
=
tf
.
div
(
tf
.
reduce_sum
(
tf
.
mul
(
losses
,
weights
)),
tf
.
reduce_sum
(
weights
),
tf
.
reduce_sum
(
weights
),
name
=
"batch_loss"
)
name
=
"batch_loss"
)
tf
.
contrib
.
losses
.
add_loss
(
batch_loss
)
tf
.
losses
.
add_loss
(
batch_loss
)
total_loss
=
tf
.
contrib
.
losses
.
get_total_loss
()
total_loss
=
tf
.
losses
.
get_total_loss
()
# Add summaries.
# Add summaries.
tf
.
s
calar_summary
(
"
batch_loss"
,
batch_loss
)
tf
.
s
ummary
.
scalar
(
"losses/
batch_loss"
,
batch_loss
)
tf
.
s
calar_summary
(
"
total_loss"
,
total_loss
)
tf
.
s
ummary
.
scalar
(
"losses/
total_loss"
,
total_loss
)
for
var
in
tf
.
trainable_variables
():
for
var
in
tf
.
trainable_variables
():
tf
.
histogram
_summary
(
var
.
op
.
name
,
var
)
tf
.
summary
.
histogram
(
"parameters/"
+
var
.
op
.
name
,
var
)
self
.
total_loss
=
total_loss
self
.
total_loss
=
total_loss
self
.
target_cross_entropy_losses
=
losses
# Used in evaluation.
self
.
target_cross_entropy_losses
=
losses
# Used in evaluation.
...
...
im2txt/im2txt/show_and_tell_model_test.py
View file @
7fb8b0f2
...
@@ -63,7 +63,7 @@ class ShowAndTellModelTest(tf.test.TestCase):
...
@@ -63,7 +63,7 @@ class ShowAndTellModelTest(tf.test.TestCase):
def
_countModelParameters
(
self
):
def
_countModelParameters
(
self
):
"""Counts the number of parameters in the model at top level scope."""
"""Counts the number of parameters in the model at top level scope."""
counter
=
{}
counter
=
{}
for
v
in
tf
.
a
l
l_variables
():
for
v
in
tf
.
glob
al_variables
():
name
=
v
.
op
.
name
.
split
(
"/"
)[
0
]
name
=
v
.
op
.
name
.
split
(
"/"
)[
0
]
num_params
=
v
.
get_shape
().
num_elements
()
num_params
=
v
.
get_shape
().
num_elements
()
assert
num_params
assert
num_params
...
@@ -98,7 +98,7 @@ class ShowAndTellModelTest(tf.test.TestCase):
...
@@ -98,7 +98,7 @@ class ShowAndTellModelTest(tf.test.TestCase):
fetches
=
expected_shapes
.
keys
()
fetches
=
expected_shapes
.
keys
()
with
self
.
test_session
()
as
sess
:
with
self
.
test_session
()
as
sess
:
sess
.
run
(
tf
.
initialize_
al
l
_variables
())
sess
.
run
(
tf
.
glob
al_variables
_initializer
())
outputs
=
sess
.
run
(
fetches
,
feed_dict
)
outputs
=
sess
.
run
(
fetches
,
feed_dict
)
for
index
,
output
in
enumerate
(
outputs
):
for
index
,
output
in
enumerate
(
outputs
):
...
...
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