-
Notifications
You must be signed in to change notification settings - Fork 0
/
rnn_test.py
38 lines (29 loc) · 945 Bytes
/
rnn_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import numpy as np
import scipy.io as sio
from sklearn.preprocessing import StandardScaler
from nn_models import basic_rnn
from utils import rolling_window,load_preprocessed
# Load preprocessed files
all_data = load_preprocessed()
data = all_data[0]
def timestep_slice_data(data,slice_size=10,rescale=True):
# Load inputs and outputs
labels = data['stages'][:,2]
pows = data['pows']
if rescale:
scaler = StandardScaler()
scaler.fit(pows)
pows = scaler.transform(pows)
pows = pows.swapaxes(0,1)
# timeslice labels [ N,slice_size ]
seq_labels = rolling_window(labels,slice_size)
# timeslicing pows is awkward...
seq_pows = rolling_window(pows,slice_size)
seq_pows = seq_pows.swapaxes(0,1)
seq_pows = seq_pows.swapaxes(1,2)
return seq_pows,seq_labels
tsteps = 10
X,Y = timestep_slice_data(data,tsteps)
model = basic_rnn(tsteps)
import ipdb; ipdb.set_trace()