Skip to content

Instantly share code, notes, and snippets.

@zafarali
Last active December 7, 2015 19:23
Show Gist options
  • Save zafarali/80a2228673808b780dab to your computer and use it in GitHub Desktop.
Save zafarali/80a2228673808b780dab to your computer and use it in GitHub Desktop.
# time_values is a signal of shape: (time, n_channels)
# window data tensor is of shape: (time, window_size, n_channels)
# where window_size just holds all the data for the T-window_size data.
window_data_tensor = np.zeros((time_values.shape[0], window_size, time_values.shape[1]))
for t in range(1, time_values.shape[0]):
if t <= window_size:
window_data_tensor[t, :, :] = np.pad(time_values[:t, :], ((0, window_size-t), (0,0)), mode='constant')
elif t > window_size and t < time_values.shape[0]-window_size+1:
window_data_tensor[t, :, :] = np.array(time_values[t: t+window_size, :])
else:
window_data_tensor[t, :, :] = np.array()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment