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
CD-SGD
CD-SGD-master/example/fcn-xs/init_fcnxs.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
4,639
42.364486
97
py
CD-SGD
CD-SGD-master/example/fcn-xs/image_segmentaion.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
4,504
35.04
97
py
CD-SGD
CD-SGD-master/example/fcn-xs/data.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
6,068
42.35
139
py
CD-SGD
CD-SGD-master/example/fcn-xs/solver.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,192
48.951389
116
py
CD-SGD
CD-SGD-master/example/fcn-xs/fcn_xs.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,773
40.472527
99
py
CD-SGD
CD-SGD-master/example/restricted-boltzmann-machine/binary_rbm_gluon.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,113
49.098592
170
py
CD-SGD
CD-SGD-master/example/restricted-boltzmann-machine/binary_rbm_module.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,894
44.901163
170
py
CD-SGD
CD-SGD-master/example/restricted-boltzmann-machine/binary_rbm.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
12,873
49.685039
172
py
CD-SGD
CD-SGD-master/example/numpy-ops/custom_sparse_sqr.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
4,291
34.471074
100
py
CD-SGD
CD-SGD-master/example/numpy-ops/weighted_logistic_regression.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,461
38.793103
103
py
CD-SGD
CD-SGD-master/example/numpy-ops/custom_softmax_rtc.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
6,868
38.028409
137
py
CD-SGD
CD-SGD-master/example/numpy-ops/custom_softmax.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,190
34.455556
79
py
CD-SGD
CD-SGD-master/example/vae-gan/convert_data.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,581
33.776699
187
py
CD-SGD
CD-SGD-master/example/vae-gan/vaegan_mxnet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
31,039
40.945946
334
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/dot.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
20,888
43.730193
123
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/memory_benchmark.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,792
39.351064
100
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/updater.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
2,695
33.126582
88
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/sparse_end2end.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
12,675
40.155844
128
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/cast_storage.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,691
35.92
107
py
CD-SGD
CD-SGD-master/benchmark/python/sparse/sparse_op.py
from __future__ import print_function # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Versio...
9,244
36.278226
117
py
CD-SGD
CD-SGD-master/benchmark/python/control_flow/rnn.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5,160
34.593103
113
py
CD-SGD
CD-SGD-master/benchmark/python/gluon/benchmark_gluon.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,754
46
113
py
CD-SGD
CD-SGD-master/benchmark/python/quantization/benchmark_op.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5,279
57.021978
117
py
CD-SGD
CD-SGD-master/ci/build_windows.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache Licen...
8,328
33.995798
118
py
CD-SGD
CD-SGD-master/ci/util.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,862
32.301724
100
py
CD-SGD
CD-SGD-master/ci/build.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache Licen...
22,504
38.344406
135
py
CD-SGD
CD-SGD-master/ci/docker/qemu/vmcontrol.py
#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "...
10,989
33.451411
149
py
CD-SGD
CD-SGD-master/ci/docker/qemu/runtime_functions.py
#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "...
4,672
33.614815
185
py
gnn-matlang
gnn-matlang-main/enzymes_contfeat.py
from torch_geometric.data import DataLoader,InMemoryDataset import torch import scipy.io as sio from torch_geometric.data.data import Data import numpy as np from sklearn.metrics import r2_score from sklearn.model_selection import StratifiedKFold import os.path as osp import torch.nn as nn import torch.nn.functional a...
15,187
33.361991
161
py
gnn-matlang
gnn-matlang-main/proteins.py
from torch_geometric.data import DataLoader,InMemoryDataset import torch import scipy.io as sio from torch_geometric.data.data import Data import numpy as np from sklearn.metrics import r2_score from sklearn.model_selection import StratifiedKFold import os.path as osp import torch.nn as nn import torch.nn.functional a...
12,181
31.747312
155
py
gnn-matlang
gnn-matlang-main/freqclass.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU import torch_geometric.transforms as T from torch_geometric.data import DataLoader from torch_geometric.nn import (GINConv,global_mean_pool,GATConv,ChebConv,GCNConv) from libs.spect_conv import SpectConv,ML...
13,770
31.866348
217
py
gnn-matlang
gnn-matlang-main/sr25.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear import torch_geometric.transforms as T from torch_geometric.data import DataLoader from torch_geometric.nn import (GINConv,global_add_pool,GATConv,ChebConv,GCNConv) import numpy as np from libs.spect_conv impor...
10,210
32.811258
143
py
gnn-matlang
gnn-matlang-main/mutag.py
from torch_geometric.data import DataLoader import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.nn import (GINConv,global_mean_pool,GATConv,ChebConv,GCNConv) from libs.spect_conv import SpectConv,ML3Layer from libs.uti...
12,475
30.826531
155
py
gnn-matlang
gnn-matlang-main/ptc.py
from torch_geometric.data import DataLoader import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.nn import (GINConv,global_add_pool,global_max_pool,global_mean_pool,GATConv,ChebConv,GCNConv) from libs.spect_conv import ...
15,068
32.118681
157
py
gnn-matlang
gnn-matlang-main/counting.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.data import DataLoader from torch_geometric.nn import (GINConv,global_add_pool,GATConv,ChebConv,GCNConv) import numpy as npi from libs.spect_conv import SpectConv,ML3Layer from libs.uti...
17,046
36.301969
173
py
gnn-matlang
gnn-matlang-main/Zinc12k.py
from torch_geometric.data import DataLoader import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.nn import (GINConv,global_add_pool,GATConv,ChebConv,GCNConv) from libs.spect_conv import SpectConv,ML3Layer from libs.utils import Zinc12KDa...
13,746
32.859606
148
py
gnn-matlang
gnn-matlang-main/prepareMnist_gnnml3_tf.py
import numpy as np from torch_geometric.datasets import MNISTSuperpixels from libs.utils_tf import * from libs.utils import DegreeMaxEigTransform #select if node degree and location of superpixel region would be used by model or not. #after any chnageing please remove MNIST/processed folder in order to preprocess c...
2,913
25.490909
97
py
gnn-matlang
gnn-matlang-main/mnist75.py
from torch_geometric.data import DataLoader import torch import scipy.io as sio from torch_geometric.data.data import Data import numpy as np import os.path as osp import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.nn import (NNConv, graclus, max_p...
13,080
32.284987
171
py
gnn-matlang
gnn-matlang-main/exp_iso.py
import os.path as osp import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear import torch_geometric.transforms as T from torch_geometric.data import DataLoader from torch_geometric.nn import (GINConv,global_add_pool,GATConv,ChebConv,GCNConv) import numpy as np fro...
10,253
32.509804
143
py
gnn-matlang
gnn-matlang-main/exp_classify.py
import os.path as osp import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU import torch_geometric.transforms as T from torch_geometric.data import DataLoader from torch_geometric.nn import (GINConv,global_mean_pool,GATConv,ChebConv,GCNConv) import numpy as n...
13,017
32.901042
217
py
gnn-matlang
gnn-matlang-main/graph8c.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear import torch_geometric.transforms as T from torch_geometric.data import DataLoader from torch_geometric.nn import (global_add_pool,GATConv,ChebConv,GCNConv,GINConv) import numpy as np from libs.spect_conv impor...
10,363
33.317881
143
py
gnn-matlang
gnn-matlang-main/filtering.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, Linear, ReLU from torch_geometric.data import DataLoader from torch_geometric.nn import (GATConv,ChebConv,GCNConv,GINConv) import numpy as np import matplotlib.pyplot as plt from libs.spect_conv import SpectConv,ML3Lay...
12,079
31.213333
183
py
gnn-matlang
gnn-matlang-main/enzymes.py
from torch_geometric.data import DataLoader,InMemoryDataset import torch import scipy.io as sio from torch_geometric.data.data import Data import numpy as np from sklearn.metrics import r2_score from sklearn.model_selection import StratifiedKFold import os.path as osp import torch.nn as nn import torch.nn.functional a...
16,522
33.85865
155
py
gnn-matlang
gnn-matlang-main/libs/utils.py
import torch from torch_geometric.data import InMemoryDataset from torch_geometric.data.data import Data from torch_geometric.utils import to_networkx from torch_geometric.utils import to_undirected import numpy as np import networkx as nx import pickle import os import scipy.io as sio from math import comb def get_n...
23,338
32.389127
108
py
gnn-matlang
gnn-matlang-main/libs/layers_tf.py
from inits_tf import * import tensorflow as tf flags = tf.app.flags FLAGS = flags.FLAGS # global unique layer ID dictionary for layer name assignment _LAYER_UIDS = {} def get_layer_uid(layer_name=''): """Helper function, assigns unique layer IDs.""" if layer_name not in _LAYER_UIDS: _LAYER_UIDS[laye...
10,941
30.085227
118
py
gnn-matlang
gnn-matlang-main/libs/spect_conv.py
from typing import Optional from torch_geometric.typing import OptTensor import math import torch from torch.nn import Parameter from torch_geometric.nn.conv import MessagePassing from torch_geometric.utils import remove_self_loops, add_self_loops from torch_geometric.utils import get_laplacian import torch.nn.function...
6,649
30.367925
129
py
Game-Theoretic-Deep-Reinforcement-Learning
Game-Theoretic-Deep-Reinforcement-Learning-main/Agents/MAD4PG/gradient.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
54,279
38.794721
93
py
Game-Theoretic-Deep-Reinforcement-Learning
Game-Theoretic-Deep-Reinforcement-Learning-main/Agents/MADRL/gradient.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
54,279
38.794721
93
py
Game-Theoretic-Deep-Reinforcement-Learning
Game-Theoretic-Deep-Reinforcement-Learning-main/Agents/MAD5PG/gradient.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
54,279
38.794721
93
py
Game-Theoretic-Deep-Reinforcement-Learning
Game-Theoretic-Deep-Reinforcement-Learning-main/Agents/MAHD5PG/gradient.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
54,279
38.794721
93
py
remix
remix-main/tests/test_rule_extractors.py
""" Very minimal test that verifies that we can call all of our rule extractors using a simple XOR dataset with 10 features of which 8 are pure noise. """ import numpy as np import pandas as pd import pytest import sklearn import tensorflow as tf from remix import deep_red_c5 from remix import eclaire from remix impo...
8,456
29.978022
80
py
remix
remix-main/experiments/experiment_runners/cross_validation.py
from prettytable import PrettyTable import logging import numpy as np import pandas as pd import pickle import sklearn import tensorflow as tf from model_training.train import load_model from remix.evaluate_rules.evaluate import evaluate, evaluate_estimator from remix.utils.resources import resource_compute from remix...
12,737
37.835366
83
py
remix
remix-main/experiments/model_training/train_dnns.py
""" Generates neural networks for each of the n folds using the procedure specified to locate optimal neural network hyper-parameters and neural network initialization. Used mostly for experimentation. """ from collections import OrderedDict from tqdm import tqdm import logging import numpy as np import os import pan...
5,710
36.326797
79
py
remix
remix-main/experiments/model_training/grid_search.py
""" Runs a grid search over hyper-parameters of our model to try and find the best hyper-parameterization. """ from tensorflow.keras.wrappers.scikit_learn import KerasClassifier import itertools import json import logging import numpy as np import sklearn import tensorflow as tf from .train import model_fn def dese...
6,292
31.107143
77
py
remix
remix-main/experiments/model_training/train.py
""" Build neural network models given number of nodes in each hidden layer """ import logging import numpy as np import os import sklearn import tensorflow as tf ################################################################################ ## Metric Functions ######################################################...
12,974
34.067568
80
py
remix
remix-main/remix/extract_rules/deep_red_c5.py
""" Implementation of DeepRED algorithm using C5.0 rather than C4.5 for intermediate rule extraction. """ import dill import logging import numpy as np from multiprocessing import Pool from remix.logic_manipulator.substitute_rules import substitute from remix.rules.C5 import C5 from remix.rules.cart import cart_rules...
15,414
43.423631
80
py
remix
remix-main/remix/extract_rules/rem_d.py
""" Main implementation of the vanilla REM-D rule extraction algorithm for DNNs. """ import dill import logging import numpy as np from remix.logic_manipulator.substitute_rules import substitute from remix.rules.C5 import C5 from remix.rules.cart import cart_rules, random_forest_rules from remix.rules.rule import Rule...
15,567
42.853521
80
py
remix
remix-main/remix/extract_rules/utils.py
""" Helper utilities common to several rule extractors. """ import pandas as pd import scipy.special as activation_fns import tensorflow.keras.models as keras ################################################################################ ## Helper Classes ###########################################################...
6,691
40.308642
80
py
remix
remix-main/remix/extract_rules/eclaire.py
""" Implementation of ECLAIRE algorithm. This algorithm extracts intermediate rules for each hidden layer and then performs a change of variables in all of these rule sets by using a clause-wise level rather than at a term-wise level. This helps the model avoiding the exponential explosion of terms that arises from dis...
27,886
42.77865
80
py
remix
remix-main/remix/extract_rules/pedagogical.py
""" Baseline implementation of an algorithm to extract rules from a DNN using a simple pedagogical algorithm: we extract a decision tree that maps input features with the model's outputs. """ import numpy as np import pandas as pd from remix.logic_manipulator.merge import merge from remix.rules.C5 import C5 from rem...
7,315
37.303665
80
py
remix
remix-main/remix/extract_rules/rem_t.py
""" Baseline implementation of an algorithm to extract rules while ignoring the given DNN's predictions. It simply uses a vanilla decision tree learner and extracts rules from it. """ import numpy as np import pandas as pd from remix.logic_manipulator.merge import merge from remix.rules.C5 import C5 from remix.rules....
5,794
37.633333
80
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/main.py
import argparse import json import torch from torch import nn, optim from torch.autograd import Variable from torch.distributions import Categorical from cknrm_tokenizer import * from policies import * from dataloaders import * from models import * from metrics import * from transformers import * def dev(args, mode...
11,421
41.460967
148
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/policies/policy.py
import torch from torch import nn import torch.nn.functional as F from models import cknrm class Policy(nn.Module): def __init__(self, args, embedding_init=None): super(Policy, self).__init__() self.embedding = nn.Embedding(args.vocab_size, args.embed_dim) if embedding_init is not None: ...
2,008
40
94
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/models/bert.py
import torch import torch.nn as nn from transformers import AutoModel class Bert(nn.Module): def __init__(self, pretrained, enc_dim): super(Bert, self).__init__() self._model = AutoModel.from_pretrained(pretrained) self._dense = nn.Linear(enc_dim, 1) def forward(self, input_ids, atten...
668
36.166667
106
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/models/cknrm.py
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F def kernal_mus(n_kernels): l_mu = [1] if n_kernels == 1: return l_mu bin_size = 2.0 / (n_kernels - 1) # score range from [-1, 1] l_mu.append(1 - bin_size / 2) # mu: middle of the bin fo...
6,341
52.745763
147
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/dataloaders/bert_dataloader.py
import numpy as np import torch from torch import nn def pack_bert_seq(q_tokens, p_tokens, tokenizer, max_seq_length): tokens = [] segment_ids = [] tokens.append("[CLS]") segment_ids.append(0) for token in q_tokens: tokens.append(token) segment_ids.append(0) tokens.append("[SEP]...
7,445
42.54386
140
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/dataloaders/dataloader.py
import numpy as np import torch from torch import nn def read_train_to_features(args, tokenizer): with open(args.train, 'r') as reader: features = [] for line in reader: if len(features) >= args.max_input: break s = line.strip('\n').split('\t') q...
5,297
41.047619
110
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/inference/cknrm_inference.py
import os import re import json import argparse import numpy as np import torch from torch import nn from torch.autograd import Variable import torch.nn.functional as F from CKNRM import CKNRM from nltk.corpus import stopwords sws = {} for w in stopwords.words('english'): sws[w] = 1 from krovetzstemmer import Stem...
9,943
37.099617
120
py
ReInfoSelect
ReInfoSelect-master/ReInfoSelect/inference/CKNRM.py
import torch.nn.functional as F from torch.autograd import Variable import torch import torch.nn as nn def kernal_mus(n_kernels): """ get the mu for each gaussian kernel. Mu is the middle of each bin :param n_kernels: number of kernels (including exact match). first one is exact match :return: l_mu, a ...
6,437
52.65
148
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/preprocessing/ccccii/show_img.py
import cv2 import numpy as np from PIL import Image from scipy import misc import os import sys import cv2 from skimage import measure, morphology, segmentation MIN_BOUND = -1000.0 MAX_BOUND = 400.0 def normalize(image): image = (image - MIN_BOUND) / (MAX_BOUND - MIN_BOUND) image[image>1] = 1. image[...
1,487
19.666667
103
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/main.py
""" Runs a model on a single node across N-gpus. """ import argparse import os import sys from argparse import ArgumentParser import numpy as np import torch from torchline.config import get_cfg from torchline.engine import build_module from torchline.models import META_ARCH_REGISTRY from torchline.trainer import buil...
3,759
36.6
139
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/config/config.py
from torchline.config import CfgNode as CN __all__ = [ 'add_config' ] def add_config(cfg): ''' cfg.new_item = CN() ''' cfg.mixup = CN() cfg.mixup.enable = 0 cfg.mixup.alpha = 0.4 cfg.dataset.slice_num = 64 cfg.dataset.is_color = False cfg.dataset.is_3d = True cfg.dataset.s...
2,972
34.392857
84
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/pre_act_resnet.py
import torch import torch.nn as nn import torch.nn.functional as F from .resnet import conv3x3x3, conv1x1x1, get_inplanes, ResNet from torchline.models import META_ARCH_REGISTRY __all__ = ['preact_resnet3d'] class PreActivationBasicBlock(nn.Module): expansion = 1 def __init__(self, in_planes, planes, str...
3,307
27.765217
120
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/resnet.py
import math from functools import partial import torch import torch.nn as nn import torch.nn.functional as F from torchline.models import META_ARCH_REGISTRY __all__ = ['resnet3d'] def get_inplanes(): return [64, 128, 256, 512] def conv3x3x3(in_planes, out_planes, stride=1): return nn.Conv3d(in_planes, ...
8,020
30.829365
80
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/utils.py
import csv import random from functools import partialmethod import torch import numpy as np from sklearn.metrics import precision_recall_fscore_support class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self): self.reset() def reset(self): ...
2,325
22.979381
66
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/model.py
import torch import torch.nn as nn from torchvision import models from torchline.models import META_ARCH_REGISTRY __all__ = [ 'mc3_18', 'r3d_18', 'r2plus1d_18' ] model_urls = { 'r3d_18': 'https://download.pytorch.org/models/r3d_18-b3b3357e.pth', 'mc3_18': 'https://download.pytorch.org/models/mc3...
11,623
30.846575
106
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/densenet.py
import math import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from torchline.models import META_ARCH_REGISTRY __all__ = ['densenet3d'] class _DenseLayer(nn.Sequential): def __init__(self, num_input_features, growth_rate, bn_size, drop_rate): super()...
7,915
36.875598
95
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/resnet2d.py
import torch import torch.nn as nn import torchvision as tv from torchline.models import META_ARCH_REGISTRY def modify_in_channels(model, n_input_channels): conv1 = model.conv1 in_channels = conv1.in_channels out_channels = conv1.out_channels kernel_size = conv1.kernel_size model.conv1.in_channels...
2,768
41.6
102
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/resnext.py
import math from functools import partial import torch import torch.nn as nn import torch.nn.functional as F from .resnet import conv1x1x1, Bottleneck, ResNet from .utils import partialclass from torchline.models import META_ARCH_REGISTRY __all__ = ['resnext3d'] def get_inplanes(): return [128, 256, 512, 102...
2,770
30.488636
74
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/wide_resnet.py
import torch import torch.nn as nn import torch.nn.functional as F from . import resnet from torchline.models import META_ARCH_REGISTRY __all__ = ['wide_resnet3d'] class WideBottleneck(resnet.Bottleneck): expansion = 2 def generate_model(model_depth, k=2, **kwargs): assert model_depth in [50, 101, 152, 2...
996
27.485714
80
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/fake_model.py
import torch import torch.nn as nn from torchline.models import META_ARCH_REGISTRY __all__ = [ 'FakeNet3D', '_FakeNet3D', ] @META_ARCH_REGISTRY.register() def FakeNet3D(cfg): if cfg.dataset.is_3d: c_in = cfg.model.n_input_channels else: c_in = cfg.dataset.slice_num return _FakeNet...
750
22.46875
51
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/models/densenet2d.py
import torch import torch.nn as nn import torchvision as tv from torchline.models import META_ARCH_REGISTRY def modify_in_channels(model, n_input_channels): conv0 = model.features.conv0 in_channels = conv0.in_channels out_channels = conv0.out_channels kernel_size = conv0.kernel_size model.features...
1,147
38.586207
104
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/tests/test_nocolor_model.py
import sys sys.path.append('..') import torchline as tl from config.config import add_config import models import torch cfg = tl.config.get_cfg() cfg = add_config(cfg) cfg.merge_from_file('../config/config.yml') cfg.model.n_input_channels = 1 x = torch.rand(1,1,32,64,64) model_names = { 'mc3_18': [], 'r3d_18...
1,151
24.6
52
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/tests/test_2dmodels.py
import sys sys.path.append('..') import torch import models import torchline as tl from config.config import add_config cfg = tl.config.get_cfg() cfg = add_config(cfg) x = torch.rand(1,16,64,64) cfg.model.n_input_channels = 16 names = [ # 'resnet2d', 'resnext2d', 'wide_resnet2d', 'densenet2d'] depths =...
882
20.536585
54
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/tests/test_model.py
import sys sys.path.append('..') import torchline as tl from config.config import add_config import models cfg = tl.config.get_cfg() cfg = add_config(cfg) cfg.merge_from_file('../config/config.yml') model_names = { 'mc3_18': [], 'r3d_18': [], 'r2plus1d_18': [], 'densenet3d': [121,169,201,264], 're...
1,421
29.255319
69
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/engine/utils.py
import numpy as np import torch def mixup_data(x, y, alpha=1.0, use_cuda=True): '''Returns mixed inputs, pairs of targets, and lambda the larger the alpha, the more it can suppress overfitting. recommend alpha=0.4 ''' if alpha > 0: lam = np.random.beta(alpha, alpha) else: lam =...
701
26
68
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/engine/module.py
import os from collections import OrderedDict import numpy as np import torch import imblearn from sklearn import metrics from torchline.engine import MODULE_REGISTRY, DefaultModule, build_module from torchline.utils import AverageMeterGroup, topk_acc from .utils import mixup_data, mixup_loss_fn from medcam import m...
7,303
37.442105
131
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/utils/visual_cam.py
import os import sys import cv2 import matplotlib.pyplot as plt import numpy as np import torch from PIL import Image from skimage.transform import resize, rotate from torchvision import transforms as TF def pil_loader(path): # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/i...
7,388
33.528037
101
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/data/sampler.py
import torch import torchvision from torchline.data.sampler import SAMPLER_REGISTRY from torchline.data import build_data __all__ = [ 'WeightedRandomSampler', ] @SAMPLER_REGISTRY.register() def WeightedRandomSampler(cfg): dataset = build_data(cfg) sampler_cfg = cfg.dataloader.sampler weights = [] ...
657
25.32
84
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/data/fake_data.py
import torch from torchline.data import DATASET_REGISTRY __all__ = [ 'FakeData', '_FakeData' ] class _FakeData(torch.utils.data.Dataset): def __init__(self, channels=1, size=[64,64], num=4): if isinstance(size, int): self.size = [size, size] elif isinstance(size, list): ...
765
24.533333
56
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/data/ct_data.py
import json import os import random import nibabel as nib import imageio import PIL import cv2 import torch import torchvision.transforms as TF from torchline.data import (DATASET_REGISTRY, build_label_transforms, build_transforms) from .utils import SymmetricalResampler, RandomResampler, ...
7,805
37.453202
132
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/data/transforms.py
from torchline.data.transforms import TRANSFORMS_REGISTRY import torchio import torchio.transforms as iotf import torchvision import numpy as np __all__ = [ 'CTTransforms', '_CTTransforms' ] @TRANSFORMS_REGISTRY.register() def CTTransforms(cfg): is_train = cfg.dataset.is_train slice_num = cfg.dataset....
4,589
41.5
113
py
HKBU_HPML_COVID-19
HKBU_HPML_COVID-19-master/covid19_pipeline/losses/loss.py
from torchline.losses import LOSS_FN_REGISTRY
47
15
45
py
RVT
RVT-master/validation.py
import os os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID' os.environ["OMP_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["VECLIB_MAXIMUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" from pathlib import Path import torch from torch.backends import ...
2,625
27.857143
92
py
RVT
RVT-master/train.py
import os os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID' os.environ["OMP_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["VECLIB_MAXIMUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" import torch torch.multiprocessing.set_sharing_strategy('file_sy...
5,556
37.86014
118
py
RVT
RVT-master/modules/detection.py
from typing import Any, Optional, Tuple, Union, Dict from warnings import warn import numpy as np import pytorch_lightning as pl import torch import torch as th import torch.distributed as dist from omegaconf import DictConfig from pytorch_lightning.utilities.types import STEP_OUTPUT from data.genx_utils.labels impor...
19,420
48.417303
128
py
RVT
RVT-master/modules/utils/fetch.py
import pytorch_lightning as pl from omegaconf import DictConfig from modules.data.genx import DataModule as genx_data_module from modules.detection import Module as rnn_det_module def fetch_model_module(config: DictConfig) -> pl.LightningModule: model_str = config.model.name if model_str == 'rnndet': ...
1,205
40.586207
85
py
RVT
RVT-master/modules/utils/detection.py
from enum import Enum, auto from typing import List, Optional, Union, Tuple, Dict, Any import torch import torch as th from data.genx_utils.labels import SparselyBatchedObjectLabels from data.utils.types import BackboneFeatures, LstmStates, DatasetSamplingMode class Mode(Enum): TRAIN = auto() VAL = auto() ...
5,918
35.537037
117
py
RVT
RVT-master/modules/data/genx.py
from functools import partial from typing import Any, Dict, Optional, Union import math import pytorch_lightning as pl from omegaconf import DictConfig from torch.utils.data import DataLoader, Dataset from data.genx_utils.collate import custom_collate_rnd, custom_collate_streaming from data.genx_utils.dataset_rnd imp...
10,408
51.306533
120
py
RVT
RVT-master/callbacks/custom.py
from omegaconf import DictConfig from pytorch_lightning.callbacks import Callback from pytorch_lightning.callbacks import ModelCheckpoint from callbacks.detection import DetectionVizCallback def get_ckpt_callback(config: DictConfig) -> ModelCheckpoint: model_name = config.model.name prefix = 'val' if mo...
1,292
31.325
116
py