Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6e19f4d
Create s47539934-GCN
arshupadhyaya Oct 21, 2022
bc99d1a
Delete s47539934-GCN
arshupadhyaya Oct 21, 2022
9f93239
Added new folder and README
arshupadhyaya Oct 21, 2022
1d7eb06
Added Preprocessed dataset
arshupadhyaya Oct 21, 2022
2205c15
Create Model.py having a 2 layer GCN
arshupadhyaya Oct 22, 2022
9d5c1a2
added header block and comments in model.py
arshupadhyaya Oct 22, 2022
d3fcd49
add header block and comments in data.py
arshupadhyaya Oct 22, 2022
52ad3d7
adding bias and dropout, along with minor changes
arshupadhyaya Oct 22, 2022
c808c20
Change structure of data.py, to better fit test and train set
arshupadhyaya Oct 22, 2022
e8891bb
created training and testing function, and stored accuracy and losses
arshupadhyaya Oct 22, 2022
c775efe
better method to store accuracy and loss
arshupadhyaya Oct 23, 2022
0d47b5d
Added screenshots of accuracies and losses for both training and vali…
arshupadhyaya Oct 23, 2022
94585ca
accuracy and loss for test set
arshupadhyaya Oct 23, 2022
2327c1e
mistakenly added test result in wrong directory, so deleted
arshupadhyaya Oct 23, 2022
5624049
accuracy and loss values after 200 epochs on test set
arshupadhyaya Oct 23, 2022
ba4ceb1
creating a predictive model to train model in real time and plot rele…
arshupadhyaya Oct 23, 2022
d22ffe3
removed data split and doing it in predict.py instead
arshupadhyaya Oct 23, 2022
61c3787
Added header block to train.py
arshupadhyaya Oct 23, 2022
da34c7a
tsne map for GCN with 200 epochs
arshupadhyaya Oct 23, 2022
315fc58
Added tsne map with 50 epochs
arshupadhyaya Oct 23, 2022
789ebab
updated predict model to include plotting tsne
arshupadhyaya Oct 23, 2022
4072e1a
add tsne map with 100 epochs
arshupadhyaya Oct 23, 2022
1ab79b1
create the tsne mapping function along with header block
arshupadhyaya Oct 23, 2022
47ea171
adding final working jupyter file with all functions and results incl…
arshupadhyaya Oct 23, 2022
f74b4cf
mistakenly put in wrong directory so removed
arshupadhyaya Oct 23, 2022
7f78321
final jupyter file containing working version of GCN model
arshupadhyaya Oct 23, 2022
2696430
fixing directory
arshupadhyaya Oct 23, 2022
81dc37e
again changing directory
arshupadhyaya Oct 23, 2022
8021030
deleted an irrelevant file
arshupadhyaya Oct 23, 2022
e6bf0ec
Added initial readme file
arshupadhyaya Oct 23, 2022
af33631
Update README.md
arshupadhyaya Oct 23, 2022
dc5cc68
Delete README.md
arshupadhyaya Oct 23, 2022
b08e1ba
Add files via upload
arshupadhyaya Oct 23, 2022
95d8689
Delete README.md
arshupadhyaya Oct 23, 2022
ae2050e
Add files via upload
arshupadhyaya Oct 23, 2022
a3b8d0d
Rename README (1).md to README.md
arshupadhyaya Oct 23, 2022
e71cb3a
Update README.md
arshupadhyaya Oct 23, 2022
c661e48
Creating basic structure of README file
arshupadhyaya Oct 23, 2022
7f00726
adding all results in README.md
arshupadhyaya Oct 23, 2022
904ea47
Updating ReadMe
arshupadhyaya Oct 23, 2022
868d3f6
Finished Readme.md
arshupadhyaya Oct 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added recognition/MySolution/s47539934-GCN/Accuracy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions recognition/MySolution/s47539934-GCN/Data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'''
Author name: Arsh Upadhyaya, s47539934
To preprocess dataset facebook.npz
'''

import numpy as np
from sklearn import preprocessing
import torch
import scipy.sparse
import torch.nn.functional as F
import matplotlib.pyplot as plt
import scipy.sparse as sp
import torch.optim as optim


def load_data(file_path):
'''
parameters:
takes file path
returns:
Adjacency matrix: normalized coo matrix
features and labels(targets) as tensors
'''

data = np.load("/content/drive/MyDrive/facebook.npz")
edges = data['edges']
features = data['features']
labels = data['target']

features = sp.csr_matrix(features)

adj= sp.coo_matrix((np.ones(edges.shape[0]), (edges[:, 0], edges[:, 1])),shape=(labels.shape[0], labels.shape[0]))

#normalize
colsum = np.array(adj.sum(0))
D = np.power(colsum, -1)[0]
D[np.isinf(D)] = 0
D_inv = sp.diags(D)
adj_trans = D_inv.dot(adj)

#transform data type
indices = torch.LongTensor(np.vstack((adj_trans.tocoo().row, adj_trans.tocoo().col)))
values = torch.FloatTensor(adj_trans.data)
shape = adj_trans.shape

adj_trans = torch.sparse_coo_tensor(indices, values, shape)
features = torch.FloatTensor(np.array(features.todense()))
labels = torch.LongTensor(labels)

return adj_trans, features, labels

Loading