Skip to content

Instantly share code, notes, and snippets.

@piEsposito
Created April 14, 2020 21:03
Show Gist options
  • Save piEsposito/139a18b19cd49cd4a1bae89813b93ecd to your computer and use it in GitHub Desktop.
Save piEsposito/139a18b19cd49cd4a1bae89813b93ecd to your computer and use it in GitHub Desktop.
def create_timestamps_ds(series,
timestep_size=window_size):
time_stamps = []
labels = []
aux_deque = deque(maxlen=timestep_size)
#starting the timestep deque
for i in range(timestep_size):
aux_deque.append(0)
#feed the timestamps list
for i in range(len(series)-1):
aux_deque.append(series[i])
time_stamps.append(list(aux_deque))
#feed the labels lsit
for i in range(len(series)-1):
labels.append(series[i + 1])
assert len(time_stamps) == len(labels), "Something went wrong"
#torch-tensoring it
features = torch.tensor(time_stamps[timestep_size:]).float()
labels = torch.tensor(labels[timestep_size:]).float()
return features, labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment