repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
GraphNormalization | GraphNormalization-master/nets/superpixels_graph_classification/gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GCN: Graph Convolutional Networks
Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017)
http://arxiv.org/abs/1609.02907
"""
from layers.gcn_layer import GCNLayer
from layer... | 2,055 | 34.448276 | 109 | py |
GraphNormalization | GraphNormalization-master/nets/superpixels_graph_classification/gated_gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018)
https://arxiv.org/pdf/1711.07553v2.pdf
"""
from layers.gated_gcn_layer im... | 2,342 | 34.5 | 111 | py |
GraphNormalization | GraphNormalization-master/nets/superpixels_graph_classification/mlp_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from layers.mlp_readout_layer import MLPReadout
class MLPNet(nn.Module):
def __init__(self, net_params):
super().__init__()
in_dim = net_params['in_dim']
hidden_dim = net_params['hidden_dim']
n_classes =... | 1,926 | 29.587302 | 81 | py |
GraphNormalization | GraphNormalization-master/nets/superpixels_graph_classification/mo_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import numpy as np
"""
GMM: Gaussian Mixture Model Convolution layer
Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs (Federico Monti et al., CVPR 2017)
https://arxiv.org/pdf/1611.08402.pdf
"""
from lay... | 3,327 | 36.393258 | 115 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/gat_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GAT: Graph Attention Network
Graph Attention Networks (Veličković et al., ICLR 2018)
https://arxiv.org/abs/1710.10903
"""
from layers.gat_layer import GATLayer
from layers.mlp_readout_layer import MLPReadout
class GATNet(nn... | 2,152 | 32.640625 | 115 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/ring_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
Ring-GNN
On the equivalence between graph isomorphism testing and function approximation with GNNs (Chen et al, 2019)
https://arxiv.org/pdf/1905.12560v1.pdf
"""
from layers.ring_gnn_equiv_layer import RingGNNEqui... | 2,384 | 35.136364 | 141 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/three_wl_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
3WLGNN / ThreeWLGNN
Provably Powerful Graph Networks (Maron et al., 2019)
https://papers.nips.cc/paper/8488-provably-powerful-graph-networks.pdf
CODE adapted from https://github.com/hadarser/ProvablyPowe... | 3,142 | 36.416667 | 118 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/graphsage_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GraphSAGE:
William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017)
https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf
"""
from layers.graphsage_layer import... | 2,271 | 33.953846 | 122 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/gin_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from dgl.nn.pytorch.glob import SumPooling, AvgPooling, MaxPooling
"""
GIN: Graph Isomorphism Networks
HOW POWERFUL ARE GRAPH NEURAL NETWORKS? (Keyulu Xu, Weihua Hu, Jure Leskovec and Stefanie Jegelka, ICLR 2019)
https://arxiv.o... | 2,874 | 34.060976 | 113 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GCN: Graph Convolutional Networks
Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017)
http://arxiv.org/abs/1609.02907
"""
from layers.gcn_layer import GCNLayer
from layer... | 2,093 | 33.9 | 109 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/gated_gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018)
https://arxiv.org/pdf/1711.07553v2.pdf
"""
from layers.gated_gcn_layer im... | 2,107 | 32.460317 | 117 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/mlp_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from layers.mlp_readout_layer import MLPReadout
class MLPNet(nn.Module):
def __init__(self, net_params):
super().__init__()
in_dim = net_params['in_dim']
hidden_dim = net_params['hidden_dim']
n_classes =... | 1,926 | 29.109375 | 81 | py |
GraphNormalization | GraphNormalization-master/nets/TUs_graph_classification/mo_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import numpy as np
"""
GMM: Gaussian Mixture Model Convolution layer
Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs (Federico Monti et al., CVPR 2017)
https://arxiv.org/pdf/1611.08402.pdf
"""
from lay... | 3,323 | 36.348315 | 115 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/gat_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GAT: Graph Attention Network
Graph Attention Networks (Veličković et al., ICLR 2018)
https://arxiv.org/abs/1710.10903
"""
from layers.gat_layer import GATLayer, CustomGATLayer, CustomGATLayerEdgeReprFeat, CustomGATLayerIsotr... | 2,970 | 34.795181 | 116 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/ring_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
Ring-GNN
On the equivalence between graph isomorphism testing and function approximation with GNNs (Chen et al, 2019)
https://arxiv.org/pdf/1905.12560v1.pdf
"""
from layers.ring_gnn_equiv_layer import RingGNNEqui... | 3,440 | 38.551724 | 141 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/three_wl_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
3WLGNN / ThreeWLGNN
Provably Powerful Graph Networks (Maron et al., 2019)
https://papers.nips.cc/paper/8488-provably-powerful-graph-networks.pdf
CODE adapted from https://github.com/hadarser/ProvablyPowe... | 4,973 | 40.107438 | 137 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/graphsage_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GraphSAGE:
William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017)
https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf
"""
from layers.graphsage_layer import... | 2,231 | 34.428571 | 122 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/gin_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from dgl.nn.pytorch.glob import SumPooling, AvgPooling, MaxPooling
"""
GIN: Graph Isomorphism Networks
HOW POWERFUL ARE GRAPH NEURAL NETWORKS? (Keyulu Xu, Weihua Hu, Jure Leskovec and Stefanie Jegelka, ICLR 2019)
https://arxiv.o... | 3,010 | 33.609195 | 113 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GCN: Graph Convolutional Networks
Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017)
http://arxiv.org/abs/1609.02907
"""
from layers.gcn_layer import GCNLayer
from layer... | 2,051 | 34.37931 | 109 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/gated_gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018)
https://arxiv.org/pdf/1711.07553v2.pdf
"""
from layers.gated_gcn_layer im... | 2,530 | 34.647887 | 111 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/mlp_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from layers.mlp_readout_layer import MLPReadout
class MLPNet(nn.Module):
def __init__(self, net_params):
super().__init__()
in_dim = net_params['in_dim']
hidden_dim = net_params['hidden_dim']
n_classes =... | 1,865 | 30.1 | 81 | py |
GraphNormalization | GraphNormalization-master/nets/TSP_edge_classification/mo_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import numpy as np
"""
GMM: Gaussian Mixture Model Convolution layer
Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs (Federico Monti et al., CVPR 2017)
https://arxiv.org/pdf/1611.08402.pdf
"""
from lay... | 3,254 | 35.988636 | 115 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/gat_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GAT: Graph Attention Network
Graph Attention Networks (Veličković et al., ICLR 2018)
https://arxiv.org/abs/1710.10903
"""
from layers.gat_layer import GATLayer
from layers.mlp_readout_layer import MLPReadout
class GATNet(nn... | 2,236 | 34.507937 | 109 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/ring_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
Ring-GNN
On the equivalence between graph isomorphism testing and function approximation with GNNs (Chen et al, 2019)
https://arxiv.org/pdf/1905.12560v1.pdf
"""
from layers.ring_gnn_equiv_layer import RingGNNEqui... | 12,685 | 40.457516 | 163 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/three_wl_gnn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import time
"""
3WLGNN / ThreeWLGNN
Provably Powerful Graph Networks (Maron et al., 2019)
https://papers.nips.cc/paper/8488-provably-powerful-graph-networks.pdf
CODE adapted from https://github.com/hadarser/ProvablyPowe... | 3,651 | 37.442105 | 122 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/graphsage_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GraphSAGE:
William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017)
https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf
"""
from layers.graphsage_layer import... | 2,345 | 35.092308 | 122 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/gin_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from dgl.nn.pytorch.glob import SumPooling, AvgPooling, MaxPooling
"""
GIN: Graph Isomorphism Networks
HOW POWERFUL ARE GRAPH NEURAL NETWORKS? (Keyulu Xu, Weihua Hu, Jure Leskovec and Stefanie Jegelka, ICLR 2019)
https://arxiv.o... | 2,897 | 34.341463 | 113 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
GCN: Graph Convolutional Networks
Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017)
http://arxiv.org/abs/1609.02907
"""
from layers.gcn_layer import GCNLayer
from layer... | 2,191 | 34.354839 | 109 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/gated_gcn_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018)
https://arxiv.org/pdf/1711.07553v2.pdf
"""
from layers.gated_gcn_layer im... | 2,991 | 35.938272 | 111 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/mlp_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from layers.mlp_readout_layer import MLPReadout
class MLPNet(nn.Module):
def __init__(self, net_params):
super().__init__()
num_atom_type = net_params['num_atom_type']
num_bond_type = net_params['num_bond_type']... | 2,196 | 30.84058 | 89 | py |
GraphNormalization | GraphNormalization-master/nets/molecules_graph_regression/mo_net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
import numpy as np
"""
GMM: Gaussian Mixture Model Convolution layer
Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs (Federico Monti et al., CVPR 2017)
https://arxiv.org/pdf/1611.08402.pdf
"""
from lay... | 3,331 | 36.438202 | 115 | py |
GraphNormalization | GraphNormalization-master/layers/graphsage_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl.function as fn
from dgl.nn.pytorch import SAGEConv
"""
GraphSAGE:
William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017)
https://cs.stanford.edu/people/jure/pubs/graphsage... | 10,938 | 29.386111 | 114 | py |
GraphNormalization | GraphNormalization-master/layers/mlp_readout_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
"""
MLP Layer used after graph vector representation
"""
class MLPReadout(nn.Module):
def __init__(self, input_dim, output_dim, L=2): #L=nb_hidden_layers
super().__init__()
list_FC_layers = [ nn.Linear( input_dim//2**l , input... | 726 | 29.291667 | 109 | py |
GraphNormalization | GraphNormalization-master/layers/gated_gcn_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl
from norm.norm import LoadNorm, normalize
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018)
https://arxiv.org/pdf/1711.07553... | 7,661 | 33.205357 | 170 | py |
GraphNormalization | GraphNormalization-master/layers/gat_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from dgl.nn.pytorch import GATConv
from norm.norm import LoadNorm, normalize
"""
GAT: Graph Attention Network
Graph Attention Networks (Veličković et al., ICLR 2018)
https://arxiv.org/abs/1710.10903
"""
class GATLayer(nn.Module):
"""
... | 10,396 | 30.035821 | 107 | py |
GraphNormalization | GraphNormalization-master/layers/gin_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl.function as fn
"""
GIN: Graph Isomorphism Networks
HOW POWERFUL ARE GRAPH NEURAL NETWORKS? (Keyulu Xu, Weihua Hu, Jure Leskovec and Stefanie Jegelka, ICLR 2019)
https://arxiv.org/pdf/1810.00826.pdf
"""
class GINLayer(nn.Module):... | 4,598 | 30.9375 | 113 | py |
GraphNormalization | GraphNormalization-master/layers/gmm_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import dgl.function as fn
"""
GMM: Gaussian Mixture Model Convolution layer
Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs (Federico Monti et al., CVPR 2017)
https://arxiv.org/pdf/1611.084... | 3,680 | 31.289474 | 111 | py |
GraphNormalization | GraphNormalization-master/layers/gcn_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl.function as fn
from dgl.nn.pytorch import GraphConv
from norm.norm import LoadNorm, normalize
"""
GCN: Graph Convolutional Networks
Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR ... | 2,601 | 29.611765 | 109 | py |
GraphNormalization | GraphNormalization-master/layers/ring_gnn_equiv_layer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Ring-GNN equi 2 to 2 layer file
On the equivalence between graph isomorphism testing and function approximation with GNNs (Chen et al, 2019)
https://arxiv.org/pdf/1905.12560v1.pdf
CODE ADPATED FROM https://github.com/leichen2018/Ri... | 8,076 | 39.385 | 139 | py |
GraphNormalization | GraphNormalization-master/layers/three_wl_gnn_layers.py | import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Layers used for
3WLGNN
Provably Powerful Graph Networks (Maron et al., 2019)
https://papers.nips.cc/paper/8488-provably-powerful-graph-networks.pdf
CODE adapted from https://github.com/hadarser/ProvablyPowerfulGraphNetwork... | 4,983 | 31.154839 | 108 | py |
GraphNormalization | GraphNormalization-master/train/train_superpixels_graph_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
from datetime import datetime
from train.metrics import accuracy_MNIST_CIFAR as accuracy
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
mo... | 3,567 | 30.575221 | 80 | py |
GraphNormalization | GraphNormalization-master/train/train_CSL_graph_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
from train.metrics import accuracy_TU as accuracy
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
model.train()
epoch_loss = 0
epoch_... | 4,388 | 33.023256 | 91 | py |
GraphNormalization | GraphNormalization-master/train/train_molecules_graph_regression.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
from train.metrics import MAE
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
model.train()
epoch_loss = 0
epoch_train_mae = 0
nb... | 4,455 | 34.648 | 91 | py |
GraphNormalization | GraphNormalization-master/train/train_COLLAB_edge_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import dgl
import numpy as np
from tqdm import tqdm
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, graph, train_edges, batch_size, epoch,... | 5,333 | 33.192308 | 107 | py |
GraphNormalization | GraphNormalization-master/train/train_TSP_edge_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
import dgl
from train.metrics import binary_f1_score
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
model.train()
epoch_loss = 0
ep... | 3,922 | 31.155738 | 98 | py |
GraphNormalization | GraphNormalization-master/train/metrics.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics import confusion_matrix
from sklearn.metrics import f1_score
import numpy as np
def MAE(scores, targets):
MAE = F.l1_loss(scores, targets)
MAE = MAE.detach().item()
return MAE
def accuracy_TU(scores, targets):
s... | 1,988 | 27.826087 | 84 | py |
GraphNormalization | GraphNormalization-master/train/train_TUs_graph_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
from train.metrics import accuracy_TU as accuracy
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
model.train()
epoch_loss = 0
epoch_... | 3,802 | 30.172131 | 86 | py |
GraphNormalization | GraphNormalization-master/train/train_SBMs_node_classification.py | """
Utility functions for training one epoch
and evaluating one epoch
"""
from datetime import datetime
import torch
import torch.nn as nn
import math
import dgl
from train.metrics import accuracy_SBM as accuracy
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
... | 4,014 | 30.865079 | 91 | py |
GraphNormalization | GraphNormalization-master/data/TSP.py | import time
import pickle
import numpy as np
import itertools
from scipy.spatial.distance import pdist, squareform
import dgl
import torch
from torch.utils.data import Dataset
class TSP(Dataset):
def __init__(self, data_dir, split="train", num_neighbors=25, max_samples=10000):
self.data_dir = data_di... | 9,283 | 41.587156 | 127 | py |
GraphNormalization | GraphNormalization-master/data/superpixels.py | import os
import pickle
from scipy.spatial.distance import cdist
import numpy as np
import itertools
import dgl
import torch
import torch.utils.data
import time
import csv
from sklearn.model_selection import StratifiedShuffleSplit
def sigma(dists, kth=8):
# Compute sigma and reshape
try:
# Get k-... | 13,741 | 37.385475 | 127 | py |
GraphNormalization | GraphNormalization-master/data/molecules.py | import torch
import pickle
import torch.utils.data
import time
import os
import numpy as np
import csv
import dgl
from scipy import sparse as sp
import numpy as np
# *NOTE
# The dataset pickle and index files are in ./zinc_molecules/ dir
# [<split>.pickle and <split>.index; for split 'train', 'val' and 'test']
... | 10,948 | 38.103571 | 127 | py |
GraphNormalization | GraphNormalization-master/data/COLLAB.py | import time
import dgl
import torch
from torch.utils.data import Dataset
from ogb.linkproppred import DglLinkPropPredDataset, Evaluator
from scipy import sparse as sp
import numpy as np
def positional_encoding(g, pos_enc_dim):
"""
Graph positional encoding v/ Laplacian eigenvectors
"""
# La... | 2,531 | 36.235294 | 88 | py |
GraphNormalization | GraphNormalization-master/data/TUs.py | import torch
import pickle
import torch.utils.data
import time
import os
import numpy as np
import csv
import dgl
from dgl.data import TUDataset
from dgl.data import LegacyTUDataset
import random
random.seed(42)
from sklearn.model_selection import StratifiedKFold, train_test_split
import csv
def get_all_split... | 10,421 | 40.357143 | 129 | py |
GraphNormalization | GraphNormalization-master/data/SBMs.py |
import time
import os
import pickle
import numpy as np
import dgl
import torch
from scipy import sparse as sp
import numpy as np
class load_SBMsDataSetDGL(torch.utils.data.Dataset):
def __init__(self,
data_dir,
name,
split):
self.split = split
... | 9,004 | 34.876494 | 127 | py |
GraphNormalization | GraphNormalization-master/data/CSL.py | import numpy as np, time, pickle, random, csv
import torch
from torch.utils.data import DataLoader, Dataset
import os
import pickle
import numpy as np
import dgl
from sklearn.model_selection import StratifiedKFold, train_test_split
random.seed(42)
from scipy import sparse as sp
class DGLFormDataset(torch.utils.d... | 13,736 | 40.00597 | 128 | py |
GraphNormalization | GraphNormalization-master/sroie/test.py | import os
from sklearn.metrics import confusion_matrix
import torch
import numpy as np
import dgl
import cv2
from dataset import SROIEDataset
from gated_gcn import GatedGCNNet
def accuracy(scores, targets):
S = targets.cpu().numpy()
C = np.argmax( torch.nn.Softmax(dim=1)(scores).cpu().detach().numpy() , axis... | 8,217 | 31.872 | 181 | py |
GraphNormalization | GraphNormalization-master/sroie/graph_norm.py | import torch.nn as nn
import torch
class GraphNorm(nn.Module):
"""
Param: []
"""
def __init__(self, num_features, eps=1e-5):
super().__init__()
self.eps = eps
self.num_features = num_features
self.gamma = nn.Parameter(torch.ones(self.num_features))
self.beta... | 799 | 23.242424 | 64 | py |
GraphNormalization | GraphNormalization-master/sroie/dataset.py | import time
import os
import pickle
import random
import numpy as np
import dgl
import torch
import glob
from torch.utils.data import Dataset, DataLoader
class SROIEDataset(Dataset):
def __init__(self,
data_dir,
split,
alphabet=None,
labels=None... | 8,537 | 33.991803 | 129 | py |
GraphNormalization | GraphNormalization-master/sroie/gated_gcn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import LSTM
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
import dgl
import numpy as np
from graph_norm import GraphNorm
"""
ResGatedGCN: Residual Gated Graph ConvNets
An Experimental Study of Neural... | 9,924 | 35.090909 | 169 | py |
GraphNormalization | GraphNormalization-master/sroie/train.py | import argparse
import random
from datetime import datetime
import numpy as np
import torch
from dataset import SROIEDataset
from torch.utils.data import DataLoader
import torch.optim as optim
from sklearn.metrics import confusion_matrix
from gated_gcn import GatedGCNNet
torch.autograd.set_detect_anomaly(True)
def ... | 10,296 | 39.380392 | 236 | py |
pytorch-cw2 | pytorch-cw2-master/runutils.py | from operator import methodcaller
import torch
import torch.nn as nn
from torch.autograd import Variable
def get_cuda_state(obj):
"""
Get cuda state of any object.
:param obj: an object (a tensor or an `torch.nn.Module`)
:raise TypeError:
:return: True if the object or the parameter set of the o... | 3,373 | 32.405941 | 81 | py |
pytorch-cw2 | pytorch-cw2-master/cw.py | """
Carlini-Wagner attack (http://arxiv.org/abs/1608.04644).
Referential implementation:
- https://github.com/carlini/nn_robust_attacks.git (the original implementation)
- https://github.com/rwightman/pytorch-nips2017-attack-example.git
"""
import operator as op
from typing import Union, Tuple
import numpy as np
im... | 24,466 | 44.309259 | 108 | py |
pycryptodome | pycryptodome-master/Doc/conf.py | # -*- coding: utf-8 -*-
#
# PyCryptodome documentation build configuration file, created by
# sphinx-quickstart on Sun Jun 8 20:21:20 2014.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
... | 9,209 | 30.649485 | 112 | py |
rosac | rosac-main/test/rooms/masac.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs import make_rooms_model
from hybrid_gym.util.io import parse_command_li... | 1,599 | 33.042553 | 95 | py |
rosac | rosac-main/test/rooms/cegrl_two_doors.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.rooms_two_doors.hybrid_env import make_rooms_model
from hybrid_gym.trai... | 2,852 | 40.347826 | 107 | py |
rosac | rosac-main/test/rooms/maddpg.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs import make_rooms_model
from hybrid_gym.util.io import parse_command_li... | 993 | 27.4 | 90 | py |
rosac | rosac-main/test/rooms/paired.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs import make_rooms_model
from hybrid_gym.util.io import parse_command_li... | 1,700 | 31.09434 | 99 | py |
rosac | rosac-main/test/rooms/cegrl.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs import make_rooms_model
from hybrid_gym.train.reward_funcs import SVMRe... | 3,112 | 37.432099 | 106 | py |
rosac | rosac-main/test/f110_pldi_ctrl/test_env.py | import os
import sys
sys.path.append(os.path.join('..', '..')) # nopep8
# flake8: noqa: E402
from hybrid_gym import HybridEnv, Controller
from hybrid_gym.envs import make_f110_model
from hybrid_gym.selectors import UniformSelector, MaxJumpWrapper
from tensorflow.keras import models
from enum import Enum
import numpy... | 7,390 | 29.924686 | 93 | py |
rosac | rosac-main/test/f110_turn/masac.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.f110_turn.hybrid_env import make_f110_model
from hybrid_gym.util.io imp... | 1,804 | 31.232143 | 86 | py |
rosac | rosac-main/test/f110_turn/maddpg.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.f110_turn.hybrid_env import make_f110_model
from hybrid_gym.util.io imp... | 1,125 | 26.463415 | 75 | py |
rosac | rosac-main/test/f110_turn/paired.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.f110_turn.hybrid_env import make_f110_model
from hybrid_gym.util.io imp... | 1,723 | 31.528302 | 99 | py |
rosac | rosac-main/test/f110_turn/cegrl.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.f110_turn.hybrid_env import make_f110_model
from hybrid_gym.train.rewar... | 3,037 | 34.741176 | 106 | py |
rosac | rosac-main/test/ant_rooms/masac.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.ant_rooms.hybrid_env import make_ant_model
from hybrid_gym.util.io impo... | 1,961 | 30.645161 | 86 | py |
rosac | rosac-main/test/ant_rooms/cegrl_old.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.ant_rooms.hybrid_env import make_ant_model
from hybrid_gym.train.reward... | 3,273 | 37.517647 | 108 | py |
rosac | rosac-main/test/ant_rooms/cegrl.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.ant_rooms.hybrid_env import make_ant_model
from hybrid_gym.train.reward... | 3,217 | 34.362637 | 132 | py |
rosac | rosac-main/test/pick_place/cegrl.py | import os
import sys
import torch
import numpy as np
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa
from hybrid_gym import Controller
from hybrid_gym.envs.pick_place.hybrid_env import make_pick_place_model
from hybrid_gym.trai... | 4,129 | 36.889908 | 86 | py |
rosac | rosac-main/test/pick_place/eval_height.py | import os
import argparse
import pathlib
import sys
import gym
import numpy as np
from stable_baselines.her import HERGoalEnvWrapper
import torch
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa: E402
from hybrid_gym.util.wrappe... | 7,064 | 41.305389 | 125 | py |
rosac | rosac-main/test/pick_place/eval.py | import os
import argparse
import pathlib
import sys
import gym
import numpy as np
from stable_baselines.her import HERGoalEnvWrapper
import torch
sys.path.append(os.path.join('..', '..')) # nopep8
sys.path.append(os.path.join('..', '..', 'spectrl_hierarchy')) # nopep8
# flake8: noqa: E402
from hybrid_gym.util.wrappe... | 6,264 | 41.331081 | 129 | py |
rosac | rosac-main/hybrid_gym/util/wrappers.py | import gym
import random
import numpy as np
import joblib
from stable_baselines import A2C, ACER, ACKTR, DDPG, DQN, GAIL, HER, PPO1, PPO2, SAC, TD3, TRPO
from stable_baselines.common.base_class import BaseRLModel
from stable_baselines3 import (
A2C as SB3_A2C, DDPG as SB3_DDPG, DQN as SB3_DQN,
PPO as SB3_PPO, S... | 17,966 | 35.742331 | 100 | py |
rosac | rosac-main/hybrid_gym/rl/paired.py | import time
import torch
import numpy as np
import torch.nn as nn
from torch.distributions import Categorical
from hybrid_gym.rl.ppo.multi_agent import Model, Trainer
from hybrid_gym.rl.ddpg.ddpg import optimizer_to
from hybrid_gym.eval import mcts_eval, random_selector_eval
class Adversary:
'''
Adversary wi... | 5,613 | 36.677852 | 90 | py |
rosac | rosac-main/hybrid_gym/rl/ars.py | from hybrid_gym.rl.util import discounted_reward, get_rollout, test_policy
from hybrid_gym.model import Controller
import numpy as np
import pickle
import torch
import os
class ARSModel:
def __init__(self, nn_params, ars_params, use_gpu=False):
self.nn_policy = NNPolicy(nn_params, use_gpu)
self.... | 11,956 | 34.064516 | 98 | py |
rosac | rosac-main/hybrid_gym/rl/ddpg/ddpg.py | """
Deep Deterministic Policy Gradient agent
Author: Sameera Lanka
Website: https://sameera-lanka.com
Modified for DIRL
"""
# Torch
import random
import torch
import torch.nn as nn
import torch.optim as optim
# Lib
from copy import deepcopy
import numpy as np
import gym
# Files
from hybrid_gym.rl.ddpg.noise import ... | 14,758 | 41.168571 | 100 | py |
rosac | rosac-main/hybrid_gym/rl/ddpg/replaybuffer.py | """
Replay Buffer
Author: Sameera Lanka
Website: https://sameera-lanka.com
Modified for DIRL
"""
import random
import torch
from collections import deque
class Buffer:
def __init__(self, buffer_size):
self.limit = buffer_size
self.data = deque(maxlen=self.limit)
def __len__(self):
re... | 1,615 | 31.32 | 80 | py |
rosac | rosac-main/hybrid_gym/rl/ddpg/actorcritic.py | """
Definitions for Actor and Critic
Author: Sameera Lanka
Website: https://sameera-lanka.com
Modified for DIRL
"""
import os
import torch
import pickle
import torch.nn as nn
import numpy as np
WFINAL = 0.003
def fanin_init(size, fanin=None):
"""Utility function for initializing actor and critic"""
fanin = ... | 3,272 | 23.984733 | 75 | py |
rosac | rosac-main/hybrid_gym/rl/ppo/multi_agent.py | from typing import Dict, List, Any, Tuple
import numpy as np
import torch
import pickle
import os
from torch import nn
from torch import optim
from torch.distributions import Normal
from labml import monit
from labml.configs import FloatDynamicHyperParam, IntDynamicHyperParam
from labml_helpers.module import Module
... | 19,322 | 34.260949 | 99 | py |
rosac | rosac-main/hybrid_gym/rl/sac/sac.py | from copy import deepcopy
import itertools
import numpy as np
import torch
from torch.optim import Adam
import gym
import random
import os
import pickle
# import time
from hybrid_gym.rl.sac.core import MLPActorCritic, combined_shape
from hybrid_gym.model import Controller
from typing import Type, TypeVar
def optimize... | 19,362 | 38.759754 | 97 | py |
rosac | rosac-main/hybrid_gym/rl/sac/core.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.normal import Normal
def combined_shape(length, shape=None):
if shape is None:
return (length,)
return (length, shape) if np.isscalar(shape) else (length, *shape)
def mlp(sizes, activation... | 4,153 | 33.616667 | 97 | py |
synboost | synboost-master/symbolic_opset11.py | from __future__ import absolute_import, division, print_function, unicode_literals
import torch
import torch.onnx.symbolic_helper as sym_help
import warnings
import numpy
from torch.onnx.symbolic_helper import parse_args, _unimplemented
from torch.onnx.symbolic_opset9 import expand
from torch.nn.modules.utils import ... | 23,251 | 44.062016 | 156 | py |
synboost | synboost-master/onnx_conversion.py | import os
from PIL import Image
import numpy as np
import cv2
from collections import OrderedDict
import shutil
import torch
from torch.backends import cudnn
import torch.onnx
import torch.nn as nn
import torchvision.transforms as transforms
import onnx
import onnxruntime
from options.test_options import TestOptions
... | 12,102 | 37.667732 | 126 | py |
synboost | synboost-master/estimator.py | import os
from PIL import Image
import numpy as np
import torch
import torch.nn.functional as F
import torchvision.transforms as transforms
from torchvision.transforms import ToPILImage
import yaml
import random
from options.config_class import Config
import sys
sys.path.insert(0, os.path.join(os.getcwd(), os.path.dir... | 15,844 | 45.466276 | 142 | py |
synboost | synboost-master/image_synthesis/train.py | import sys
from collections import OrderedDict
import torch.multiprocessing as mp
import torch.distributed as dist
import torch
import data
from options.train_options import TrainOptions
from trainers.pix2pix_trainer import Pix2PixTrainer
from util.iter_counter import IterationCounter
from util.visualizer import Visu... | 3,400 | 34.061856 | 103 | py |
synboost | synboost-master/image_synthesis/options/base_options.py | import sys
import argparse
import os
from util import util
import torch
import models
import data
import pickle
import pdb
class BaseOptions():
def __init__(self):
self.initialized = False
def initialize(self, parser):
# experiment specifics
parser.add_argument('--mpdist', action='stor... | 9,196 | 50.668539 | 283 | py |
synboost | synboost-master/image_synthesis/models/pix2pix_model.py | import torch
import models.networks as networks
import util.util as util
import pdb
class Pix2PixModel(torch.nn.Module):
@staticmethod
def modify_commandline_options(parser, is_train):
networks.modify_commandline_options(parser, is_train)
return parser
def __init__(self, opt):
supe... | 9,724 | 37.9 | 127 | py |
synboost | synboost-master/image_synthesis/models/__init__.py | import importlib
import torch
def find_model_using_name(model_name):
# Given the option --model [modelname],
# the file "models/modelname_model.py"
# will be imported.
model_filename = "models." + model_name + "_model"
modellib = importlib.import_module(model_filename)
# In the file, the clas... | 1,241 | 30.05 | 156 | py |
synboost | synboost-master/image_synthesis/models/networks/architecture.py | import math
import re
import torch
import torch.nn as nn
import functools
import numpy as np
import torch.nn.functional as F
import torchvision
import torch.nn.utils.spectral_norm as spectral_norm
from models.networks.base_network import BaseNetwork
from models.networks.normalization import SPADE
from models.networks.c... | 7,140 | 35.809278 | 91 | py |
synboost | synboost-master/image_synthesis/models/networks/condconv.py | import re
import torch
import torch.nn as nn
import torch.nn.functional as F
## depthwise seperable conv + spectral norm + batch norm
class DepthConv(nn.Module):
def __init__(self, fmiddle, opt, kw=3, padding=1, stride=1):
super().__init__()
self.kw = kw
self.stride = stride
self.u... | 1,080 | 29.885714 | 107 | py |
synboost | synboost-master/image_synthesis/models/networks/discriminator.py | import sys
import torch
import re
from collections import OrderedDict
import os.path
import functools
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
from models.networks.base_network import BaseNetwork
from models.networks.normalization import get_nonspade_norm_layer
import util.util as util
... | 4,872 | 39.608333 | 94 | py |
synboost | synboost-master/image_synthesis/models/networks/loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from models.networks.architecture import VGG19
# Defines the GAN loss which uses either LSGAN or the regular GAN.
# When LSGAN is used, it is basically same as MSELoss,
# but it abstracts away the need to create the target label tens... | 4,811 | 38.121951 | 91 | py |
synboost | synboost-master/image_synthesis/models/networks/encoder.py | import torch
import torch.nn as nn
import functools
import numpy as np
import torch.nn.functional as F
from models.networks.base_network import BaseNetwork
from models.networks.normalization import get_nonspade_norm_layer
class ConvEncoder(BaseNetwork):
""" Same architecture as the image discriminator """
def ... | 1,906 | 34.981132 | 100 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.