This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from rsepassi/push
v1.0.13
- Loading branch information
Showing
28 changed files
with
893 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,18 @@ | |
|
||
setup( | ||
name='tensor2tensor', | ||
version='1.0.12', | ||
version='1.0.13', | ||
description='Tensor2Tensor', | ||
author='Google Inc.', | ||
author_email='[email protected]', | ||
url='http://github.com/tensorflow/tensor2tensor', | ||
license='Apache 2.0', | ||
packages=find_packages(), | ||
scripts=['tensor2tensor/bin/t2t-trainer', 'tensor2tensor/bin/t2t-datagen'], | ||
scripts=[ | ||
'tensor2tensor/bin/t2t-trainer', | ||
'tensor2tensor/bin/t2t-datagen', | ||
'tensor2tensor/bin/t2t-make-tf-configs', | ||
], | ||
install_requires=[ | ||
'numpy', | ||
'sympy', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright 2017 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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"""Inspect a TFRecord file of tensorflow.Example and show tokenizations. | ||
python data_generators/inspect.py \ | ||
--logtostderr \ | ||
--print_targets \ | ||
--subword_text_encoder_filename=$DATA_DIR/tokens.vocab.8192 \ | ||
--input_filename=$DATA_DIR/wmt_ende_tokens_8k-train-00000-of-00100 | ||
""" | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
# Dependency imports | ||
|
||
from tensor2tensor.data_generators import text_encoder | ||
|
||
import tensorflow as tf | ||
|
||
tf.app.flags.DEFINE_string("subword_text_encoder_filename", "", | ||
"SubwordTextEncoder vocabulary file") | ||
tf.app.flags.DEFINE_string("input_filename", "", "input filename") | ||
tf.app.flags.DEFINE_bool("print_inputs", False, | ||
"Print decoded inputs to stdout") | ||
tf.app.flags.DEFINE_bool("print_targets", False, | ||
"Print decoded targets to stdout") | ||
|
||
FLAGS = tf.app.flags.FLAGS | ||
|
||
|
||
def main(_): | ||
"""Convert a file to examples.""" | ||
if FLAGS.subword_text_encoder_filename: | ||
encoder = text_encoder.SubwordTextEncoder( | ||
FLAGS.subword_text_encoder_filename) | ||
else: | ||
encoder = None | ||
reader = tf.python_io.tf_record_iterator(FLAGS.input_filename) | ||
total_sequences = 0 | ||
total_input_tokens = 0 | ||
total_target_tokens = 0 | ||
max_input_length = 0 | ||
max_target_length = 0 | ||
for record in reader: | ||
x = tf.train.Example() | ||
x.ParseFromString(record) | ||
inputs = [int(i) for i in x.features.feature["inputs"].int64_list.value] | ||
targets = [int(i) for i in x.features.feature["targets"].int64_list.value] | ||
if FLAGS.print_inputs: | ||
print(encoder.decode(inputs) if encoder else inputs) | ||
if FLAGS.print_targets: | ||
print(encoder.decode(targets) if encoder else targets) | ||
total_input_tokens += len(inputs) | ||
total_target_tokens += len(targets) | ||
total_sequences += 1 | ||
max_input_length = max(max_input_length, len(inputs)) | ||
max_target_length = max(max_target_length, len(targets)) | ||
|
||
tf.logging.info("total_sequences: %d", total_sequences) | ||
tf.logging.info("total_input_tokens: %d", total_input_tokens) | ||
tf.logging.info("total_target_tokens: %d", total_target_tokens) | ||
tf.logging.info("max_input_length: %d", max_input_length) | ||
tf.logging.info("max_target_length: %d", max_target_length) | ||
|
||
|
||
if __name__ == "__main__": | ||
tf.app.run() |
Oops, something went wrong.