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
ae0a9409
Commit
ae0a9409
authored
Jan 24, 2018
by
cclauss
Browse files
Fix Python 3 Syntax Errors (en masse)
parent
eb7c6e43
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
25 deletions
+32
-25
research/real_nvp/real_nvp_multiscale_dataset.py
research/real_nvp/real_nvp_multiscale_dataset.py
+17
-14
research/street/python/vgsl_model.py
research/street/python/vgsl_model.py
+3
-1
research/swivel/prep.py
research/swivel/prep.py
+3
-2
research/swivel/text2bin.py
research/swivel/text2bin.py
+1
-1
research/syntaxnet/dragnn/python/graph_builder.py
research/syntaxnet/dragnn/python/graph_builder.py
+1
-1
research/syntaxnet/syntaxnet/conll2tree.py
research/syntaxnet/syntaxnet/conll2tree.py
+3
-3
research/tcn/alignment.py
research/tcn/alignment.py
+2
-2
research/tcn/dataset/webcam.py
research/tcn/dataset/webcam.py
+2
-1
No files found.
research/real_nvp/real_nvp_multiscale_dataset.py
View file @
ae0a9409
...
@@ -23,11 +23,14 @@ $ python real_nvp_multiscale_dataset.py \
...
@@ -23,11 +23,14 @@ $ python real_nvp_multiscale_dataset.py \
--data_path [DATA_PATH]
--data_path [DATA_PATH]
"""
"""
from
__future__
import
print_function
import
time
import
time
from
datetime
import
datetime
from
datetime
import
datetime
import
os
import
os
import
numpy
import
numpy
from
six.moves
import
xrange
import
tensorflow
as
tf
import
tensorflow
as
tf
from
tensorflow
import
gfile
from
tensorflow
import
gfile
...
@@ -1435,10 +1438,10 @@ class RealNVP(object):
...
@@ -1435,10 +1438,10 @@ class RealNVP(object):
n_equal
=
int
(
n_equal
)
n_equal
=
int
(
n_equal
)
n_dash
=
bar_len
-
n_equal
n_dash
=
bar_len
-
n_equal
progress_bar
=
"["
+
"="
*
n_equal
+
"-"
*
n_dash
+
"]
\r
"
progress_bar
=
"["
+
"="
*
n_equal
+
"-"
*
n_dash
+
"]
\r
"
print
progress_bar
,
print
(
progress_bar
,
end
=
' '
)
cost
=
self
.
bit_per_dim
.
eval
()
cost
=
self
.
bit_per_dim
.
eval
()
eval_costs
.
append
(
cost
)
eval_costs
.
append
(
cost
)
print
""
print
(
""
)
return
float
(
numpy
.
mean
(
eval_costs
))
return
float
(
numpy
.
mean
(
eval_costs
))
...
@@ -1467,7 +1470,7 @@ def train_model(hps, logdir):
...
@@ -1467,7 +1470,7 @@ def train_model(hps, logdir):
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
logdir
)
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
logdir
)
if
ckpt_state
and
ckpt_state
.
model_checkpoint_path
:
if
ckpt_state
and
ckpt_state
.
model_checkpoint_path
:
print
"Loading file %s"
%
ckpt_state
.
model_checkpoint_path
print
(
"Loading file %s"
%
ckpt_state
.
model_checkpoint_path
)
saver
.
restore
(
sess
,
ckpt_state
.
model_checkpoint_path
)
saver
.
restore
(
sess
,
ckpt_state
.
model_checkpoint_path
)
# Start the queue runners.
# Start the queue runners.
...
@@ -1499,8 +1502,8 @@ def train_model(hps, logdir):
...
@@ -1499,8 +1502,8 @@ def train_model(hps, logdir):
format_str
=
(
'%s: step %d, loss = %.2f '
format_str
=
(
'%s: step %d, loss = %.2f '
'(%.1f examples/sec; %.3f '
'(%.1f examples/sec; %.3f '
'sec/batch)'
)
'sec/batch)'
)
print
format_str
%
(
datetime
.
now
(),
global_step_val
,
loss
,
print
(
format_str
%
(
datetime
.
now
(),
global_step_val
,
loss
,
examples_per_sec
,
duration
)
examples_per_sec
,
duration
)
)
if
should_eval_summaries
:
if
should_eval_summaries
:
summary_str
=
outputs
[
-
1
]
summary_str
=
outputs
[
-
1
]
...
@@ -1542,24 +1545,24 @@ def evaluate(hps, logdir, traindir, subset="valid", return_val=False):
...
@@ -1542,24 +1545,24 @@ def evaluate(hps, logdir, traindir, subset="valid", return_val=False):
while
True
:
while
True
:
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
traindir
)
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
traindir
)
if
not
(
ckpt_state
and
ckpt_state
.
model_checkpoint_path
):
if
not
(
ckpt_state
and
ckpt_state
.
model_checkpoint_path
):
print
"No model to eval yet at %s"
%
traindir
print
(
"No model to eval yet at %s"
%
traindir
)
time
.
sleep
(
30
)
time
.
sleep
(
30
)
continue
continue
print
"Loading file %s"
%
ckpt_state
.
model_checkpoint_path
print
(
"Loading file %s"
%
ckpt_state
.
model_checkpoint_path
)
saver
.
restore
(
sess
,
ckpt_state
.
model_checkpoint_path
)
saver
.
restore
(
sess
,
ckpt_state
.
model_checkpoint_path
)
current_step
=
tf
.
train
.
global_step
(
sess
,
eval_model
.
step
)
current_step
=
tf
.
train
.
global_step
(
sess
,
eval_model
.
step
)
if
current_step
==
previous_global_step
:
if
current_step
==
previous_global_step
:
print
"Waiting for the checkpoint to be updated."
print
(
"Waiting for the checkpoint to be updated."
)
time
.
sleep
(
30
)
time
.
sleep
(
30
)
continue
continue
previous_global_step
=
current_step
previous_global_step
=
current_step
print
"Evaluating..."
print
(
"Evaluating..."
)
bit_per_dim
=
eval_model
.
eval_epoch
(
hps
)
bit_per_dim
=
eval_model
.
eval_epoch
(
hps
)
print
(
"Epoch: %d, %s -> %.3f bits/dim"
print
(
"Epoch: %d, %s -> %.3f bits/dim"
%
(
current_step
,
subset
,
bit_per_dim
))
%
(
current_step
,
subset
,
bit_per_dim
))
print
"Writing summary..."
print
(
"Writing summary..."
)
summary
=
tf
.
Summary
()
summary
=
tf
.
Summary
()
summary
.
value
.
extend
(
summary
.
value
.
extend
(
[
tf
.
Summary
.
Value
(
[
tf
.
Summary
.
Value
(
...
@@ -1597,7 +1600,7 @@ def sample_from_model(hps, logdir, traindir):
...
@@ -1597,7 +1600,7 @@ def sample_from_model(hps, logdir, traindir):
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
traindir
)
ckpt_state
=
tf
.
train
.
get_checkpoint_state
(
traindir
)
if
not
(
ckpt_state
and
ckpt_state
.
model_checkpoint_path
):
if
not
(
ckpt_state
and
ckpt_state
.
model_checkpoint_path
):
if
not
initialized
:
if
not
initialized
:
print
"No model to eval yet at %s"
%
traindir
print
(
"No model to eval yet at %s"
%
traindir
)
time
.
sleep
(
30
)
time
.
sleep
(
30
)
continue
continue
else
:
else
:
...
@@ -1607,7 +1610,7 @@ def sample_from_model(hps, logdir, traindir):
...
@@ -1607,7 +1610,7 @@ def sample_from_model(hps, logdir, traindir):
current_step
=
tf
.
train
.
global_step
(
sess
,
eval_model
.
step
)
current_step
=
tf
.
train
.
global_step
(
sess
,
eval_model
.
step
)
if
current_step
==
previous_global_step
:
if
current_step
==
previous_global_step
:
print
"Waiting for the checkpoint to be updated."
print
(
"Waiting for the checkpoint to be updated."
)
time
.
sleep
(
30
)
time
.
sleep
(
30
)
continue
continue
previous_global_step
=
current_step
previous_global_step
=
current_step
...
...
research/street/python/vgsl_model.py
View file @
ae0a9409
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
# ==============================================================================
# ==============================================================================
"""String network description language to define network layouts."""
"""String network description language to define network layouts."""
from
__future__
import
print_function
import
re
import
re
import
time
import
time
...
@@ -170,7 +172,7 @@ def Eval(train_dir,
...
@@ -170,7 +172,7 @@ def Eval(train_dir,
_AddRateToSummary
(
'Sequence error rate'
,
rates
.
sequence_error
,
step
,
_AddRateToSummary
(
'Sequence error rate'
,
rates
.
sequence_error
,
step
,
sw
)
sw
)
sw
.
flush
()
sw
.
flush
()
print
'Error rates='
,
rates
print
(
'Error rates='
,
rates
)
else
:
else
:
raise
ValueError
(
'Non-softmax decoder evaluation not implemented!'
)
raise
ValueError
(
'Non-softmax decoder evaluation not implemented!'
)
if
eval_interval_secs
:
if
eval_interval_secs
:
...
...
research/swivel/prep.py
View file @
ae0a9409
...
@@ -61,6 +61,7 @@ import os
...
@@ -61,6 +61,7 @@ import os
import
struct
import
struct
import
sys
import
sys
from
six.moves
import
xrange
import
tensorflow
as
tf
import
tensorflow
as
tf
flags
=
tf
.
app
.
flags
flags
=
tf
.
app
.
flags
...
@@ -118,7 +119,7 @@ def create_vocabulary(lines):
...
@@ -118,7 +119,7 @@ def create_vocabulary(lines):
if
not
num_words
:
if
not
num_words
:
raise
Exception
(
'empty vocabulary'
)
raise
Exception
(
'empty vocabulary'
)
print
'vocabulary contains %d tokens'
%
num_words
print
(
'vocabulary contains %d tokens'
%
num_words
)
vocab
=
vocab
[:
num_words
]
vocab
=
vocab
[:
num_words
]
return
[
tok
for
tok
,
n
in
vocab
]
return
[
tok
for
tok
,
n
in
vocab
]
...
@@ -309,7 +310,7 @@ def main(_):
...
@@ -309,7 +310,7 @@ def main(_):
write_vocab_and_sums
(
vocab
,
sums
,
'row_vocab.txt'
,
'row_sums.txt'
)
write_vocab_and_sums
(
vocab
,
sums
,
'row_vocab.txt'
,
'row_sums.txt'
)
write_vocab_and_sums
(
vocab
,
sums
,
'col_vocab.txt'
,
'col_sums.txt'
)
write_vocab_and_sums
(
vocab
,
sums
,
'col_vocab.txt'
,
'col_sums.txt'
)
print
'done!'
print
(
'done!'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
research/swivel/text2bin.py
View file @
ae0a9409
...
@@ -49,7 +49,7 @@ import sys
...
@@ -49,7 +49,7 @@ import sys
try
:
try
:
opts
,
args
=
getopt
(
opts
,
args
=
getopt
(
sys
.
argv
[
1
:],
'o:v:'
,
[
'output='
,
'vocab='
])
sys
.
argv
[
1
:],
'o:v:'
,
[
'output='
,
'vocab='
])
except
GetoptError
,
e
:
except
GetoptError
as
e
:
print
>>
sys
.
stderr
,
e
print
>>
sys
.
stderr
,
e
sys
.
exit
(
2
)
sys
.
exit
(
2
)
...
...
research/syntaxnet/dragnn/python/graph_builder.py
View file @
ae0a9409
...
@@ -28,7 +28,7 @@ from syntaxnet.util import check
...
@@ -28,7 +28,7 @@ from syntaxnet.util import check
try
:
try
:
tf
.
NotDifferentiable
(
'ExtractFixedFeatures'
)
tf
.
NotDifferentiable
(
'ExtractFixedFeatures'
)
except
KeyError
,
e
:
except
KeyError
as
e
:
logging
.
info
(
str
(
e
))
logging
.
info
(
str
(
e
))
...
...
research/syntaxnet/syntaxnet/conll2tree.py
View file @
ae0a9409
...
@@ -88,12 +88,12 @@ def main(unused_argv):
...
@@ -88,12 +88,12 @@ def main(unused_argv):
sentence
.
ParseFromString
(
d
)
sentence
.
ParseFromString
(
d
)
tr
=
asciitree
.
LeftAligned
()
tr
=
asciitree
.
LeftAligned
()
d
=
to_dict
(
sentence
)
d
=
to_dict
(
sentence
)
print
'Input: %s'
%
sentence
.
text
print
(
'Input: %s'
%
sentence
.
text
)
print
'Parse:'
print
(
'Parse:'
)
tr_str
=
tr
(
d
)
tr_str
=
tr
(
d
)
pat
=
re
.
compile
(
r
'\s*@\d+$'
)
pat
=
re
.
compile
(
r
'\s*@\d+$'
)
for
tr_ln
in
tr_str
.
splitlines
():
for
tr_ln
in
tr_str
.
splitlines
():
print
pat
.
sub
(
''
,
tr_ln
)
print
(
pat
.
sub
(
''
,
tr_ln
)
)
if
finished
:
if
finished
:
break
break
...
...
research/tcn/alignment.py
View file @
ae0a9409
...
@@ -76,9 +76,9 @@ def compute_average_alignment(
...
@@ -76,9 +76,9 @@ def compute_average_alignment(
alignment
=
np
.
mean
(
alignment
=
np
.
mean
(
np
.
abs
(
np
.
array
(
times_i
)
-
np
.
array
(
times_j
))
/
float
(
seq_len
))
np
.
abs
(
np
.
array
(
times_i
)
-
np
.
array
(
times_j
))
/
float
(
seq_len
))
all_alignments
.
append
(
alignment
)
all_alignments
.
append
(
alignment
)
print
'alignment so far %f'
%
alignment
print
(
'alignment so far %f'
%
alignment
)
average_alignment
=
np
.
mean
(
all_alignments
)
average_alignment
=
np
.
mean
(
all_alignments
)
print
'Average alignment %f'
%
average_alignment
print
(
'Average alignment %f'
%
average_alignment
)
summ
=
tf
.
Summary
(
value
=
[
tf
.
Summary
.
Value
(
summ
=
tf
.
Summary
(
value
=
[
tf
.
Summary
.
Value
(
tag
=
'validation/alignment'
,
simple_value
=
average_alignment
)])
tag
=
'validation/alignment'
,
simple_value
=
average_alignment
)])
summary_writer
.
add_summary
(
summ
,
int
(
training_step
))
summary_writer
.
add_summary
(
summ
,
int
(
training_step
))
...
...
research/tcn/dataset/webcam.py
View file @
ae0a9409
...
@@ -58,6 +58,7 @@ matplotlib.use('TkAgg')
...
@@ -58,6 +58,7 @@ matplotlib.use('TkAgg')
from
matplotlib
import
animation
# pylint: disable=g-import-not-at-top
from
matplotlib
import
animation
# pylint: disable=g-import-not-at-top
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
from
six.moves
import
input
import
tensorflow
as
tf
import
tensorflow
as
tf
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
...
@@ -438,7 +439,7 @@ def main(_):
...
@@ -438,7 +439,7 @@ def main(_):
tf
.
logging
.
info
(
'About to write to:'
)
tf
.
logging
.
info
(
'About to write to:'
)
for
v
in
view_dirs
:
for
v
in
view_dirs
:
tf
.
logging
.
info
(
v
)
tf
.
logging
.
info
(
v
)
raw_
input
(
'Press Enter to continue...'
)
input
(
'Press Enter to continue...'
)
except
SyntaxError
:
except
SyntaxError
:
pass
pass
...
...
Prev
1
2
Next
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