Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #751 from rsepassi/push
Browse files Browse the repository at this point in the history
v1.6.1
  • Loading branch information
lukaszkaiser authored Apr 26, 2018
2 parents 757b529 + 1027772 commit ed9e3bd
Show file tree
Hide file tree
Showing 213 changed files with 5,164 additions and 366 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ script:
--ignore=tensor2tensor/problems_test.py
--ignore=tensor2tensor/bin/t2t_trainer_test.py
--ignore=tensor2tensor/data_generators/algorithmic_math_test.py
--ignore=tensor2tensor/models/research/r_transformer_test.py # Requires new feature in tf.foldl (rm with TF 1.9)
- pytest tensor2tensor/utils/registry_test.py
- pytest tensor2tensor/utils/trainer_lib_test.py
- pytest tensor2tensor/visualization/visualization_test.py
Expand Down
6 changes: 4 additions & 2 deletions docs/distributed_training.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ distributed training:
Parameter servers only need `--master=grpc://$ADDRESS` and
`--schedule=run_std_server`.

>> Note about `output_dir`: All the workers (masters and parameter servers) should use the same `output_dir`. If training
>> on separate nodes, output_dir can be a shared filesystem like NFS or an object store like GCS.
>> Note about `--output_dir`: All the nodes should use the same `--output_dir`.
>> When using multiple machines, `output_dir` should point to a shared
>> filesystem like NFS or an object store like Google Cloud Storage
>> (`gs://...`).
## Utility to produce `TF_CONFIG` and flags

Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='tensor2tensor',
version='1.6.0',
version='1.6.1',
description='Tensor2Tensor',
author='Google Inc.',
author_email='[email protected]',
Expand All @@ -14,6 +14,7 @@
packages=find_packages(),
package_data={
'tensor2tensor.data_generators': ['test_data/*'],
'tensor2tensor.data_generators.wikisum': ['test_data/*'],
'tensor2tensor.visualization': [
'attention.js', 'TransformerVisualization.ipynb'
],
Expand All @@ -37,7 +38,8 @@
'gevent',
'google-api-python-client',
'gunicorn',
'gym<=0.9.5', # gym in version 0.9.6 has some temporary issues.
'gym',
'h5py',
'numpy',
'requests',
'scipy',
Expand All @@ -47,7 +49,7 @@
extras_require={
'tensorflow': ['tensorflow>=1.5.0'],
'tensorflow_gpu': ['tensorflow-gpu>=1.5.0'],
'tests': ['pytest', 'h5py', 'mock'],
'tests': ['pytest', 'mock'],
},
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/make_tf_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Output command line arguments and json-encoded TF_CONFIGs.
Usage:
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_avg_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Script to continuously average last N checkpoints in a given directory."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_bleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Evaluate BLEU score for all checkpoints/translations in a given directory.
This script can be used in two ways.
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Produces the training and dev data for --problem into --data_dir.
Produces sharded and shuffled TFRecord files of tensorflow.Example protocol
Expand Down
8 changes: 5 additions & 3 deletions tensor2tensor/bin/t2t_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

r"""Decode from trained T2T models.
This binary performs inference using the Estimator API.
Expand Down Expand Up @@ -82,9 +81,13 @@ def create_decode_hparams():

def decode(estimator, hparams, decode_hp):
if FLAGS.decode_interactive:
if estimator.config.use_tpu:
raise ValueError("TPU can only decode from dataset.")
decoding.decode_interactively(estimator, hparams, decode_hp,
checkpoint_path=FLAGS.checkpoint_path)
elif FLAGS.decode_from_file:
if estimator.config.use_tpu:
raise ValueError("TPU can only decode from dataset.")
decoding.decode_from_file(estimator, FLAGS.decode_from_file, hparams,
decode_hp, FLAGS.decode_to_file,
checkpoint_path=FLAGS.checkpoint_path)
Expand Down Expand Up @@ -160,7 +163,6 @@ def main(_):
tf.logging.set_verbosity(tf.logging.INFO)
trainer_lib.set_random_seed(FLAGS.random_seed)
usr_dir.import_usr_dir(FLAGS.t2t_usr_dir)
FLAGS.use_tpu = False # decoding not supported on TPU

if FLAGS.score_file:
filename = os.path.expanduser(FLAGS.score_file)
Expand All @@ -183,7 +185,7 @@ def main(_):
hp,
t2t_trainer.create_run_config(hp),
decode_hparams=decode_hp,
use_tpu=False)
use_tpu=FLAGS.use_tpu)

decode(estimator, hp, decode_hp)

Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_distill.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

r"""Perform distillation for a teacher to student.
This script is intended to be used with --model=distillation. See the model for
Expand Down
6 changes: 4 additions & 2 deletions tensor2tensor/bin/t2t_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Train and evaluate."""
from __future__ import absolute_import
from __future__ import division
Expand Down Expand Up @@ -87,6 +86,8 @@
"Name of Cloud TPU instance to use or create.")
flags.DEFINE_bool("cloud_delete_on_done", False,
"Whether to delete the VM and TPU instance when done.")
flags.DEFINE_bool("cloud_skip_confirmation", False,
"Whether to skip launch confirmations.")

# Google Cloud ML Engine
flags.DEFINE_bool("cloud_mlengine", False,
Expand Down Expand Up @@ -319,7 +320,8 @@ def maybe_cloud_tpu():
with cloud_tpu.cloud_tpu(
FLAGS.cloud_vm_name,
FLAGS.cloud_tpu_name,
delete_on_done=FLAGS.cloud_delete_on_done) as tpu_master:
delete_on_done=FLAGS.cloud_delete_on_done,
skip_confirmation=FLAGS.cloud_skip_confirmation) as tpu_master:
FLAGS.master = tpu_master
yield

Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_trainer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for t2t_trainer."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/bin/t2t_translate_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Translate a file with all checkpoints in a given directory.
t2t-decoder will be executed with these parameters:
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/algorithmic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Algorithmic data generators."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/algorithmic_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Algorithmic data generators for symbolic math tasks.
See go/symbolic-math-dataset
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/algorithmic_math_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for tensor2tensor.data_generators.algorithmic_math."""
# TODO(rsepassi): This test is flaky. Disable, remove, or update.

Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/algorithmic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Algorithmic generators test."""

from __future__ import absolute_import
Expand Down
35 changes: 31 additions & 4 deletions tensor2tensor/data_generators/all_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Imports for problem modules."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import importlib
import six


modules = [
Expand Down Expand Up @@ -55,12 +55,39 @@
"tensor2tensor.data_generators.translate_enzh",
"tensor2tensor.data_generators.twentybn",
"tensor2tensor.data_generators.wiki",
"tensor2tensor.data_generators.wikisum.wikisum",
"tensor2tensor.data_generators.wsj_parsing",
]


for module in modules:

def _py_err_msg(module):
if six.PY2:
msg = "No module named %s" % module.split(".")[-1]
else:
msg = "No module named '%s'" % module
return msg


def _handle_errors(errors):
"""Log out and possibly reraise errors during import."""
if not errors:
return
log_all = True # pylint: disable=unused-variable
err_msg = "Skipped importing {num_missing} data_generators modules."
print(err_msg.format(num_missing=len(errors)))
for module, err in errors:
err_str = str(err)
if err_str != _py_err_msg(module):
raise err
if log_all:
print("Did not import module: %s; Cause: %s" % (module, err_str))


_errors = []
for _module in modules:
try:
importlib.import_module(module)
importlib.import_module(_module)
except ImportError as error:
print("Did not import module: %s; Cause: %s" % (module, str(error)))
_errors.append((_module, error))
_handle_errors(_errors)
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/all_problems_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for Tensor2Tensor's all_problems.py."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""TIMIT data generator."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/audio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for tensor2tensor.data_generators.audio."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/celeba.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""CelebA."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""CIFAR."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Cipher data generators."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/cnn_dailymail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Data generators for the CNN and Daily Mail datasets."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/desc2code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Data generators for the Description2Code OpenAI data-set."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/desc2code_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for desc2code."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/dna_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Encoders for DNA data.
* DNAEncoder: ACTG strings to ints and back
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/dna_encoder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for tensor2tensor.data_generators.dna_encoder."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/fsns.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""FSNS."""

from __future__ import absolute_import
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/gene_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Gene expression problems.
Inputs are bases ACTG (with indices assigned in that order).
Expand Down
1 change: 0 additions & 1 deletion tensor2tensor/data_generators/gene_expression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for Genetics problems."""
from __future__ import absolute_import
from __future__ import division
Expand Down
Loading

0 comments on commit ed9e3bd

Please sign in to comment.