diff options
author | 2016-09-08 20:46:46 -0800 | |
---|---|---|
committer | 2016-09-08 22:01:08 -0700 | |
commit | 7520588ffc759a7eefeee432414fa0493df818de (patch) | |
tree | 180995dc207bf802942935b346a22bbe955430bb | |
parent | 56ad910f5957d3aa2d96eb840e6da36ac4105236 (diff) |
Change read_keyed_batch_features and read_batch_features to accept custom parsing function.
Change: 132637867
-rw-r--r-- | tensorflow/contrib/learn/python/learn/learn_io/graph_io.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tensorflow/contrib/learn/python/learn/learn_io/graph_io.py b/tensorflow/contrib/learn/python/learn/learn_io/graph_io.py index 3c6d992932..d82ddb5c3b 100644 --- a/tensorflow/contrib/learn/python/learn/learn_io/graph_io.py +++ b/tensorflow/contrib/learn/python/learn/learn_io/graph_io.py @@ -235,6 +235,7 @@ def read_keyed_batch_features(file_pattern, feature_queue_capacity=100, num_queue_runners=2, parser_num_threads=None, + parse_fn=None, name=None): """Adds operations to read, queue, batch and parse `Example` protos. @@ -269,6 +270,8 @@ def read_keyed_batch_features(file_pattern, a full queue when the subsequent computations overall are cheaper than parsing. parser_num_threads: (Deprecated) The number of threads to parse examples. + parse_fn: Parsing function, takes `Example` Tensor returns parsed + representation. If `None`, no parsing is done. name: Name of resulting op. Returns: @@ -289,7 +292,7 @@ def read_keyed_batch_features(file_pattern, file_pattern, batch_size, reader, randomize_input=randomize_input, num_epochs=num_epochs, queue_capacity=queue_capacity, num_threads=reader_num_threads, read_batch_size=batch_size, - name=scope) + parse_fn=parse_fn, name=scope) # Parse the example. feature_map = parsing_ops.parse_example(examples, features) return queue_parsed_features( @@ -407,7 +410,8 @@ def queue_parsed_features(parsed_features, def read_batch_features(file_pattern, batch_size, features, reader, randomize_input=True, num_epochs=None, queue_capacity=10000, feature_queue_capacity=100, - reader_num_threads=1, parser_num_threads=1, name=None): + reader_num_threads=1, parser_num_threads=1, + parse_fn=None, name=None): """Adds operations to read, queue, batch and parse `Example` protos. Given file pattern (or list of files), will setup a queue for file names, @@ -439,6 +443,8 @@ def read_batch_features(file_pattern, batch_size, features, reader, reader_num_threads: The number of threads to read examples. parser_num_threads: The number of threads to parse examples. records to read at once + parse_fn: Parsing function, takes `Example` Tensor returns parsed + representation. If `None`, no parsing is done. name: Name of resulting op. Returns: @@ -453,7 +459,8 @@ def read_batch_features(file_pattern, batch_size, features, reader, queue_capacity=queue_capacity, feature_queue_capacity=feature_queue_capacity, reader_num_threads=reader_num_threads, - parser_num_threads=parser_num_threads, name=name) + parser_num_threads=parser_num_threads, + parse_fn=parse_fn, name=name) return features |