tf.contrib.data.read_batch_features
Stay organized with collections
Save and categorize content based on your preferences.
Reads batches of Examples. (deprecated)
tf.contrib.data.read_batch_features(
file_pattern, batch_size, features, reader=tf.data.TFRecordDataset,
reader_args=None, randomize_input=True, num_epochs=None, capacity=10000
)
Example:
serialized_examples = [
features {
feature { key: "age" value { int64_list { value: [ 0 ] } } }
feature { key: "gender" value { bytes_list { value: [ "f" ] } } }
feature { key: "kws" value { bytes_list { value: [ "code", "art" ] } } }
},
features {
feature { key: "age" value { int64_list { value: [] } } }
feature { key: "gender" value { bytes_list { value: [ "f" ] } } }
feature { key: "kws" value { bytes_list { value: [ "sports" ] } } }
}
]
We can use arguments:
features: {
"age": FixedLenFeature([], dtype=tf.int64, default_value=-1),
"gender": FixedLenFeature([], dtype=tf.string),
"kws": VarLenFeature(dtype=tf.string),
}
And the expected output is:
{
"age": [[0], [-1]],
"gender": [["f"], ["f"]],
"kws": SparseTensor(
indices=[[0, 0], [0, 1], [1, 0]],
values=["code", "art", "sports"]
dense_shape=[2, 2]),
}
Args |
file_pattern
|
List of files or patterns of file paths containing
Example records. See tf.io.gfile.glob for pattern rules.
|
batch_size
|
An int representing the number of records to combine
in a single batch.
|
features
|
A dict mapping feature keys to FixedLenFeature or
VarLenFeature values. See tf.io.parse_example .
|
reader
|
A function or class that can be
called with a filenames tensor and (optional) reader_args and returns
a Dataset of Example tensors. Defaults to tf.data.TFRecordDataset .
|
reader_args
|
Additional arguments to pass to the reader class.
|
randomize_input
|
Whether the input should be randomized.
|
num_epochs
|
Integer specifying the number of times to read through the
dataset. If None, cycles through the dataset forever.
|
capacity
|
Buffer size of the ShuffleDataset. A large capacity ensures better
shuffling but would increase memory usage and startup time.
|
Returns |
A dict from keys in features to Tensor or SparseTensor objects.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.read_batch_features\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/readers.py#L277-L359) |\n\nReads batches of Examples. (deprecated) \n\n tf.contrib.data.read_batch_features(\n file_pattern, batch_size, features, reader=tf.data.TFRecordDataset,\n reader_args=None, randomize_input=True, num_epochs=None, capacity=10000\n )\n\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use [`tf.data.experimental.make_batched_features_dataset(...)`](../../../tf/data/experimental/make_batched_features_dataset)\n\n#### Example:\n\n serialized_examples = [\n features {\n feature { key: \"age\" value { int64_list { value: [ 0 ] } } }\n feature { key: \"gender\" value { bytes_list { value: [ \"f\" ] } } }\n feature { key: \"kws\" value { bytes_list { value: [ \"code\", \"art\" ] } } }\n },\n features {\n feature { key: \"age\" value { int64_list { value: [] } } }\n feature { key: \"gender\" value { bytes_list { value: [ \"f\" ] } } }\n feature { key: \"kws\" value { bytes_list { value: [ \"sports\" ] } } }\n }\n ]\n\n#### We can use arguments:\n\n features: {\n \"age\": FixedLenFeature([], dtype=tf.int64, default_value=-1),\n \"gender\": FixedLenFeature([], dtype=tf.string),\n \"kws\": VarLenFeature(dtype=tf.string),\n }\n\nAnd the expected output is: \n\n {\n \"age\": [[0], [-1]],\n \"gender\": [[\"f\"], [\"f\"]],\n \"kws\": SparseTensor(\n indices=[[0, 0], [0, 1], [1, 0]],\n values=[\"code\", \"art\", \"sports\"]\n dense_shape=[2, 2]),\n }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `file_pattern` | List of files or patterns of file paths containing `Example` records. See [`tf.io.gfile.glob`](../../../tf/io/gfile/glob) for pattern rules. |\n| `batch_size` | An int representing the number of records to combine in a single batch. |\n| `features` | A `dict` mapping feature keys to `FixedLenFeature` or `VarLenFeature` values. See [`tf.io.parse_example`](../../../tf/io/parse_example). |\n| `reader` | A function or class that can be called with a `filenames` tensor and (optional) `reader_args` and returns a `Dataset` of `Example` tensors. Defaults to [`tf.data.TFRecordDataset`](../../../tf/data/TFRecordDataset). |\n| `reader_args` | Additional arguments to pass to the reader class. |\n| `randomize_input` | Whether the input should be randomized. |\n| `num_epochs` | Integer specifying the number of times to read through the dataset. If None, cycles through the dataset forever. |\n| `capacity` | Buffer size of the ShuffleDataset. A large capacity ensures better shuffling but would increase memory usage and startup time. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A dict from keys in features to `Tensor` or `SparseTensor` objects. ||\n\n\u003cbr /\u003e"]]