tf.contrib.timeseries.RandomWindowInputFn
Stay organized with collections
Save and categorize content based on your preferences.
Wraps a TimeSeriesReader
to create random batches of windows.
tf.contrib.timeseries.RandomWindowInputFn(
time_series_reader, window_size, batch_size, queue_capacity_multiplier=1000,
shuffle_min_after_dequeue_multiplier=2, discard_out_of_order=True,
discard_consecutive_batches_limit=1000, jitter=True, num_threads=2,
shuffle_seed=None
)
Tensors are first collected into sequential windows (in a windowing queue
created by tf.compat.v1.train.batch
, based on the order returned from
time_series_reader
), then these windows are randomly batched (in a
RandomShuffleQueue
), the Tensors returned by create_batch
having shapes
prefixed by [batch_size
, window_size
].
This TimeSeriesInputFn
is useful for both training and quantitative
evaluation (but be sure to run several epochs for sequential models such as
StructuralEnsembleRegressor
to completely flush stale state left over from
training). For qualitative evaluation or when preparing for predictions, use
WholeDatasetInputFn
.
Args |
time_series_reader
|
A TimeSeriesReader object.
|
window_size
|
The number of examples to keep together sequentially. This
controls the length of truncated backpropagation: smaller values mean
less sequential computation, which can lead to faster training, but
create a coarser approximation to the gradient (which would ideally be
computed by a forward pass over the entire sequence in order).
|
batch_size
|
The number of windows to place together in a batch. Larger
values will lead to more stable gradients during training.
|
queue_capacity_multiplier
|
The capacity for the queues used to create
batches, specified as a multiple of batch_size (for
RandomShuffleQueue) and batch_size * window_size (for the FIFOQueue).
Controls the maximum number of windows stored. Should be greater than
shuffle_min_after_dequeue_multiplier .
|
shuffle_min_after_dequeue_multiplier
|
The minimum number of windows in the
RandomShuffleQueue after a dequeue, which controls the amount of entropy
introduced during batching. Specified as a multiple of batch_size .
|
discard_out_of_order
|
If True, windows of data which have times which
decrease (a higher time followed by a lower time) are discarded. If
False, the window and associated features are instead sorted so that
times are non-decreasing. Discarding is typically faster, as models do
not have to deal with artificial gaps in the data. However, discarding
does create a bias where the beginnings and endings of files are
under-sampled.
|
discard_consecutive_batches_limit
|
Raise an OutOfRangeError if more than
this number of batches are discarded without a single non-discarded
window (prevents infinite looping when the dataset is too small).
|
jitter
|
If True, randomly discards examples between some windows in order
to avoid deterministic chunking patterns. This is important for models
like AR which may otherwise overfit a fixed chunking.
|
num_threads
|
Use this number of threads for queues. Setting a value of 1
removes one source of non-determinism (and in combination with
shuffle_seed should provide deterministic windowing).
|
shuffle_seed
|
A seed for window shuffling. The default value of None
provides random behavior. With shuffle_seed set and num_threads=1 ,
provides deterministic behavior.
|
Methods
create_batch
View source
create_batch()
Create queues to window and batch time series data.
Returns |
A dictionary of Tensors corresponding to the output of self._reader
(from the time_series_reader constructor argument), each with shapes
prefixed by [batch_size , window_size ].
|
__call__
View source
__call__()
Call self as a function.
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.timeseries.RandomWindowInputFn\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L622-L802) |\n\nWraps a `TimeSeriesReader` to create random batches of windows. \n\n tf.contrib.timeseries.RandomWindowInputFn(\n time_series_reader, window_size, batch_size, queue_capacity_multiplier=1000,\n shuffle_min_after_dequeue_multiplier=2, discard_out_of_order=True,\n discard_consecutive_batches_limit=1000, jitter=True, num_threads=2,\n shuffle_seed=None\n )\n\nTensors are first collected into sequential windows (in a windowing queue\ncreated by [`tf.compat.v1.train.batch`](../../../tf/train/batch), based on the order returned from\n`time_series_reader`), then these windows are randomly batched (in a\n`RandomShuffleQueue`), the Tensors returned by `create_batch` having shapes\nprefixed by \\[`batch_size`, `window_size`\\].\n\nThis `TimeSeriesInputFn` is useful for both training and quantitative\nevaluation (but be sure to run several epochs for sequential models such as\n`StructuralEnsembleRegressor` to completely flush stale state left over from\ntraining). For qualitative evaluation or when preparing for predictions, use\n`WholeDatasetInputFn`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `time_series_reader` | A TimeSeriesReader object. |\n| `window_size` | The number of examples to keep together sequentially. This controls the length of truncated backpropagation: smaller values mean less sequential computation, which can lead to faster training, but create a coarser approximation to the gradient (which would ideally be computed by a forward pass over the entire sequence in order). |\n| `batch_size` | The number of windows to place together in a batch. Larger values will lead to more stable gradients during training. |\n| `queue_capacity_multiplier` | The capacity for the queues used to create batches, specified as a multiple of `batch_size` (for RandomShuffleQueue) and `batch_size * window_size` (for the FIFOQueue). Controls the maximum number of windows stored. Should be greater than `shuffle_min_after_dequeue_multiplier`. |\n| `shuffle_min_after_dequeue_multiplier` | The minimum number of windows in the RandomShuffleQueue after a dequeue, which controls the amount of entropy introduced during batching. Specified as a multiple of `batch_size`. |\n| `discard_out_of_order` | If True, windows of data which have times which decrease (a higher time followed by a lower time) are discarded. If False, the window and associated features are instead sorted so that times are non-decreasing. Discarding is typically faster, as models do not have to deal with artificial gaps in the data. However, discarding does create a bias where the beginnings and endings of files are under-sampled. |\n| `discard_consecutive_batches_limit` | Raise an OutOfRangeError if more than this number of batches are discarded without a single non-discarded window (prevents infinite looping when the dataset is too small). |\n| `jitter` | If True, randomly discards examples between some windows in order to avoid deterministic chunking patterns. This is important for models like AR which may otherwise overfit a fixed chunking. |\n| `num_threads` | Use this number of threads for queues. Setting a value of 1 removes one source of non-determinism (and in combination with shuffle_seed should provide deterministic windowing). |\n| `shuffle_seed` | A seed for window shuffling. The default value of None provides random behavior. With `shuffle_seed` set and `num_threads=1`, provides deterministic behavior. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `create_batch`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L705-L802) \n\n create_batch()\n\nCreate queues to window and batch time series data.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A dictionary of Tensors corresponding to the output of `self._reader` (from the `time_series_reader` constructor argument), each with shapes prefixed by \\[`batch_size`, `window_size`\\]. ||\n\n\u003cbr /\u003e\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/timeseries/python/timeseries/input_pipeline.py#L573-L575) \n\n __call__()\n\nCall self as a function."]]