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
DSGC
DSGC-master/20news/main.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch.backends.cudnn as cudnn import torch.optim as optim from Optim import Optim import argparse import random import numpy as np; import Loader import timeit from models import ChebyNet, DCNN, MoNet, GCN, DSG...
4,168
36.558559
140
py
DSGC
DSGC-master/20news/utils.py
import torch import numpy as np; from torch.autograd import Variable from graph import *; import math; def normal_std(x): return x.std() * np.sqrt((len(x) - 1.)/(len(x))) class Data_utility(object): # train and valid is the ratio of training set and validation set. test = 1 - train - valid def __init__(s...
6,297
39.896104
110
py
DSGC
DSGC-master/20news/graph.py
import sklearn.metrics import sklearn.neighbors # import matplotlib.pyplot as plt import scipy.sparse import scipy.sparse.linalg import scipy.spatial.distance import numpy as np import torch import math; def grid(m, dtype=np.float32): """Return the embedding of a grid graph.""" M = m**2 x = np.linspace(0, ...
11,373
27.794937
79
py
DSGC
DSGC-master/20news/Optim.py
import math import torch.optim as optim class Optim(object): def _makeOptimizer(self): if self.method == 'sgd': self.optimizer = optim.SGD(self.params, lr=self.lr, weight_decay = self.weight_decay, momentum=0.9) elif self.method == 'adam': self.optimizer = optim.Adam(self.p...
903
29.133333
111
py
DSGC
DSGC-master/20news/models/GCN.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from PoolingLayer import Pooling cfgs = [64] * 5 L_cfgs = [0] * 5; nodes_num_list = [1000] * 5; nn_num_list = [32] * 5; pool_list = [-1] * 5 last_layer = 1000; class Model(nn.Module): def __init__(self, ar...
2,311
29.421053
65
py
DSGC
DSGC-master/20news/models/PoolingLayer.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class Pooling(nn.Module): def __init__(self, ks): super(Pooling, self).__init__() self.ks = ks self.pooling = torch.nn.MaxPool1d(ks) def forward(self, x, index): '''...
929
28.0625
65
py
DSGC
DSGC-master/20news/models/MoNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Variable from PoolingLayer import Pooling cfgs = [64] * 5 L_cfgs = [0] * 5; nodes_num_list = [1000] * 5; nn_num_list = [32] * 5; J_num = [32] * 5; last_layer = 1000; class Model(nn.M...
4,207
32.133858
83
py
DSGC
DSGC-master/20news/models/DSGC.py
import torch import torch.nn as nn import torch.nn.functional as F from XeLayer import XeLayer from PoolingLayer import Pooling from torch.nn.parameter import Parameter from torch.autograd import Variable cfgs = [64] * 5 L_cfgs = [0] * 5; nodes_num_list = [1000] * 5; nn_num_list = [64] * 5; pool_list = [-1] * 5 graph_...
3,860
32.284483
110
py
DSGC
DSGC-master/20news/models/ChebyNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from PoolingLayer import Pooling cfgs = [64] * 5 L_cfgs = [0] * 5; nodes_num_list = [1000] * 5; nn_num_list = [32] * 5; pool_list = [-1] * 5 last_layer = 1000; class Model(nn.Module): def __init__(self, args, dat...
2,909
33.642857
104
py
DSGC
DSGC-master/20news/models/XeLayer.py
import torch import torch.nn as nn import torch.nn.functional as F class XeLayer(nn.Module): def __init__(self, node_num, in_feature, out_feature, graph_num): super(XeLayer, self).__init__() self.in_feature = in_feature; self.out_feature = out_feature; self.in_hid = in_feature / gra...
1,442
33.357143
104
py
DSGC
DSGC-master/20news/models/DCNN.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter ''' cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024, 1024, 1024] L_cfgs = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]; nodes_num_list = [1024, 1024, 256, 256, 64, 64, 16, 16, 4, 4]; nn_num_list = [8, 8, 8, 8, 8, 8, 8, 8, 3,...
2,188
32.166667
102
py
DSGC
DSGC-master/time_series_forecasting/main.py
import argparse import math import time import torch import torch.nn as nn from models import LSTNet, AR, VAR, GCN, ChebyNet, MoNet, DSGC import numpy as np; import importlib from utils import *; import Optim def evaluate(loader, data, model, evaluateL2, evaluateL1, batch_size): model.eval(); total_loss = 0; ...
7,783
45.059172
226
py
DSGC
DSGC-master/time_series_forecasting/utils.py
import torch import numpy as np; from torch.autograd import Variable from graph import *; def normal_std(x): return x.std() * np.sqrt((len(x) - 1.)/(len(x))) class Data_utility(object): # train and valid is the ratio of training set and validation set. test = 1 - train - valid def __init__(self, args): ...
8,070
36.714953
116
py
DSGC
DSGC-master/time_series_forecasting/graph.py
import sklearn.metrics import sklearn.neighbors # import matplotlib.pyplot as plt import scipy.sparse import scipy.sparse.linalg import scipy.spatial.distance import numpy as np import torch import math; def grid(m, dtype=np.float32): """Return the embedding of a grid graph.""" M = m**2 x = np.linspace(0, ...
11,766
28.054321
84
py
DSGC
DSGC-master/time_series_forecasting/Optim.py
import math import torch.optim as optim class Optim(object): def _makeOptimizer(self): if self.method == 'sgd': self.optimizer = optim.SGD(self.params, lr=self.lr, weight_decay = self.weight_decay) elif self.method == 'adagrad': self.optimizer = optim.Adagrad(self.params, l...
2,342
33.970149
110
py
DSGC
DSGC-master/time_series_forecasting/models/GCN.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.m = data.m self.w = args.window if (args.mask): ...
2,309
32.478261
67
py
DSGC
DSGC-master/time_series_forecasting/models/VAR.py
import torch import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.m = data.m self.w = args.window if (args.mask): self.w = self.w * 2; se...
762
25.310345
57
py
DSGC
DSGC-master/time_series_forecasting/models/AR.py
import torch import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.m = data.m self.w = args.window if (args.mask): self.w *= 2; self.linea...
863
26
48
py
DSGC
DSGC-master/time_series_forecasting/models/LSTNet.py
import torch import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.P = args.window; self.m = data.m self.hidR = args.hidRNN; self.hidC = args.hidCNN; ...
2,354
30.824324
80
py
DSGC
DSGC-master/time_series_forecasting/models/MoNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Variable cfgs = [64] * 10 J_num = [8] * 10; class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda ...
3,903
31.264463
73
py
DSGC
DSGC-master/time_series_forecasting/models/DSGC.py
import torch import torch.nn as nn import torch.nn.functional as F from XeLayer import XeLayer from torch.nn.parameter import Parameter from torch.autograd import Variable _INF = float('inf'); cfgs = [64] * 10 graph_num = [4] * 10; class Model(nn.Module): def __init__(self, args, data): super(Model, sel...
3,417
30.648148
97
py
DSGC
DSGC-master/time_series_forecasting/models/ChebyNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.m = data.m self.w = args.window if (args.mask): ...
3,216
36.847059
68
py
DSGC
DSGC-master/time_series_forecasting/models/XeLayer.py
import torch import torch.nn as nn import torch.nn.functional as F class XeLayer(nn.Module): def __init__(self, node_num, in_feature, out_feature, graph_num): super(XeLayer, self).__init__() self.in_feature = in_feature; self.out_feature = out_feature; self.in_hid = in_feature / gra...
1,442
33.357143
104
py
DSGC
DSGC-master/time_series_forecasting/models/DCNN.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter class Model(nn.Module): def __init__(self, args, data): super(Model, self).__init__() self.use_cuda = args.cuda self.m = data.m self.w = args.window if (args.mask): ...
1,694
31.596154
87
py
DSGC
DSGC-master/cifar10/main.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch.backends.cudnn as cudnn from Optim import Optim import torch.optim as optim import argparse import random import numpy as np; import timeit from models import GCN, ChebyNet, MoNet, VGG, Xception, DSGCDens...
4,309
36.478261
140
py
DSGC
DSGC-master/cifar10/utils.py
import torch import numpy as np; from torch.autograd import Variable from graph import *; import math; def normal_std(x): return x.std() * np.sqrt((len(x) - 1.)/(len(x))) class Data_utility(object): # train and valid is the ratio of training set and validation set. test = 1 - train - valid def __init__(s...
6,393
39.213836
95
py
DSGC
DSGC-master/cifar10/graph.py
import sklearn.metrics import sklearn.neighbors # import matplotlib.pyplot as plt import scipy.sparse import scipy.sparse.linalg import scipy.spatial.distance import numpy as np import torch import math; def grid(m, dtype=np.float32): """Return the embedding of a grid graph.""" M = m**2 x = np.linspace(0, ...
9,872
27.208571
79
py
DSGC
DSGC-master/cifar10/Optim.py
import math import torch.optim as optim class Optim(object): def _makeOptimizer(self): if self.method == 'sgd': self.optimizer = optim.SGD(self.params, lr=self.lr, weight_decay = self.weight_decay, momentum=0.9) elif self.method == 'adam': self.optimizer = optim.Adam(self.p...
903
29.133333
111
py
DSGC
DSGC-master/cifar10/models/GCN.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from PoolingLayer import Pooling # hyper-parameters for the subsampled setting cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024] L_cfgs = [0, 0, 1, 1, 2, 2, 3, 3]; nodes_num_list = [256, 256, 64, 64, 16, 16, 4,...
3,194
32.28125
78
py
DSGC
DSGC-master/cifar10/models/GraphConv.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F from XeLayer import XeLayer class GraphConv(nn.Module): def __init__(self, node_num, in_feature, out_feature, loc_feature, graph_num): super(GraphConv, self).__init__() self.node_num = node_num;...
1,500
35.609756
96
py
DSGC
DSGC-master/cifar10/models/PoolingLayer.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class Pooling(nn.Module): def __init__(self, ks, method = 'max'): super(Pooling, self).__init__() self.ks = ks if (method == 'avg'): self.pooling = torch.nn.AvgPool1d(ks) ...
1,043
28.828571
65
py
DSGC
DSGC-master/cifar10/models/Xception.py
'''VGG11/13/16/19 in Pytorch.''' import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F cfg = { 'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG13': [256, 256, 'M', 512, 512, 'M', 512, 512, 'M', 512, 512, 'M', 1024, 1024, 'M'], ...
1,902
35.596154
117
py
DSGC
DSGC-master/cifar10/models/MoNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from torch.autograd import Variable from PoolingLayer import Pooling ''' #cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024] cfgs = [128, 128, 256, 256, 256, 256, 512, 512] L_cfgs = [0, 0, 1, 1, 2, 2, 3, 3]; node...
4,884
32.689655
95
py
DSGC
DSGC-master/cifar10/models/DSGC.py
import torch import torch.nn as nn import torch.nn.functional as F from GraphConv import GraphConv from PoolingLayer import Pooling from torch.nn.parameter import Parameter from torch.autograd import Variable # hyper-parameters for the subsampled setting cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024] L_cfgs = [0, ...
2,812
30.965909
82
py
DSGC
DSGC-master/cifar10/models/ChebyNet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from PoolingLayer import Pooling # hyper-parameters for the subsampled setting cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024] L_cfgs = [0, 0, 1, 1, 2, 2, 3, 3]; nodes_num_list = [256, 256, 64, 64, 16, 16, 4, 4]; ...
4,281
35.598291
111
py
DSGC
DSGC-master/cifar10/models/DSGCDense.py
import torch import torch.nn as nn import torch.nn.functional as F from GraphConv import GraphConv from PoolingLayer import Pooling from torch.nn.parameter import Parameter from torch.autograd import Variable #hyper-parameters for the origin setting ''' nodes_num_list = [1024, 256, 64, 16, 4]; blocks = [6, 12, 24, 16]...
4,811
32.416667
82
py
DSGC
DSGC-master/cifar10/models/XeLayer.py
import torch import torch.nn as nn import torch.nn.functional as F class XeLayer(nn.Module): def __init__(self, node_num, in_feature, out_feature, graph_num): super(XeLayer, self).__init__() self.in_feature = in_feature; self.out_feature = out_feature; self.graph_num = graph_num ...
1,338
33.333333
104
py
DSGC
DSGC-master/cifar10/models/InceLayer.py
import torch import torch.nn as nn import torch.nn.functional as F class InceLayer(nn.Module): def __init__(self, node_num, in_feature, out_feature, graph_num, depth): super(InceLayer, self).__init__() self.in_feature = in_feature; self.out_feature = out_feature / 2; self.in_hid = i...
1,544
34.113636
92
py
DSGC
DSGC-master/cifar10/models/VGG.py
'''VGG11/13/16/19 in Pytorch.''' import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F cfg = { 'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'VGG13': [256, 256, 'M', 512, 512, 'M', 512, 512, 'M', 512, 512, 'M', 512, 512, 'M'], '...
1,830
34.901961
117
py
DSGC
DSGC-master/cifar10/models/seex.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F class SEEX(nn.Module): def __init__(self, n, m): super(SEEX, self).__init__() self.r = 16; self.m = m; self.n = n; self.hid = self.m/self.r; self.linear1 = nn.Line...
897
27.967742
51
py
DSGC
DSGC-master/cifar10/models/DSGCSE.py
import torch import torch.nn as nn import torch.nn.functional as F from GraphConv import GraphConv from PoolingLayer import Pooling from torch.nn.parameter import Parameter from torch.autograd import Variable from seex import SEEX # hyper-parameters for the subsampled setting cfgs = [256, 256, 512, 512, 512, 512, 102...
2,982
31.075269
82
py
DSGC
DSGC-master/cifar10/models/DSGCInce.py
import torch import torch.nn as nn import torch.nn.functional as F from InceLayer import InceLayer from PoolingLayer import Pooling from torch.nn.parameter import Parameter from torch.autograd import Variable # hyper-parameters for the subsampled setting cfgs = [256, 256, 512, 512, 512, 512, 1024, 1024] L_cfgs = [0, ...
4,495
33.852713
109
py
OpenICL
OpenICL-main/setup.py
from setuptools import setup, find_packages from setuptools.command.install import install class DownloadNLTK(install): def run(self): self.do_egg_install() import nltk nltk.download('punkt') REQUIRES = """ transformers accelerate datasets>=2.7.1 evaluate>=0.3.0 faiss_gpu>=1.7.2 nltk>=3....
1,737
23.138889
72
py
OpenICL
OpenICL-main/openicl/icl_dataset_reader.py
"""Simple Dataset Reader""" from typing import List, Union, Optional, Dict from datasets import load_dataset from datasets import Dataset, DatasetDict from transformers import AutoTokenizer from datasets.splits import NamedSplit from openicl.icl_prompt_template import PromptTemplate from openicl.utils.check_type impor...
11,390
44.564
320
py
OpenICL
OpenICL-main/openicl/icl_inferencer/icl_cot_inferencer.py
"""chain-of-thought inferencer""" import torch from openicl import PromptTemplate from openicl.icl_retriever import * from openicl.icl_evaluator import * from openicl.icl_inferencer.icl_base_inferencer import BaseInferencer, GenInferencerOutputHandler from typing import List, Union, Optional from tqdm import tqdm from...
7,887
55.342857
145
py
OpenICL
OpenICL-main/openicl/icl_inferencer/icl_base_inferencer.py
"""Basic Inferencer""" import os import torch from openicl import BaseRetriever, PromptTemplate from openicl.utils.api_service import * from openicl.icl_evaluator import * from transformers import AutoTokenizer, AutoModelForCausalLM, PretrainedConfig, GPT2Tokenizer, AutoConfig, \ T5ForConditionalGeneration from ty...
13,816
48.880866
145
py
OpenICL
OpenICL-main/openicl/icl_inferencer/icl_channel_inferencer.py
"""PPL Inferencer""" import json import torch from openicl import PromptTemplate from openicl.icl_retriever import * from openicl.icl_evaluator import * from openicl.icl_inferencer.icl_base_inferencer import BaseInferencer, PPLInferencerOutputHandler from openicl.icl_inferencer.icl_ppl_inferencer import PPLInferencer ...
5,410
45.247863
113
py
OpenICL
OpenICL-main/openicl/icl_inferencer/icl_ppl_inferencer.py
"""PPL Inferencer""" import json import torch from openicl import PromptTemplate from openicl.icl_retriever import * from openicl.icl_evaluator import * from openicl.icl_inferencer.icl_base_inferencer import BaseInferencer, PPLInferencerOutputHandler from openicl.utils.logging import get_logger from openicl.utils.api_...
9,631
49.429319
145
py
OpenICL
OpenICL-main/openicl/icl_inferencer/icl_gen_inferencer.py
"""Direct Generation Inferencer""" import json import torch from openicl import PromptTemplate from openicl.icl_retriever import * from openicl.icl_evaluator import * from openicl.icl_inferencer.icl_base_inferencer import BaseInferencer, GenInferencerOutputHandler from openicl.utils.api_service import * from openicl.u...
7,691
56.834586
145
py
OpenICL
OpenICL-main/openicl/icl_retriever/icl_topk_retriever.py
"""Topk Retriever""" from openicl import DatasetReader from openicl.icl_dataset_reader import DatasetEncoder from openicl.icl_retriever import BaseRetriever from openicl.utils.collators import DataCollatorWithPaddingAndCuda from openicl.utils.logging import get_logger import torch from torch.utils.data import DataLoad...
6,165
50.815126
169
py
OpenICL
OpenICL-main/openicl/icl_retriever/icl_mdl_retriever.py
"""MDL Retriever""" from openicl import DatasetReader, PromptTemplate from openicl.icl_retriever.icl_topk_retriever import TopkRetriever from openicl.utils.calculate import entropy from openicl.utils.logging import get_logger from typing import List, Union, Optional, Tuple from transformers import AutoModelForCausalLM...
7,594
51.37931
169
py
OpenICL
OpenICL-main/openicl/utils/icl_common_utils.py
from torch.utils.data import DataLoader from openicl.icl_retriever import BaseRetriever from typing import List, Union, Optional from openicl import PromptTemplate from accelerate import Accelerator def get_dataloader(datalist: List[List], batch_size: int) -> DataLoader: dataloader = DataLoader(datalist, batch_si...
2,224
56.051282
120
py
OpenICL
OpenICL-main/openicl/utils/logging.py
import logging import torch.distributed as dist LOG_LEVEL = logging.INFO SUBPROCESS_LOG_LEVEL = logging.ERROR LOG_FORMATTER = '[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s' def get_logger(name, level=LOG_LEVEL, log_file=None, file_mode='w'): formatter = logging.Formatter(LOG_FORMATTER) logger = log...
1,108
26.04878
70
py
OpenICL
OpenICL-main/openicl/utils/collators.py
from dataclasses import dataclass from typing import Any, Dict, List, Optional, Union import torch from transformers import PreTrainedTokenizerBase, BatchEncoding from transformers.file_utils import PaddingStrategy import numpy as np class ListWrapper: def __init__(self, data: List[Any]): self.data = dat...
1,931
27.411765
99
py
OpenICL
OpenICL-main/docs/source/conf.py
# -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # ...
2,098
33.409836
113
py
mlr3keras
mlr3keras-master/inst/python/generators/keras_generators.py
import os import warnings import numpy as np from keras.preprocessing.image import Iterator, ImageDataGenerator from keras.utils import Sequence class Numpy2DArrayIterator(Iterator): """Iterator yielding data from a Numpy array. (adapted from https://github.com/keras-team/keras-preprocessing) # Arguments...
7,143
37
89
py
mlr3keras
mlr3keras-master/inst/python/generators/__init__.py
from .keras_generators import *
32
15.5
31
py
A.I.A.Co
A.I.A.Co-main/train_model.py
import random import os import string import pandas as pd import numpy as np from keras.models import Sequential from keras.layers import Dense from tensorflow.keras.models import Model, load_model from tensorflow.keras.utils import to_categorical import numpy as np import seaborn as sns import matplotlib.pyplot as plt...
8,350
43.657754
275
py
OTP
OTP-master/utils_sampler.py
import torch import torch.nn as nn class Sample_Categorical(nn.Module): def __init__(self, tau): super(Sample_Categorical, self).__init__() self.tau = tau def forward(self, logits, smoothing=None): # logits : [B, K, 1], K categories logits = logits.squeeze(-1) c = logits.size(-1) ...
2,147
28.833333
85
py
OTP
OTP-master/train_cp_model.py
import torch, os import torch.nn as nn from tqdm import tqdm import numpy as np from scipy import stats import matplotlib.pyplot as plt from cp_model import PoissonModel from utils_io import load_model import sys action = sys.argv[1] device_ids = [2,3,1,0] device = torch.device('cuda' if torch.cuda.is_available() el...
3,002
24.025
84
py
OTP
OTP-master/utils_io.py
import pickle import torch import numpy as np def load_txt(datadir): with open(datadir, encoding='utf-8') as f: data = f.read().splitlines() return data def load_pickle(datadir): file = open(datadir, 'rb') data = pickle.load(file) return data def write_pickle(data, savedir): file = open...
2,784
32.963415
82
py
OTP
OTP-master/topic_model.py
import torch import torch.nn as nn from utils_sampler import Sample_Dirichlet, Sample_Categorical, Sample_Bernoulli class TopicBackward(nn.Module): def __init__(self, V, K, H, D, tau): super(TopicBackward, self).__init__() self.embed_layer = nn.Sequential( nn.Linear(1, H), ...
2,802
28.197917
81
py
OTP
OTP-master/music_model.py
import torch import torch.nn as nn from utils_sampler import Sample_Categorical, Sample_Bernoulli class MusicBackward(nn.Module): def __init__(self, K, H, D, tau): super(MusicBackward, self).__init__() self.linear = nn.Sequential( nn.Linear(D, H), nn.ReLU(), ...
2,591
25.721649
80
py
OTP
OTP-master/train_topic_model.py
import torch, os import torch.nn as nn import time import ot from tqdm import tqdm import gensim.corpora as corpora from octis.dataset.dataset import Dataset from torch.utils.data import DataLoader from topic_model import TopicModel from utils_io import load_model from octis.evaluation_metrics.diversity_metrics impo...
4,421
25.963415
106
py
OTP
OTP-master/train_music_model.py
import torch, os import torch.nn as nn from tqdm import tqdm import numpy as np import matplotlib.pyplot as plt from music_model import MusicModel, Criterion from utils_io import load_model, load_music_data from trainer import train_epoch, val_epoch torch.manual_seed(8) import sys action = sys.argv[1] device_ids = [2...
2,388
26.77907
102
py
OTP
OTP-master/utils_model.py
import torch import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm def one_hot_sequential_vectorizer(corpus, word2id, L): corpus = [lt for lt in corpus if len(lt) >= L] B = len(corpus) V = len(word2id) inp = torch.zeros((B, L, V)) for i, doc in enumerate(corpus): for j i...
4,994
29.644172
88
py
OTP
OTP-master/synthetic_model.py
import torch import torch.nn as nn from utils_sampler import Sample_Dirichlet, Sample_Categorical class TopicBackward(nn.Module): def __init__(self, L, V, K, H, D, tau): super(TopicBackward, self).__init__() self.lstm = nn.LSTM(V, D, batch_first = True) self.topic_layer = nn.Se...
2,675
26.030303
79
py
OTP
OTP-master/cp_model.py
import torch import torch.nn as nn from utils_sampler import Sample_Categorical class PoissonBackward(nn.Module): def __init__(self, K, L, tau): super(PoissonBackward, self).__init__() self.linear = nn.Sequential( nn.Linear(1, L), nn.ReLU(), nn.Linear(L, ...
2,426
24.547368
83
py
OTP
OTP-master/train_synth_topic.py
import torch, os import torch.nn as nn import sys, time import ot from tqdm import tqdm from torch.utils.data import DataLoader from topic_model import TopicModel from utils_model import load_topic_config from utils_io import load_model, write_pickle, load_pickle import numpy as np def train_epoch(model, optimizer, ...
6,357
27.769231
106
py
OTP
OTP-master/drepl/main.py
import os import argparse from configs.defaults import get_cfgs_defaults import torch from trainer import OTP_Trainer from util import set_seeds, get_loader def arg_parse(): parser = argparse.ArgumentParser( description="main.py") parser.add_argument( "-c", "--config_file", default="", he...
2,663
30.341176
117
py
OTP
OTP-master/drepl/model.py
import numpy as np import torch import torch.nn.functional as F from torch import nn from quantizer import VectorQuantizer, WS_VectorQuantizer, Fast_WS_VectorQuantizer import networks.mnist as net_mnist import networks.fashion_mnist as net_fashionmnist import networks.cifar10 as net_cifar10 import networks.svhn as net...
5,924
34.059172
138
py
OTP
OTP-master/drepl/util.py
import os import random import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import numpy as np import torch from torchvision import datasets, transforms from torch.utils.data.dataset import Subset from torch.utils.data import DataLoader import time import os import imageio import requests from tqdm ...
15,134
37.219697
148
py
OTP
OTP-master/drepl/trainer_base.py
import shutil import json import datetime from torch import nn from model import OPT_VQAE from util import * from util_plot import tsne_plot class TrainerBase(nn.Module): def __init__(self, cfgs, flgs, train_loader, val_loader, test_loader): super(TrainerBase, self).__init__() self.cfgs = cfgs ...
8,120
35.913636
92
py
OTP
OTP-master/drepl/trainer.py
import time from trainer_base import TrainerBase from util import * from torch import nn class OTP_Trainer(TrainerBase): def __init__(self, cfgs, flgs, train_loader, val_loader, test_loader): super(OTP_Trainer, self).__init__( cfgs, flgs, train_loader, val_loader, test_loader) self.pl...
6,591
42.368421
120
py
OTP
OTP-master/drepl/quantizer.py
import torch import torch.nn.functional as F from torch import nn from torch.distributions import Categorical import ot from torch import nn class VectorQuantizer(nn.Module): def __init__(self, size_dict, dim_dict, cfgs): super(VectorQuantizer, self).__init__() self.size_dict = size_dict self.dim_dict = dim_di...
9,957
31.019293
169
py
OTP
OTP-master/drepl/networks/net_32.py
from torch import nn from networks.util import ResBlock import torch.nn.functional as F class ResidualLayer(nn.Module): """ One residual layer inputs: - in_dim : the input dimension - h_dim : the hidden layer dimension - res_h_dim : the hidden dimension of the residual block """ def __init...
3,977
30.824
81
py
OTP
OTP-master/drepl/networks/util.py
from torch import nn ## Resblocks class ResBlock(nn.Module): def __init__(self, dim, act="relu"): super().__init__() if act == "relu": activation = nn.ReLU() elif act == "elu": activation = nn.ELU() self.block = nn.Sequential( activation, ...
550
22.956522
41
py
OTP
OTP-master/drepl/networks/net_32_mnist.py
from torch import nn from networks.util import ResBlock import torch.nn.functional as F class ResidualLayer(nn.Module): """ One residual layer inputs: - in_dim : the input dimension - h_dim : the hidden layer dimension - res_h_dim : the hidden dimension of the residual block """ def __init...
3,978
30.579365
81
py
OTP
OTP-master/drepl/evaluations/inception.py
import torch import torch.nn as nn import torch.nn.functional as F import torchvision try: from torchvision.models.utils import load_state_dict_from_url except ImportError: from torch.utils.model_zoo import load_url as load_state_dict_from_url # Inception weights ported to Pytorch from # http://download.tenso...
12,171
36.801242
126
py
OTP
OTP-master/drepl/evaluations/evaluation.py
import os import glob import shutil import lpips import numpy as np import argparse from PIL import Image from skimage.metrics import structural_similarity as ssim from skimage.metrics import peak_signal_noise_ratio as psnr from image_folder import make_dataset import torch parser = argparse.ArgumentParser(description...
4,227
40.048544
152
py
OTP
OTP-master/drepl/evaluations/fid_score.py
"""Calculates the Frechet Inception Distance (FID) to evalulate GANs The FID metric calculates the distance between two distributions of examples. Typically, we have summary statistics (mean & covariance matrix) of one of these distributions, while the 2nd distribution is given by a GAN. When run as a stand-alone progr...
9,618
38.101626
118
py
OTP
OTP-master/drepl/datasets/block.py
import cv2 import numpy as np from torch.utils.data import Dataset class BlockDataset(Dataset): """ Creates block dataset of 32X32 images with 3 channels requires numpy and cv2 to work """ def __init__(self, file_path, train=True, transform=None): print('Loading block data') data ...
1,819
27.888889
78
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/dataset_argoverse.py
import copy import math import multiprocessing import os import pickle import random import zlib from collections import defaultdict from multiprocessing import Process from random import choice from pathlib import Path import numpy as np import torch from tqdm import tqdm import utils_cython import utils from utils ...
32,151
36.429569
150
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/utils.py
import argparse import inspect import json import math import multiprocessing import os import pickle import random import subprocess import sys import time import pdb from collections import defaultdict from multiprocessing import Process from random import randint from typing import Dict, List, Tuple, NamedTuple, Any...
63,589
34.564877
2,154
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/run.py
import argparse import itertools import logging import os import time from functools import partial import numpy as np import torch import torch.distributed as dist import torch.multiprocessing as mp from torch.nn.parallel import DistributedDataParallel as DDP from torch.utils.data import RandomSampler from torch.util...
11,697
34.23494
122
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/do_eval.py
import argparse import logging import os from functools import partial import numpy as np import torch from torch.utils.data import RandomSampler, SequentialSampler from tqdm import tqdm import structs import utils from modeling.vectornet import VectorNet logging.basicConfig(format='%(asctime)s - %(levelname)s - %(n...
6,039
37.967742
133
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/modeling/lib.py
import math import numpy as np import torch import torch.nn.functional as F from torch import nn, Tensor import utils class LayerNorm(nn.Module): r""" Layer normalization. """ def __init__(self, hidden_size, eps=1e-5): super(LayerNorm, self).__init__() self.weight = nn.Parameter(tor...
8,924
44.075758
125
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/modeling/decoder.py
from typing import Dict, List, Tuple, NamedTuple, Any import numpy as np import torch import torch.nn.functional as F from torch import nn, Tensor import structs import utils_cython from modeling.lib import PointSubGraph, GlobalGraphRes, CrossAttention, GlobalGraph, MLP import utils class DecoderRes(nn.Module): ...
28,356
51.904851
150
py
DenseTNT-argoverse2
DenseTNT-argoverse2/src/modeling/vectornet.py
from typing import Dict, List, Tuple, NamedTuple, Any import numpy as np import torch import torch.nn.functional as F from torch import nn, Tensor from modeling.decoder import Decoder, DecoderResCat from modeling.lib import MLP, GlobalGraph, LayerNorm, CrossAttention, GlobalGraphRes import utils class NewSubGraph(n...
7,838
44.051724
140
py
gpu_performance_api
gpu_performance_api-master/docs/sphinx/source/conf.py
# Copyright (c) 2018-2022 Advanced Micro Devices, Inc. All rights reserved. # # # -*- coding: utf-8 -*- # # GPUPerfAPI documentation build configuration file, created by # sphinx-quickstart on Wed Jan 10 14:37:31 2018. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that no...
6,260
29.691176
79
py
Torch-Pruning
Torch-Pruning-master/setup.py
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="torch-pruning", version="v1.1.9", author="Gongfan Fang", author_email="gongfan@u.nus.edu", description="Structural Pruning for Model Acceleration.", long_description=long_description, ...
702
28.291667
61
py
Torch-Pruning
Torch-Pruning-master/benchmarks/main.py
import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from functools import partial import argparse import torch import torch.nn as nn import torch.nn.functional as F import torch_pruning as tp import engine.utils as utils import registry parser = argparse.ArgumentParser() # ...
14,245
39.356941
123
py
Torch-Pruning
Torch-Pruning-master/benchmarks/registry.py
from pyexpat import model from torchvision import datasets, transforms as T from PIL import PngImagePlugin LARGE_ENOUGH_NUMBER = 100 PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2) import os, sys import engine.models as models import engine.utils as utils from functools import partial NORMALIZE_DICT = {...
6,287
38.54717
102
py
Torch-Pruning
Torch-Pruning-master/benchmarks/main_imagenet.py
import datetime import os, sys import time import warnings import registry sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True import warnings warnings.filterwarnings("ignore", category=UserWarning) from engine.utils.imagenet_u...
29,151
50.054291
278
py
Torch-Pruning
Torch-Pruning-master/benchmarks/prunability/yolov7_detect_pruned.py
# Please put this script under official yolov7 repo: https://github.com/WongKinYiu/yolov7 # python yolov7_detect_pruned.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg &> output.log import argparse import time from pathlib import Path import cv2 import torch import torch.backend...
10,823
45.25641
139
py
Torch-Pruning
Torch-Pruning-master/benchmarks/prunability/yolov8_pruning.py
# This code is adapted from Issue [#147](https://github.com/VainF/Torch-Pruning/issues/147), implemented by @Hyunseok-Kim0. import argparse import math import os from copy import deepcopy from datetime import datetime from pathlib import Path from typing import List, Union import numpy as np import torch import torch....
15,081
37.37659
123
py
Torch-Pruning
Torch-Pruning-master/benchmarks/prunability/yolov7_train_pruned.py
import argparse import logging import math import os import random import time from copy import deepcopy from pathlib import Path from threading import Thread import numpy as np import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.optim.lr_sche...
39,641
52.282258
151
py
Torch-Pruning
Torch-Pruning-master/benchmarks/prunability/torchvision_pruning.py
import os, sys sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))) # torchvision==0.13.1 ########################################### # Prunable Models ############################################ from torchvision.models.detection.ssdlite import ssdlite320_mo...
10,793
36.873684
214
py
Torch-Pruning
Torch-Pruning-master/benchmarks/engine/models/imagenet/vision_transformer.py
import math from collections import OrderedDict from functools import partial from typing import Any, Callable, List, NamedTuple, Optional, Dict import torch import torch.nn as nn from torchvision.ops.misc import Conv2dNormActivation, MLP from torchvision.transforms._presets import ImageClassification, InterpolationM...
31,724
36.192263
161
py
Torch-Pruning
Torch-Pruning-master/benchmarks/engine/models/imagenet/__init__.py
from torchvision.models import ( resnet50, densenet121, mobilenet_v2, googlenet, inception_v3, squeezenet1_1, vgg16_bn, vgg19_bn, mnasnet1_0, alexnet, ) try: from torchvision.models import regnet_x_1_6gf from torchvision.models import resnext50_32x4d from .vision_tr...
426
19.333333
50
py