repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
hepdata-converter
hepdata-converter-master/hepdata_converter/writers/root_writer.py
# -*- coding: utf-8 -*- import abc from hepdata_converter.writers.array_writer import ArrayWriter, ObjectWrapper, ObjectFactory import ROOT as ROOTModule import array import tempfile import os from ctypes import c_char_p from hepdata_converter.writers.utils import error_value_processor __author__ = 'Michał Szostak' i...
20,446
43.06681
131
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_csvwriter.py
import os import hepdata_converter from hepdata_converter import convert from hepdata_converter.testsuite import insert_path, insert_data_as_str from hepdata_converter.testsuite.test_writer import WriterTestSuite class CSVWriterTestCase(WriterTestSuite): @insert_path('yaml_full') def setUp(self, submission_f...
5,281
51.29703
106
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_yamlwriter.py
# -*- encoding: utf-8 -*- import os import hepdata_converter from hepdata_converter.testsuite import insert_data_as_file, insert_data_as_str, insert_path from hepdata_converter.testsuite.test_writer import WriterTestSuite __author__ = 'Michał Szostak' class YAMLWriterTestSuite(WriterTestSuite): @insert_path('old...
1,969
42.777778
108
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_rootwriter.py
# -*- encoding: utf-8 -*- import os import hepdata_converter from hepdata_converter.testsuite import insert_path, insert_paths from hepdata_converter.testsuite.test_writer import WriterTestSuite import ROOT __author__ = 'Michał Szostak' def walk(tdirectory, path=None, depth=0): '''Walk the direc...
4,164
40.65
98
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_oldhepdata.py
import hepdata_converter from hepdata_converter.parsers import yaml_parser from hepdata_converter.parsers.oldhepdata_parser import OldHEPData from hepdata_converter.testsuite import insert_data_as_file, insert_path from hepdata_converter.testsuite.test_writer import WriterTestSuite class OldHEPDataTestSuite(WriterTes...
1,812
41.162791
82
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_getconcretesubclassmixin.py
import abc import unittest from hepdata_converter.common import GetConcreteSubclassMixin class ParserTestSuite(unittest.TestCase): """Test suite for Parser factory class """ def test_get_all_subclasses(self): class A(GetConcreteSubclassMixin): pass class AB(A): pa...
660
22.607143
94
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_parser.py
import unittest import datetime from hepdata_converter.parsers import Parser from hepdata_converter.parsers.oldhepdata_parser import OldHEPData from hepdata_converter.parsers.yaml_parser import YAML from hepdata_converter.testsuite import insert_paths class ParserTestSuite(unittest.TestCase): """Test suite for ...
1,111
37.344828
97
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_convert.py
import io import os import yaml import hepdata_converter from hepdata_converter.testsuite import insert_path from hepdata_converter.testsuite.test_writer import WriterTestSuite # We try to load using the CSafeLoader for speed improvements. try: from yaml import CSafeLoader as Loader except ImportError: #pragma: no...
5,806
47.391667
193
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_yodawriter.py
# -*- encoding: utf-8 -*- import os import hepdata_converter from hepdata_converter.testsuite import insert_data_as_file, insert_path, insert_paths from hepdata_converter.testsuite.test_writer import WriterTestSuite __author__ = 'Michał Szostak' class YODAWriterTestSuite(WriterTestSuite): @insert_path('yaml_full...
1,652
46.228571
98
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_yamlparser.py
# -*- encoding: utf-8 -*- import hepdata_converter from hepdata_converter.testsuite import insert_path, insert_data_as_str from hepdata_converter.testsuite.test_writer import WriterTestSuite __author__ = 'Michał Szostak' class YAMLWriterTestSuite(WriterTestSuite): @insert_path('yaml_qual') @insert_data_as_st...
807
41.526316
98
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_clitools.py
import os import hepdata_converter from hepdata_converter.testsuite import insert_data_as_str, insert_path from hepdata_converter.testsuite.test_writer import WriterTestSuite class CLIToolsTestSuite(WriterTestSuite): def test_wrong_call(self): self.assertRaises(SystemExit, hepdata_converter.main, []) ...
1,697
42.538462
96
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_optioninitmixin.py
import unittest from hepdata_converter.common import OptionInitMixin, Option class OptionInitMixinTestSuite(unittest.TestCase): def test_dir(self): class TestClass(OptionInitMixin): @classmethod def options(cls): return { 'testoption': Option('testop...
623
27.363636
62
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/__init__.py
import os from random import randint import tempfile import unittest import shutil import time import yaml # We try to load using the CSafeLoader for speed improvements. try: from yaml import CSafeLoader as Loader except ImportError: #pragma: no cover from yaml import SafeLoader as Loader #pragma: no cover de...
4,079
32.170732
144
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_writer.py
from hepdata_converter.testsuite import TMPDirMixin, ExtendedTestCase class WriterTestSuite(TMPDirMixin, ExtendedTestCase): pass
135
21.666667
69
py
hepdata-converter
hepdata-converter-master/hepdata_converter/testsuite/test_arraywriter.py
import os from hepdata_converter import convert from hepdata_converter.testsuite import insert_path from hepdata_converter.testsuite.test_writer import WriterTestSuite class ArrayWriterTestSuite(WriterTestSuite): @insert_path('yaml_full') def test_select_table(self, submission_filepath): csv_content =...
1,414
57.958333
123
py
hepdata-converter
hepdata-converter-master/hepdata_converter/parsers/yaml_parser.py
import yaml # We try to load using the CSafeLoader for speed improvements. try: from yaml import CSafeLoader as Loader except ImportError: #pragma: no cover from yaml import SafeLoader as Loader #pragma: no cover from hepdata_validator import LATEST_SCHEMA_VERSION from hepdata_validator.submission_file_validat...
4,770
41.981982
109
py
hepdata-converter
hepdata-converter-master/hepdata_converter/parsers/oldhepdata_parser.py
from hepdata_converter.common import OptionInitMixin, Option from hepdata_converter.parsers import Parser, ParsedData, BadFormat, Table import copy import re class HEPTable(Table): """Extension of Table including some place for temporary data needed during conversion """ def __init__(self, index=None, dat...
31,065
42.207232
269
py
hepdata-converter
hepdata-converter-master/hepdata_converter/parsers/__init__.py
import abc import copy import os from hepdata_converter.common import GetConcreteSubclassMixin, OptionInitMixin __all__ = [] import pkgutil import inspect class BadFormat(Exception): """Class for exceptions raised if bad formatting of parser's input file prohibits from parsing the file correctly """ ...
5,961
31.053763
112
py
gr-iio
gr-iio-master/python/iio/attr_updater.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2018 Analog Devices Inc. # Author: Travis Collins <travis.collins@analog.com> # # This is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version...
2,404
29.833333
83
py
gr-iio
gr-iio-master/python/iio/__init__.py
# # Copyright 2008,2009 Free Software Foundation, Inc. # # This application is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # This application is di...
1,350
32.775
74
py
SimPer
SimPer-main/src/augmentation.py
""" Augmentations for SimPer (and other SSL methods). """ import tensorflow as tf import tensorflow_probability as tfp from typing import Optional, Tuple def random_apply(func, p, x): return tf.cond( tf.less(tf.random.uniform([], minval=0, maxval=1, dtype=tf.float32), tf.cast(p, tf.float32...
9,872
38.178571
87
py
SimPer
SimPer-main/src/simper.py
""" Minimal SimPer implementation & example training loops. """ import tensorflow as tf from networks import Featurizer, Classifier @tf.function def _max_cross_corr(feats_1, feats_2): # feats_1: 1 x T(# time stamp) # feats_2: M(# aug) x T(# time stamp) feats_2 = tf.cast(feats_2, feats_1.dtype) feats_1...
5,269
35.344828
91
py
SimPer
SimPer-main/src/utils.py
import numpy as np import tensorflow as tf import tensorflow_probability as tfp def _dot_similarity_dim1(x, y): # (N, 1, C), (N, C, 1) -> (N, 1, 1) v = tf.matmul(tf.expand_dims(x, 1), tf.expand_dims(y, 2)) return v def _dot_similarity_dim2(x, y): v = tf.tensordot(tf.expand_dims(x, 1), tf.expand_dims...
999
27.571429
86
py
SimPer
SimPer-main/src/networks.py
""" Example network architectures: - Featurizer (for representation learning) - Classifier (for downstream tasks) """ import tensorflow as tf from tensorflow.keras.layers import (Conv2D, Conv3D, Dense, Flatten, BatchNormalization, TimeDistributed, MaxPool2D, GlobalAveragePooling2D) ...
2,324
26.678571
88
py
sampling_cf
sampling_cf-main/main.py
import os import time import importlib import datetime as dt from tqdm import tqdm from utils import file_write, log_end_epoch, INF, valid_hyper_params from data_path_constants import get_log_file_path, get_model_file_path # NOTE: No global-level torch imports as the GPU-ID is set through code def train(model, crite...
10,944
39.238971
114
py
sampling_cf
sampling_cf-main/data_genie.py
from data_genie.data_genie_config import * from data_genie.data_genie_trainers import * from data_genie.data_genie_data import OracleData from data_genie.data_genie_model import PointwiseDataGenie, PairwiseDataGenie # NOTE: Please edit the config in `data_genie/data_genie_config.py` before \ # running this trainer s...
2,771
34.088608
124
py
sampling_cf
sampling_cf-main/loss.py
import torch import torch.nn.functional as F from torch_utils import is_cuda_available class CustomLoss(torch.nn.Module): def __init__(self, hyper_params): super(CustomLoss, self).__init__() self.forward = { 'explicit': self.mse, 'implicit': self.bpr, 'sequentia...
3,395
36.318681
94
py
sampling_cf
sampling_cf-main/utils.py
INF = float(1e6) def get_data_loader_class(hyper_params): from data_loaders import MF, MVAE, SASRec, SVAE return { "pop_rec": (MF.TrainDataset, MF.TestDataset), "bias_only": (MF.TrainDataset, MF.TestDataset), "MF_dot": (MF.TrainDataset, MF.TestDataset), "MF": (MF.TrainDataset, ...
4,305
39.622642
157
py
sampling_cf
sampling_cf-main/data.py
import os import h5py import json import math import random import numpy as np from collections import defaultdict import networkx as nx import networkit as nk nk.setNumberOfThreads(16) from graph_sampling.ForestFire import ForestFireSampler from graph_sampling.RW import RandomWalkWithRestartSampler class rating_dat...
15,733
40.405263
130
py
sampling_cf
sampling_cf-main/data_path_constants.py
import os from utils import get_common_path # Sampling experiments' constants BASE_SAMPLING_PATH = "./experiments/sampling_runs/" # Data-genie experiments' constants BASE_DATA_GENIE_PATH = "./experiments/data_genie/" def get_svp_log_file_path(hyper_params): return BASE_SAMPLING_PATH + "/results/logs/SVP/{}.txt"....
1,747
32.615385
97
py
sampling_cf
sampling_cf-main/hyper_params.py
hyper_params = { ## Dataset # [ 'ml-100k', 'magazine', 'software', 'luxury', 'fashion', 'industrial', 'goodreads_comics' ] 'dataset': 'magazine', ## Tasks # [ 'explicit', 'implicit', 'sequential' ] 'task': 'sequential', ## Sampling # [ complete_data, us...
1,302
32.410256
116
py
sampling_cf
sampling_cf-main/torch_utils.py
import torch is_cuda_available = torch.cuda.is_available() if is_cuda_available: print("Using CUDA...\n") LongTensor = torch.cuda.LongTensor FloatTensor = torch.cuda.FloatTensor BoolTensor = torch.cuda.BoolTensor else: LongTensor = torch.LongTensor FloatTensor = torch.FloatTensor BoolTens...
827
25.709677
59
py
sampling_cf
sampling_cf-main/grid_search.py
import os import gc import copy import time import json import datetime import traceback from tqdm import tqdm import multiprocessing from main import main from utils import get_common_path from data_path_constants import get_index_path, get_log_file_path # NOTE: Specify all possible combinations of hyper-parameters ...
5,100
30.68323
129
py
sampling_cf
sampling_cf-main/eval.py
import torch import numpy as np from numba import jit, float32, float64, int64 from utils import INF def evaluate(model, criterion, reader, hyper_params, item_propensity, topk = [ 10, 100 ], test = False): metrics = {} # Do a negative sampled item-space evaluation (only on the validation set) # if the da...
7,384
38.704301
137
py
sampling_cf
sampling_cf-main/load_data.py
import h5py import numpy as np from utils import get_data_loader_class from data_path_constants import get_data_path, get_index_path def load_data(hyper_params, track_events = False): rating_data_path = get_data_path(hyper_params) index_path = get_index_path(hyper_params) data_holder = DataHolder(rating_...
3,038
36.060976
96
py
sampling_cf
sampling_cf-main/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/svp_handler.py
import numpy as np from collections import defaultdict from main import main_pytorch from data_path_constants import get_svp_log_file_path, get_svp_model_file_path class SVPHandler: def __init__(self, model_type, loss_type, hyper_params): hyper_params['model_type'] = model_type hyper_params['task'...
7,281
40.375
110
py
sampling_cf
sampling_cf-main/preprocess.py
from initial_data_prep_code import movielens, amazon, goodreads, beeradvocate from data_path_constants import get_data_path from svp_handler import SVPHandler percent_sample = [ 20, 40, 60, 80, 90, 99 ] # Which datasets to prep? for dataset in [ 'magazine', 'ml-100k', ## Did not download & preprocess the followin...
5,035
41.319328
118
py
sampling_cf
sampling_cf-main/initial_data_prep_code/amazon.py
from data import rating_data from utils import remap_items from data_path_constants import get_data_path def prep(dataset): f = open(get_data_path(dataset) + '/data.csv', "r") users, items, ratings, time = [], [], [], [] user_map, item_map = {}, {} line = f.readline() while line: i, u, r, t = line.strip().spl...
1,124
24
69
py
sampling_cf
sampling_cf-main/initial_data_prep_code/beeradvocate.py
from data import rating_data from utils import remap_items from data_path_constants import get_data_path def prep(dataset): f = open(get_data_path(dataset) + '/data.csv', "r") users, items, ratings, time = [], [], [], [] user_map, item_map = {}, {} line = f.readline() temp = line.strip().split(",") col_map = d...
1,439
25.666667
69
py
sampling_cf
sampling_cf-main/initial_data_prep_code/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/initial_data_prep_code/movielens.py
from data import rating_data from utils import remap_items from data_path_constants import get_data_path def prep(dataset): if dataset == "ml-100k": later_path, delim = "/u.data", "\t" elif dataset == "ml-25m": later_path, delim = "/ratings.csv", "," f = open(get_data_path(dataset) + later_path, "r") users, item...
1,177
26.395349
69
py
sampling_cf
sampling_cf-main/initial_data_prep_code/goodreads.py
import json from tqdm import tqdm from datetime import datetime, timezone from data import rating_data from utils import remap_items from data_path_constants import get_data_path def prep(dataset): num_lines = sum(1 for line in open(get_data_path(dataset) + '/data.json', "r")) f = open(get_data_path(dataset) + '/d...
1,605
24.09375
80
py
sampling_cf
sampling_cf-main/data_genie/data_genie_loss.py
import torch import torch.nn as nn import torch.nn.functional as F class PointwiseLoss(nn.Module): def __init__(self): super(PointwiseLoss, self).__init__() def forward(self, output, y, return_mean = True): loss = torch.pow(output - y, 2) if return_mean: return torch.mean(loss) return loss class PairwiseLoss...
560
27.05
63
py
sampling_cf
sampling_cf-main/data_genie/data_genie_trainers.py
import time import torch import numpy as np from tqdm import tqdm from collections import defaultdict from sklearn.feature_selection import RFE from sklearn.metrics import roc_auc_score from xgboost import XGBClassifier, XGBRegressor from torch.utils.tensorboard import SummaryWriter from sklearn.linear_model import Rid...
8,933
38.883929
144
py
sampling_cf
sampling_cf-main/data_genie/get_embeddings.py
import gc import os import dgl import snap import torch import numpy as np from tqdm import tqdm import networkx as nx from collections import defaultdict from data_genie.data_genie_config import * from data_genie.data_genie_utils import save_numpy, load_numpy from data_genie.data_genie_utils import EMBEDDINGS_PATH_G...
7,131
33.960784
125
py
sampling_cf
sampling_cf-main/data_genie/data_genie_data.py
import torch import numpy as np from torch_utils import LongTensor, FloatTensor, is_cuda_available from data_genie.data_genie_config import * from data_genie.get_data import get_data_pointwise, get_data_pairwise from data_genie.get_embeddings import get_embeddings from data_genie.InfoGraph.infograph_dataset import Syn...
7,077
33.526829
136
py
sampling_cf
sampling_cf-main/data_genie/data_genie_model.py
import dgl import torch import torch.nn as nn from torch_utils import is_cuda_available from data_genie.data_genie_loss import PointwiseLoss, PairwiseLoss # NOTE: Below two are the training classes for data-genie: pointwise/pairwise class PointwiseDataGenie: def __init__(self, hyper_params, writer, xavier_init): s...
3,352
31.240385
92
py
sampling_cf
sampling_cf-main/data_genie/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/data_genie/get_data.py
import os import random from tqdm import tqdm from collections import defaultdict from data_genie.data_genie_config import * from data_genie.data_genie_utils import TRAINING_DATA_PATH, CACHED_KENDALL_TAU_PATH, load_obj, save_obj from data_genie.data_genie_utils import count_performance_retained, get_best_results from...
5,240
32.596154
103
py
sampling_cf
sampling_cf-main/data_genie/data_genie_config.py
import copy TEST_SPLIT = 0.2 # Of total 100% VAL_SPLIT = 0.15 # Of (100 - TEST_SPLIT)% NUM_SAMPLES = 10 # Number of samples per degree features e.g. user/item degree, hop-plot distr. NUM_PURE_FEAUTRES = 7 * NUM_SAMPLES # Graph-based features NUM_FEAUTRES = NUM_PURE_FEAUTRES + 5 # The remaining 5 are generic feat...
2,643
30.47619
124
py
sampling_cf
sampling_cf-main/data_genie/data_genie_utils.py
import os import re import pickle import numpy as np from scipy import stats from utils import get_common_path, INF from data_path_constants import BASE_DATA_GENIE_PATH, get_log_base_path # NOTE: Below is the definition of the directory-structure of data-genie data folder def append(path): # Append all relative path...
4,216
35.669565
143
py
sampling_cf
sampling_cf-main/data_genie/InfoGraph/infograph_dataset.py
from dgl import save_graphs, load_graphs from dgl.data import DGLDataset from tqdm import tqdm import numpy as np import networkx as nx import torch import dgl import os from load_data import DataHolder from data_path_constants import get_data_path, get_index_path from data_genie.data_genie_config import * from data_g...
4,944
30.698718
104
py
sampling_cf
sampling_cf-main/data_genie/InfoGraph/infograph_model.py
''' Credit https://github.com/hengruizhang98/InfoGraph & https://github.com/fanyun-sun/InfoGraph ''' import torch as th import torch.nn as nn import torch.nn.functional as F from torch.nn import Sequential, ModuleList, Linear, ReLU, BatchNorm1d from dgl.nn import GINConv from dgl.nn.pytorch.glob import SumPooling, Av...
4,413
25.590361
110
py
sampling_cf
sampling_cf-main/data_genie/InfoGraph/train_infograph.py
import dgl import time import argparse import torch as th from dgl.dataloading import GraphDataLoader from tqdm import tqdm from data_genie.data_genie_utils import INFOGRAPH_MODEL_PATH from data_genie.InfoGraph.infograph_model import InfoGraph from data_genie.InfoGraph.infograph_dataset import SyntheticDataset def ar...
3,615
33.438095
121
py
sampling_cf
sampling_cf-main/data_genie/InfoGraph/infograph_utils.py
''' Credit: https://github.com/fanyun-sun/InfoGraph ''' import torch import torch as th import torch.nn.functional as F import math def local_global_loss_(l_enc, g_enc, graph_id, measure): num_graphs = g_enc.shape[0] num_nodes = l_enc.shape[0] device = g_enc.device pos_mask = th.zeros((num_nodes, n...
3,376
26.680328
82
py
sampling_cf
sampling_cf-main/data_genie/InfoGraph/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/pytorch_models/SASRec.py
import torch import numpy as np import torch.nn as nn from torch_utils import LongTensor, BoolTensor, is_cuda_available class PointWiseFeedForward(nn.Module): def __init__(self, hidden_units, dropout_rate): super(PointWiseFeedForward, self).__init__() self.conv1 = nn.Conv1d(hidden_units, hidden_u...
5,147
40.853659
122
py
sampling_cf
sampling_cf-main/pytorch_models/NeuMF.py
import torch import torch.nn as nn from pytorch_models.MF import BaseMF class GMF(BaseMF): def __init__(self, hyper_params): super(GMF, self).__init__(hyper_params) self.final = nn.Linear(hyper_params['latent_size'], 1) self.dropout = nn.Dropout(hyper_params['dropout']) def g...
5,009
43.732143
118
py
sampling_cf
sampling_cf-main/pytorch_models/SVAE.py
import torch import numpy as np import torch.nn as nn from torch.autograd import Variable from torch_utils import is_cuda_available class Encoder(nn.Module): def __init__(self, hyper_params): super(Encoder, self).__init__() self.linear1 = nn.Linear( hyper_params['latent_size'], hyper_p...
3,388
38.406977
107
py
sampling_cf
sampling_cf-main/pytorch_models/MVAE.py
import torch import numpy as np import torch.nn as nn from torch.autograd import Variable from torch_utils import is_cuda_available class Encoder(nn.Module): def __init__(self, hyper_params): super(Encoder, self).__init__() self.linear1 = nn.Linear( hyper_params['total_items'], hyper_p...
2,331
32.797101
107
py
sampling_cf
sampling_cf-main/pytorch_models/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/pytorch_models/MF.py
import torch import torch.nn as nn import torch.nn.functional as F from torch_utils import LongTensor, FloatTensor class BaseMF(nn.Module): def __init__(self, hyper_params, keep_gamma = True): super(BaseMF, self).__init__() self.hyper_params = hyper_params # Declaring alpha, beta, gamma ...
4,075
38.960784
108
py
sampling_cf
sampling_cf-main/pytorch_models/pop_rec.py
from torch_utils import FloatTensor class PopRec: def __init__(self, hyper_params, item_count): self.hyper_params = hyper_params self.top_items = FloatTensor([ item_count[i] for i in range(hyper_params['total_items']) ]).unsqueeze(0) def __call__(self, data, eval = False): users, _, _ ...
414
28.642857
112
py
sampling_cf
sampling_cf-main/data_loaders/base.py
import torch import numpy as np from collections import defaultdict from torch.multiprocessing import Process, Queue, Event class CombinedBase: def __init__(self): pass def __len__(self): return (self.num_interactions // self.batch_size) + 1 def __del__(self): try: self.p.terminate() ...
5,688
39.347518
98
py
sampling_cf
sampling_cf-main/data_loaders/SASRec.py
import torch import numpy as np from data_loaders.base import BaseTrainDataset, BaseTestDataset from torch_utils import LongTensor, is_cuda_available class TrainDataset(BaseTrainDataset): def __init__(self, data, hyper_params, track_events): super(TrainDataset, self).__init__(data, hyper_params) s...
3,743
44.108434
110
py
sampling_cf
sampling_cf-main/data_loaders/SVAE.py
import torch import numpy as np from data_loaders.base import BaseTrainDataset, BaseTestDataset from torch_utils import LongTensor, FloatTensor, is_cuda_available class TrainDataset(BaseTrainDataset): def __init__(self, data, hyper_params, track_events): super(TrainDataset, self).__init__(data, hyper_para...
3,329
43.4
104
py
sampling_cf
sampling_cf-main/data_loaders/MVAE.py
import numpy as np from data_loaders.base import BaseTrainDataset, BaseTestDataset from torch_utils import LongTensor, FloatTensor class TrainDataset(BaseTrainDataset): def __init__(self, data, hyper_params, track_events): super(TrainDataset, self).__init__(data, hyper_params) self.shuffle_allowed...
2,616
44.12069
104
py
sampling_cf
sampling_cf-main/data_loaders/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/data_loaders/MF.py
import torch import numpy as np from data_loaders.base import BaseTrainDataset, BaseTestDataset from torch_utils import LongTensor, FloatTensor, is_cuda_available class TrainDataset(BaseTrainDataset): def __init__(self, data, hyper_params, track_events): super(TrainDataset, self).__init__(data, hyper_para...
4,575
43.862745
114
py
sampling_cf
sampling_cf-main/graph_sampling/RW.py
import random class RandomWalkWithRestartSampler: """An implementation of node sampling by random walks with restart. The process is a discrete random walker on nodes which teleports back to the staring node with a fixed probability. This results in a connected subsample from the original input graph....
2,432
34.779412
86
py
sampling_cf
sampling_cf-main/graph_sampling/ForestFire.py
import random import numpy as np from collections import deque class ForestFireSampler: """An implementation of forest fire sampling. The procedure is a stochastic snowball sampling method where the expansion is proportional to the burning probability. `"For details about the algorithm see this paper." <h...
3,031
42.314286
133
py
sampling_cf
sampling_cf-main/graph_sampling/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/data_hyperparams/goodreads_comics.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 20, 'batch_size': 128, 'validate_every': 3, 'early_stop': 2, 'max_seq_len': 30, }
183
19.444444
35
py
sampling_cf
sampling_cf-main/data_hyperparams/luxury.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 80, 'batch_size': 1024, 'validate_every': 5, 'early_stop': 4, 'max_seq_len': 10, }
184
19.555556
35
py
sampling_cf
sampling_cf-main/data_hyperparams/magazine.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 120, 'batch_size': 1024, 'validate_every': 5, 'early_stop': 6, 'max_seq_len': 10, }
167
17.666667
32
py
sampling_cf
sampling_cf-main/data_hyperparams/ml-100k.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 100, 'batch_size': 1024, 'validate_every': 5, 'early_stop': 5, 'max_seq_len': 100, }
186
19.777778
35
py
sampling_cf
sampling_cf-main/data_hyperparams/beeradvocate.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 30, 'batch_size': 256, 'validate_every': 3, 'early_stop': 3, 'max_seq_len': 10, }
183
19.444444
35
py
sampling_cf
sampling_cf-main/data_hyperparams/__init__.py
0
0
0
py
sampling_cf
sampling_cf-main/data_hyperparams/video_games.py
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 25, 'batch_size': 1024, 'validate_every': 3, 'early_stop': 2, 'max_seq_len': 10, }
184
19.555556
35
py
word_forms
word_forms-master/setup.py
from setuptools import setup with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setup(name="word_forms", version="2.1.0", description="Generate all possible forms of an English word.", long_description=long_description, long_description_content_type="text/mar...
868
33.76
71
py
word_forms
word_forms-master/test_word_forms.py
#!/usr/bin/env python # encoding: utf-8 from word_forms.word_forms import get_word_forms import unittest class TestWordForms(unittest.TestCase): """ Simple TestCase for a specific input to output, one instance generated per test case for use in a TestSuite """ def __init__(self, text_input: str, exp...
1,000
24.666667
111
py
word_forms
word_forms-master/test_values.py
# Test values must be in the form [(text_input, expected_output), (text_input, expected_output), ...] test_values = [ ( "president", { "n": { "president", "presidentship", "presidencies", "presidency", "presi...
19,834
23.887077
101
py
word_forms
word_forms-master/word_forms/word_forms.py
import re try: from nltk.corpus import wordnet as wn raise_lookuperror_if_wordnet_data_absent = wn.synset("python.n.01") except LookupError: import nltk nltk.download("wordnet") from nltk.stem import WordNetLemmatizer import inflect from difflib import SequenceMatcher from .constants import CONJUGATED...
4,689
36.822581
130
py
word_forms
word_forms-master/word_forms/constants.py
from collections import defaultdict from pathlib import Path import json class Verb(object): def __init__(self, verbs=None): self.verbs = verbs if verbs else set() def __repr__(self): return "Verbs" + str(self.verbs) def update(self, verbs): self.verbs.update(verbs) verbs_fh = o...
797
25.6
78
py
word_forms
word_forms-master/word_forms/lemmatizer.py
from word_forms.word_forms import get_word_forms def lemmatize(word): """ Out of all the related word forms of ``word``, return the smallest form that appears first in the dictionary """ forms = [word for pos_form in get_word_forms(word).values() for word in pos_form] forms.sort() forms.sort(k...
449
25.470588
112
py
word_forms
word_forms-master/word_forms/__init__.py
0
0
0
py
GUIcandid
GUIcandid-master/candid.py
from __future__ import print_function import numpy as np from matplotlib import pyplot as plt plt.ion() # interactive mode _fitsLoaded=False try: from astropy.io import fits _fitsLoaded=True except: try: import pyfits as fits _fitsLoaded=True except: pass if not _fitsLoaded: ...
203,132
42.769231
210
py
BILP-Q
BILP-Q-main/Utils_CSG.py
#!/usr/bin/env python # coding: utf-8 import math import numpy as np import pandas as pd from sympy import * import re import time import random import itertools ################### ######## #Different distributions data generator functions """ All different distributions considered as benchmark for the evaluation o...
9,710
30.427184
202
py
BILP-Q
BILP-Q-main/data_generator.py
from Utils_CSG import * from Utils_Solvers import * directory = 'data' seed = 12 filename = f'data_{seed}.txt' create_dir(directory, log=False) distributions = [Agent_based_uniform, Agent_based_normal, Modified_uniform_distribution, Normal_distribution, SVA_BETA_distribution, Weibull_distribution,...
1,308
28.75
105
py
BILP-Q
BILP-Q-main/BILP-Q_benchmark.py
from Utils_CSG import * from Utils_Solvers import * def running_dwave(linear, quadratic, exact_solution, colnames, params={'distr':'', 'n':0}, n_runs=1000): """ Solve the experimental input instance using the dwave device :params linear: dictionary of linear coefficient terms in the ...
11,869
45.18677
138
py
BILP-Q
BILP-Q-main/Utils_Solvers.py
#!/usr/bin/env python # coding: utf-8 import warnings warnings.filterwarnings('ignore') # Qiskit from qiskit import BasicAer from qiskit.algorithms import QAOA, NumPyMinimumEigensolver from qiskit_optimization.algorithms import MinimumEigenOptimizer, RecursiveMinimumEigenOptimizer from qiskit_optimization import Qua...
15,289
29.702811
201
py
neuralTPPs
neuralTPPs-master/setup.py
from setuptools import setup, find_packages with open('README.md') as f: readme = f.read() setup( name='tpp', version='0.0.1', description='Playing around with TPPs.', long_description=readme, author='Babylon ML team', author_email='loss.goes.down@babylonhealth.com', url='https://gith...
467
23.631579
55
py
neuralTPPs
neuralTPPs-master/debug/cumulative_attention.py
import torch as th import matplotlib.pyplot as plt from torch import nn from pprint import pprint from tqdm import tqdm from tpp.models.base.enc_dec import EncDecProcess from tpp.models.encoders.mlp_variable import MLPVariableEncoder from tpp.models.decoders.self_attention_cm import SelfAttentionCmDecoder from tpp.mo...
2,491
30.544304
75
py
neuralTPPs
neuralTPPs-master/debug/batchnorm.py
import torch as th from torch import nn from tpp.pytorch.layers import NonNegLinear from tpp.pytorch.layers import BatchNorm1d def multidim_grad(a, b): a_split = th.split(a, split_size_or_sections=1, dim=-1) grads = [th.autograd.grad( outputs=a_split[i], inputs=b, grad_outputs=th.ones...
1,043
22.2
59
py
neuralTPPs
neuralTPPs-master/debug/layernorm.py
import torch as th from torch import nn from tpp.pytorch.layers import LayerNorm from debug.batchnorm import multidim_grad th.manual_seed(0) pytorch_norm = nn.LayerNorm(3) my_norm = LayerNorm(3, use_running_stats=True) x = th.rand([3]).reshape(1, -1).float().repeat(2, 1) x.requires_grad = True pytorch_y = pytorch_...
831
19.8
55
py
neuralTPPs
neuralTPPs-master/debug/regression.py
import numpy as np import torch as th import torch.nn import matplotlib.pyplot as plt from tpp.pytorch.models import MLP def detach(x: th.Tensor) -> np.ndarray: return x.detach().cpu().numpy() th.manual_seed(0) x_min, x_max, steps = 0., 100., 3000 alpha = 1. beta = 1. n_events = 20 epochs = 1000 cumulative =...
2,239
23.086022
68
py
neuralTPPs
neuralTPPs-master/debug/check_synthea_csvs.py
import os import datetime as dt import numpy as np import pandas as pd from argparse import ArgumentParser from tqdm import tqdm pd.set_option("max.rows", 10) pd.set_option("max.columns", 50) pd.set_option("display.width", 1000) CSV_SUBSET = {"patients", "encounters"} def main(args): dfs = get_dfs(synthea_pat...
2,965
30.892473
79
py
neuralTPPs
neuralTPPs-master/profiling/r_terms_for_pytorch_profile.py
import torch as th from tpp.processes.hawkes.r_terms_recursive_v import get_r_terms from tpp.utils.test import get_test_events_query def run_test(): marks = 3 events, query = get_test_events_query(marks=marks) beta = th.rand([marks, marks]) get_r_terms(events=events, beta=beta) if __name__ == '__m...
343
19.235294
64
py
neuralTPPs
neuralTPPs-master/profiling/get_r_terms_profile.py
import time import matplotlib.pyplot as plt import numpy as np import torch as th # from tpp.processes.hawkes.r_terms import get_r_terms as naive from tpp.processes.hawkes.r_terms_recursive import get_r_terms as recursive from tpp.processes.hawkes.r_terms_recursive_v import get_r_terms as recursive_v from tpp.utils.te...
2,568
28.872093
79
py