Unverified Commit 00fa8b12 authored by cclauss's avatar cclauss Committed by GitHub
Browse files

Merge branch 'master' into patch-13

parents 6d257a4f 1f34fcaf
...@@ -30,6 +30,8 @@ python celeba_formatting.py \ ...@@ -30,6 +30,8 @@ python celeba_formatting.py \
""" """
from __future__ import print_function
import os import os
import os.path import os.path
...@@ -70,7 +72,7 @@ def main(): ...@@ -70,7 +72,7 @@ def main():
writer = tf.python_io.TFRecordWriter(file_out) writer = tf.python_io.TFRecordWriter(file_out)
for example_idx, img_fn in enumerate(img_fn_list): for example_idx, img_fn in enumerate(img_fn_list):
if example_idx % 1000 == 0: if example_idx % 1000 == 0:
print example_idx, "/", num_examples print(example_idx, "/", num_examples)
image_raw = scipy.ndimage.imread(os.path.join(fn_root, img_fn)) image_raw = scipy.ndimage.imread(os.path.join(fn_root, img_fn))
rows = image_raw.shape[0] rows = image_raw.shape[0]
cols = image_raw.shape[1] cols = image_raw.shape[1]
......
...@@ -34,6 +34,8 @@ done ...@@ -34,6 +34,8 @@ done
""" """
from __future__ import print_function
import os import os
import os.path import os.path
...@@ -73,10 +75,10 @@ def main(): ...@@ -73,10 +75,10 @@ def main():
file_out = "%s_%05d.tfrecords" file_out = "%s_%05d.tfrecords"
file_out = file_out % (FLAGS.file_out, file_out = file_out % (FLAGS.file_out,
example_idx // n_examples_per_file) example_idx // n_examples_per_file)
print "Writing on:", file_out print("Writing on:", file_out)
writer = tf.python_io.TFRecordWriter(file_out) writer = tf.python_io.TFRecordWriter(file_out)
if example_idx % 1000 == 0: if example_idx % 1000 == 0:
print example_idx, "/", num_examples print(example_idx, "/", num_examples)
image_raw = scipy.ndimage.imread(os.path.join(fn_root, img_fn)) image_raw = scipy.ndimage.imread(os.path.join(fn_root, img_fn))
rows = image_raw.shape[0] rows = image_raw.shape[0]
cols = image_raw.shape[1] cols = image_raw.shape[1]
......
...@@ -29,6 +29,7 @@ python lsun_formatting.py \ ...@@ -29,6 +29,7 @@ python lsun_formatting.py \
--fn_root [LSUN_FOLDER] --fn_root [LSUN_FOLDER]
""" """
from __future__ import print_function
import os import os
import os.path import os.path
...@@ -68,10 +69,10 @@ def main(): ...@@ -68,10 +69,10 @@ def main():
file_out = "%s_%05d.tfrecords" file_out = "%s_%05d.tfrecords"
file_out = file_out % (FLAGS.file_out, file_out = file_out % (FLAGS.file_out,
example_idx // n_examples_per_file) example_idx // n_examples_per_file)
print "Writing on:", file_out print("Writing on:", file_out)
writer = tf.python_io.TFRecordWriter(file_out) writer = tf.python_io.TFRecordWriter(file_out)
if example_idx % 1000 == 0: if example_idx % 1000 == 0:
print example_idx, "/", num_examples print(example_idx, "/", num_examples)
image_raw = numpy.array(Image.open(os.path.join(fn_root, img_fn))) image_raw = numpy.array(Image.open(os.path.join(fn_root, img_fn)))
rows = image_raw.shape[0] rows = image_raw.shape[0]
cols = image_raw.shape[1] cols = image_raw.shape[1]
......
...@@ -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
......
...@@ -19,6 +19,7 @@ r"""Utility functions for Real NVP. ...@@ -19,6 +19,7 @@ r"""Utility functions for Real NVP.
# pylint: disable=dangerous-default-value # pylint: disable=dangerous-default-value
import numpy import numpy
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
from tensorflow.python.framework import ops from tensorflow.python.framework import ops
......
...@@ -94,6 +94,7 @@ import threading ...@@ -94,6 +94,7 @@ import threading
import google3 import google3
import numpy as np import numpy as np
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
tf.app.flags.DEFINE_string('train_directory', '/tmp/', tf.app.flags.DEFINE_string('train_directory', '/tmp/',
......
...@@ -45,7 +45,9 @@ ...@@ -45,7 +45,9 @@
# downloading the raw images. # downloading the raw images.
# #
# usage: # usage:
# ./download_and_convert_imagenet.sh [data-dir] # cd research/slim
# bazel build :download_and_convert_imagenet
# ./bazel-bin/download_and_convert_imagenet.sh [data-dir]
set -e set -e
if [ -z "$1" ]; then if [ -z "$1" ]; then
...@@ -58,7 +60,7 @@ DATA_DIR="${1%/}" ...@@ -58,7 +60,7 @@ DATA_DIR="${1%/}"
SCRATCH_DIR="${DATA_DIR}/raw-data/" SCRATCH_DIR="${DATA_DIR}/raw-data/"
mkdir -p "${DATA_DIR}" mkdir -p "${DATA_DIR}"
mkdir -p "${SCRATCH_DIR}" mkdir -p "${SCRATCH_DIR}"
WORK_DIR="$0.runfiles/third_party/tensorflow_models/research/slim" WORK_DIR="$0.runfiles/__main__"
# Download the ImageNet data. # Download the ImageNet data.
LABELS_FILE="${WORK_DIR}/datasets/imagenet_lsvrc_2015_synsets.txt" LABELS_FILE="${WORK_DIR}/datasets/imagenet_lsvrc_2015_synsets.txt"
......
...@@ -49,7 +49,7 @@ mkdir -p "${BBOX_DIR}" ...@@ -49,7 +49,7 @@ mkdir -p "${BBOX_DIR}"
cd "${OUTDIR}" cd "${OUTDIR}"
# Download and process all of the ImageNet bounding boxes. # Download and process all of the ImageNet bounding boxes.
BASE_URL="http://www.image-net.org/challenges/LSVRC/2012/nonpub" BASE_URL="http://www.image-net.org/challenges/LSVRC/2012/nnoupb"
# See here for details: http://www.image-net.org/download-bboxes # See here for details: http://www.image-net.org/download-bboxes
BOUNDING_BOX_ANNOTATIONS="${BASE_URL}/ILSVRC2012_bbox_train_v2.tar.gz" BOUNDING_BOX_ANNOTATIONS="${BASE_URL}/ILSVRC2012_bbox_train_v2.tar.gz"
......
...@@ -51,6 +51,7 @@ from __future__ import print_function ...@@ -51,6 +51,7 @@ from __future__ import print_function
import os import os
import os.path import os.path
import sys import sys
from six.moves import xrange
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -85,6 +85,7 @@ import glob ...@@ -85,6 +85,7 @@ import glob
import os.path import os.path
import sys import sys
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from six.moves import xrange
class BoundingBox(object): class BoundingBox(object):
......
...@@ -18,7 +18,7 @@ from __future__ import division ...@@ -18,7 +18,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import numpy as np import numpy as np
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
layers = tf.contrib.layers layers = tf.contrib.layers
......
...@@ -19,6 +19,7 @@ from __future__ import print_function ...@@ -19,6 +19,7 @@ from __future__ import print_function
from math import log from math import log
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
slim = tf.contrib.slim slim = tf.contrib.slim
......
...@@ -18,6 +18,7 @@ from __future__ import absolute_import ...@@ -18,6 +18,7 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
from nets import dcgan from nets import dcgan
......
...@@ -25,6 +25,7 @@ import collections ...@@ -25,6 +25,7 @@ import collections
import re import re
import errorcounter as ec import errorcounter as ec
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
# Named tuple Part describes a part of a multi (1 or more) part code that # Named tuple Part describes a part of a multi (1 or more) part code that
......
...@@ -24,6 +24,7 @@ tensor_dim: gets a shape dimension as a constant integer if known otherwise a ...@@ -24,6 +24,7 @@ tensor_dim: gets a shape dimension as a constant integer if known otherwise a
runtime usable tensor value. runtime usable tensor value.
tensor_shape: returns the full shape of a tensor as the tensor_dim. tensor_shape: returns the full shape of a tensor as the tensor_dim.
""" """
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
......
...@@ -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:
......
...@@ -23,6 +23,7 @@ from string import maketrans ...@@ -23,6 +23,7 @@ from string import maketrans
import nn_ops import nn_ops
import shapes import shapes
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
import tensorflow.contrib.slim as slim import tensorflow.contrib.slim as slim
......
...@@ -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__':
......
...@@ -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)
......
...@@ -57,10 +57,10 @@ RUN python -m pip install \ ...@@ -57,10 +57,10 @@ RUN python -m pip install \
&& rm -rf /root/.cache/pip /tmp/pip* && rm -rf /root/.cache/pip /tmp/pip*
# Installs Bazel. # Installs Bazel.
RUN wget --quiet https://github.com/bazelbuild/bazel/releases/download/0.5.4/bazel-0.5.4-installer-linux-x86_64.sh \ RUN wget --quiet https://github.com/bazelbuild/bazel/releases/download/0.8.1/bazel-0.8.1-installer-linux-x86_64.sh \
&& chmod +x bazel-0.5.4-installer-linux-x86_64.sh \ && chmod +x bazel-0.8.1-installer-linux-x86_64.sh \
&& ./bazel-0.5.4-installer-linux-x86_64.sh \ && ./bazel-0.8.1-installer-linux-x86_64.sh \
&& rm ./bazel-0.5.4-installer-linux-x86_64.sh && rm ./bazel-0.8.1-installer-linux-x86_64.sh
COPY WORKSPACE $SYNTAXNETDIR/syntaxnet/WORKSPACE COPY WORKSPACE $SYNTAXNETDIR/syntaxnet/WORKSPACE
COPY tools/bazel.rc $SYNTAXNETDIR/syntaxnet/tools/bazel.rc COPY tools/bazel.rc $SYNTAXNETDIR/syntaxnet/tools/bazel.rc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment