Skip to content

Commit

Permalink
Fixed the input matrix values for the Graph Neural Network. So now we…
Browse files Browse the repository at this point in the history
… can train the GNN model using the input matrix.
  • Loading branch information
aang114 committed Jul 16, 2020
1 parent 99db902 commit 307d580
Show file tree
Hide file tree
Showing 120 changed files with 15 additions and 9 deletions.
Binary file modified graph files/2020-02-22.pkl
Binary file not shown.
Binary file modified graph files/2020-02-23.pkl
Binary file not shown.
Binary file modified graph files/2020-02-24.pkl
Binary file not shown.
Binary file modified graph files/2020-02-25.pkl
Binary file not shown.
Binary file modified graph files/2020-02-26.pkl
Binary file not shown.
Binary file modified graph files/2020-02-27.pkl
Binary file not shown.
Binary file modified graph files/2020-02-28.pkl
Binary file not shown.
Binary file modified graph files/2020-02-29.pkl
Binary file not shown.
Binary file modified graph files/2020-03-01.pkl
Binary file not shown.
Binary file modified graph files/2020-03-02.pkl
Binary file not shown.
Binary file modified graph files/2020-03-03.pkl
Binary file not shown.
Binary file modified graph files/2020-03-04.pkl
Binary file not shown.
Binary file modified graph files/2020-03-05.pkl
Binary file not shown.
Binary file modified graph files/2020-03-06.pkl
Binary file not shown.
Binary file modified graph files/2020-03-07.pkl
Binary file not shown.
Binary file modified graph files/2020-03-08.pkl
Binary file not shown.
Binary file modified graph files/2020-03-09.pkl
Binary file not shown.
Binary file modified graph files/2020-03-10.pkl
Binary file not shown.
Binary file modified graph files/2020-03-11.pkl
Binary file not shown.
Binary file modified graph files/2020-03-12.pkl
Binary file not shown.
Binary file modified graph files/2020-03-13.pkl
Binary file not shown.
Binary file modified graph files/2020-03-14.pkl
Binary file not shown.
Binary file modified graph files/2020-03-15.pkl
Binary file not shown.
Binary file modified graph files/2020-03-16.pkl
Binary file not shown.
Binary file modified graph files/2020-03-17.pkl
Binary file not shown.
Binary file modified graph files/2020-03-18.pkl
Binary file not shown.
Binary file modified graph files/2020-03-19.pkl
Binary file not shown.
Binary file modified graph files/2020-03-20.pkl
Binary file not shown.
Binary file modified graph files/2020-03-21.pkl
Binary file not shown.
Binary file modified graph files/2020-03-22.pkl
Binary file not shown.
Binary file modified graph files/2020-03-23.pkl
Binary file not shown.
Binary file modified graph files/2020-03-24.pkl
Binary file not shown.
Binary file modified graph files/2020-03-25.pkl
Binary file not shown.
Binary file modified graph files/2020-03-26.pkl
Binary file not shown.
Binary file modified graph files/2020-03-27.pkl
Binary file not shown.
Binary file modified graph files/2020-03-28.pkl
Binary file not shown.
Binary file modified graph files/2020-03-29.pkl
Binary file not shown.
Binary file modified graph files/2020-03-30.pkl
Binary file not shown.
Binary file modified graph files/2020-03-31.pkl
Binary file not shown.
Binary file modified graph files/2020-04-01.pkl
Binary file not shown.
Binary file modified graph files/2020-04-02.pkl
Binary file not shown.
Binary file modified graph files/2020-04-03.pkl
Binary file not shown.
Binary file modified graph files/2020-04-04.pkl
Binary file not shown.
Binary file modified graph files/2020-04-05.pkl
Binary file not shown.
Binary file modified graph files/2020-04-06.pkl
Binary file not shown.
Binary file modified graph files/2020-04-07.pkl
Binary file not shown.
Binary file modified graph files/2020-04-08.pkl
Binary file not shown.
Binary file modified graph files/2020-04-09.pkl
Binary file not shown.
Binary file modified graph files/2020-04-10.pkl
Binary file not shown.
Binary file modified graph files/2020-04-11.pkl
Binary file not shown.
Binary file modified graph files/2020-04-12.pkl
Binary file not shown.
Binary file modified graph files/2020-04-30.pkl
Binary file not shown.
Binary file modified graph files/2020-05-01.pkl
Binary file not shown.
Binary file modified graph files/2020-05-02.pkl
Binary file not shown.
Binary file modified graph files/2020-05-03.pkl
Binary file not shown.
Binary file modified graph files/2020-05-04.pkl
Binary file not shown.
Binary file modified graph files/2020-05-05.pkl
Binary file not shown.
Binary file modified graph files/2020-05-06.pkl
Binary file not shown.
Binary file modified graph files/2020-05-07.pkl
Binary file not shown.
Binary file modified graph files/2020-05-08.pkl
Binary file not shown.
Binary file modified graph files/2020-05-09.pkl
Binary file not shown.
Binary file modified graph files/2020-05-10.pkl
Binary file not shown.
Binary file modified graph files/2020-05-11.pkl
Binary file not shown.
Binary file modified graph files/2020-05-12.pkl
Binary file not shown.
Binary file modified graph files/2020-05-13.pkl
Binary file not shown.
Binary file modified graph files/2020-05-14.pkl
Binary file not shown.
Binary file modified graph files/2020-05-15.pkl
Binary file not shown.
Binary file modified graph files/2020-05-16.pkl
Binary file not shown.
Binary file modified graph files/2020-05-17.pkl
Binary file not shown.
Binary file modified graph files/2020-05-18.pkl
Binary file not shown.
Binary file modified graph files/2020-05-19.pkl
Binary file not shown.
Binary file modified graph files/2020-05-20.pkl
Binary file not shown.
Binary file modified graph files/2020-05-21.pkl
Binary file not shown.
Binary file modified graph files/2020-05-22.pkl
Binary file not shown.
Binary file modified graph files/2020-05-23.pkl
Binary file not shown.
Binary file modified graph files/2020-05-24.pkl
Binary file not shown.
Binary file modified graph files/2020-05-25.pkl
Binary file not shown.
Binary file modified graph files/2020-05-26.pkl
Binary file not shown.
Binary file modified graph files/2020-05-27.pkl
Binary file not shown.
Binary file modified graph files/2020-05-28.pkl
Binary file not shown.
Binary file modified graph files/2020-05-29.pkl
Binary file not shown.
Binary file modified graph files/2020-05-30.pkl
Binary file not shown.
Binary file modified graph files/2020-05-31.pkl
Binary file not shown.
Binary file modified graph files/2020-06-01.pkl
Binary file not shown.
Binary file modified graph files/2020-06-02.pkl
Binary file not shown.
Binary file modified graph files/2020-06-03.pkl
Binary file not shown.
Binary file modified graph files/2020-06-04.pkl
Binary file not shown.
Binary file modified graph files/2020-06-05.pkl
Binary file not shown.
Binary file modified graph files/2020-06-06.pkl
Binary file not shown.
Binary file modified graph files/2020-06-07.pkl
Binary file not shown.
Binary file modified graph files/2020-06-08.pkl
Binary file not shown.
Binary file modified graph files/2020-06-09.pkl
Binary file not shown.
Binary file modified graph files/2020-06-10.pkl
Binary file not shown.
Binary file modified graph files/2020-06-11.pkl
Binary file not shown.
Binary file modified graph files/2020-06-12.pkl
Binary file not shown.
Binary file modified graph files/2020-06-13.pkl
Binary file not shown.
Binary file modified graph files/2020-06-14.pkl
Binary file not shown.
Binary file modified graph files/2020-06-15.pkl
Binary file not shown.
Binary file modified graph files/2020-06-16.pkl
Binary file not shown.
Binary file modified graph files/2020-06-17.pkl
Binary file not shown.
Binary file modified graph files/2020-06-18.pkl
Binary file not shown.
Binary file modified graph files/2020-06-19.pkl
Binary file not shown.
Binary file modified graph files/2020-06-20.pkl
Binary file not shown.
Binary file modified graph files/2020-06-21.pkl
Binary file not shown.
Binary file modified graph files/2020-06-22.pkl
Binary file not shown.
Binary file modified graph files/2020-06-23.pkl
Binary file not shown.
Binary file modified graph files/2020-06-24.pkl
Binary file not shown.
Binary file modified graph files/2020-06-25.pkl
Binary file not shown.
Binary file modified graph files/2020-06-26.pkl
Binary file not shown.
Binary file modified graph files/2020-06-27.pkl
Binary file not shown.
Binary file modified graph files/2020-06-28.pkl
Binary file not shown.
Binary file modified graph files/2020-06-29.pkl
Binary file not shown.
Binary file modified graph files/2020-06-30.pkl
Binary file not shown.
Binary file modified graph files/2020-07-01.pkl
Binary file not shown.
Binary file modified graph files/2020-07-02.pkl
Binary file not shown.
Binary file modified graph files/2020-07-03.pkl
Binary file not shown.
Binary file modified modules/__pycache__/gnn_model.cpython-38.pyc
Binary file not shown.
6 changes: 2 additions & 4 deletions modules/gnn_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import dgl
import dgl.function as fn
import torch as th
import torch.nn as nn
import torch.nn.functional as F

Expand Down Expand Up @@ -47,10 +45,10 @@ class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()

self.layer1 = GCNLSTM(1, 10)
self.layer1 = GCNLSTM(2, 10)
self.dropout1 = nn.Dropout(0.3)
self.layer2 = GCNLinear(100, 50)
self.layer3 = GCNLinear(50, 1)
self.layer3 = GCNLinear(50, 2)

def forward(self, g, features):
batch_size, seq_len, n_feats = features.size()
Expand Down
13 changes: 10 additions & 3 deletions scripts/create_grc_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

# normalize values to [0,1]
dfc = dfc / dfc.values.max(axis=1, keepdims=True)
dfc.fillna(0.0, inplace=True) # some GRCs have 0 cases


# make C a directed graph
Expand Down Expand Up @@ -76,10 +77,16 @@
confirmed = np.reshape(dfc[lag_dates].values, (-1, n_lags, 1))

#deaths = np.reshape(dfd[lag_dates].values, (-1, n_lags, 1))
#features = np.concatenate((confirmed, deaths), axis=2)

features = confirmed
targets = np.stack((dfc[date].values)).T
deaths = np.zeros(shape=(confirmed.shape[0], n_lags, 1))

features = np.concatenate((confirmed, deaths), axis=2)

#features = confirmed

#targets = np.stack((dfc[date].values)).T

targets = np.stack( (dfc[date].values, np.zeros(shape=confirmed.shape[0])) ).T

# save feature and response arrays with original graph
with open(f'../graph files/{str(date)[0:10]}.pkl', 'wb') as f:
Expand Down
5 changes: 3 additions & 2 deletions scripts/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pickle
import os


import torch as th
import dgl


from modules.gnn_model import *
Expand Down Expand Up @@ -131,4 +132,4 @@ def several_day_forecast(g, features, n_days):
plt.show()


sqrt(test_loss[499])
#sqrt(test_loss[499])

0 comments on commit 307d580

Please sign in to comment.