I work with time series models in tensor flow. My dataset contains physical signals. I need to split these signals into windows so that these cut windows are introduced into my model.
This is how I read the data and cut it:
import tensorflow as tf import numpy as np def _ds_slicer(data): win_len = 768 return {"mix":(tf.stack(tf.split(data["mix"],win_len))), "pure":(tf.stack(tf.split(data["pure"],win_len)))} dataset = tf.data.Dataset.from_tensor_slices({ "mix" : np.random.uniform(0,1,[1000,24576]), "pure" : np.random.uniform(0,1,[1000,24576]) }) dataset = dataset.map(_ds_slicer) print dataset.output_shapes
I want to change this dataset to # {'mix': TensorShape([Dimension(32)]), 'pure': TensorShape([Dimension(32))}
An equivalent conversion to numpy would look like this:
signal = np.random.uniform(0,1,[1000,24576]) sliced_sig = np.stack(np.split(signal,768,axis=1),axis=1) print sliced_sig.shape
I was thinking about using tf.contrib.data.group_by_window as the dataset.apply () input, but I couldn’t determine exactly how to use it. Is there a way I can use any custom transform to modify a dataset?
source share