SlidingWindow

class tfsnippet.dataflows.SlidingWindow(data_array, window_size)

Bases: tfsnippet.dataflows.data_mappers.DataMapper

DataMapper for producing sliding windows according to indices.

Usage:

data = np.arange(1000)
sw = SlidingWindow(data, window_size=100)

# construct a DataFlow from this SlidingWindow
sw_flow = sw.as_flow(batch_size=64)
# or equivalently
sw_flow = DataFlow.seq(
    0, len(data) - sw.window_size + 1, batch_size=64).map(sw)

Attributes Summary

data_array Get the data array.
window_size Get the window size.

Methods Summary

__call__(*arrays) Transform the input arrays into outputs.
as_flow(batch_size[, shuffle, skip_incomplete]) Get a DataFlow which iterates through mini-batches of sliding windows upon data_array.

Attributes Documentation

data_array

Get the data array.

window_size

Get the window size.

Methods Documentation

__call__(*arrays)

Transform the input arrays into outputs.

Parameters:*arrays – Arrays to be transformed.
Returns:The output arrays.
Return type:tuple[np.ndarray]
as_flow(batch_size, shuffle=False, skip_incomplete=False)

Get a DataFlow which iterates through mini-batches of sliding windows upon data_array.

Parameters:
  • batch_size (int) – Batch size of the data flow. Required.
  • shuffle (bool) – Whether or not to shuffle the numbers before iterating? (default False)
  • skip_incomplete (bool) – Whether or not to exclude the last mini-batch if it is incomplete? (default False)
Returns:

The data flow for sliding windows.

Return type:

DataFlow