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
pylops
pylops-master/pylops/signalprocessing/fredholm1.py
__all__ = ["Fredholm1"] import numpy as np from pylops import LinearOperator from pylops.utils.backend import get_array_module from pylops.utils.decorators import reshaped from pylops.utils.typing import DTypeLike, NDArray class Fredholm1(LinearOperator): r"""Fredholm integral of first kind. Implement a mu...
5,263
34.093333
86
py
pylops
pylops-master/pylops/signalprocessing/sliding3d.py
__all__ = [ "sliding3d_design", "Sliding3D", ] import logging from typing import Tuple from pylops import LinearOperator from pylops.basicoperators import BlockDiag, Diagonal, HStack, Restriction from pylops.signalprocessing.sliding2d import _slidingsteps from pylops.utils.tapers import taper3d from pylops.ut...
7,683
32.701754
113
py
pylops
pylops-master/pylops/signalprocessing/_radon2d_numba.py
import os import numpy as np from numba import jit # detect whether to use parallel or not numba_threads = int(os.getenv("NUMBA_NUM_THREADS", "1")) parallel = True if numba_threads != 1 else False @jit(nopython=True) def _linear_numba(x, t, px): return t + px * x @jit(nopython=True) def _parabolic_numba(x, t,...
2,416
28.839506
86
py
pylops
pylops-master/pylops/signalprocessing/convolvend.py
__all__ = ["ConvolveND"] from typing import Optional, Union import numpy as np from numpy.core.multiarray import normalize_axis_index from pylops import LinearOperator from pylops.utils._internal import _value_or_sized_to_tuple from pylops.utils.backend import ( get_array_module, get_convolve, get_correl...
4,683
33.189781
84
py
pylops
pylops-master/pylops/signalprocessing/__init__.py
""" Signal processing ================= The subpackage signalprocessing provides linear operators for several signal processing algorithms with forward and adjoint functionalities. A list of operators present in pylops.signalprocessing: Convolve1D 1D convolution operator. Convolve2D ...
3,069
32.010753
80
py
pylops
pylops-master/pylops/signalprocessing/_chirpradon3d.py
import numpy as np from pylops.utils.backend import get_array_module from pylops.utils.typing import NDArray try: import pyfftw except ImportError: pyfftw = None def _chirp_radon_3d( data: NDArray, dt: float, dy: float, dx: float, pmax: NDArray, mode: str = "f" ) -> NDArray: r"""3D Chirp Radon trans...
7,719
32.419913
88
py
pylops
pylops-master/pylops/signalprocessing/chirpradon3d.py
__all__ = ["ChirpRadon3D"] import logging import numpy as np from pylops import LinearOperator from pylops.utils import deps from pylops.utils.decorators import reshaped from pylops.utils.typing import DTypeLike, NDArray from ._chirpradon3d import _chirp_radon_3d pyfftw_message = deps.pyfftw_import("the chirpradon...
4,439
33.96063
119
py
pylops
pylops-master/pylops/signalprocessing/convolve2d.py
__all__ = ["Convolve2D"] from typing import Union from pylops.signalprocessing import ConvolveND from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray class Convolve2D(ConvolveND): r"""2D convolution operator. Apply two-dimensional convolution with a compact filter to model (and data) along...
2,753
30.655172
105
py
pylops
pylops-master/pylops/signalprocessing/radon3d.py
__all__ = ["Radon3D"] import logging from typing import Callable, Optional, Tuple import numpy as np from pylops.basicoperators import Spread from pylops.utils import deps from pylops.utils.typing import DTypeLike, NDArray jit_message = deps.numba_import("the radon3d module") if jit_message is None: from numba...
11,959
29.35533
94
py
pylops
pylops-master/pylops/signalprocessing/fftnd.py
__all__ = ["FFTND"] import logging import warnings from typing import Optional, Sequence, Union import numpy as np import numpy.typing as npt from pylops.signalprocessing._baseffts import _BaseFFTND, _FFTNorms from pylops.utils.backend import get_sp_fft from pylops.utils.decorators import reshaped from pylops.utils....
17,149
40.225962
130
py
pylops
pylops-master/pylops/signalprocessing/dct.py
__all__ = ["DCT"] from typing import List, Optional, Union import numpy as np from scipy import fft from pylops import LinearOperator from pylops.utils._internal import _value_or_sized_to_tuple from pylops.utils.decorators import reshaped from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray class DCT(...
3,296
32.989691
116
py
pylops
pylops-master/pylops/signalprocessing/sliding2d.py
__all__ = [ "sliding2d_design", "Sliding2D", ] import logging from typing import Tuple import numpy as np from pylops import LinearOperator from pylops.basicoperators import BlockDiag, Diagonal, HStack, Restriction from pylops.utils.tapers import taper2d from pylops.utils.typing import InputDimsLike, NDArray...
6,953
30.466063
113
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/sotabench.py
import os import numpy as np import PIL import torch from torch.utils.data import DataLoader import torchvision.transforms as transforms from torchvision.datasets import ImageNet from efficientnet_pytorch import EfficientNet from sotabencheval.image_classification import ImageNetEvaluator from sotabencheval.utils imp...
2,094
28.097222
131
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Note: To use the 'upload' functionality of this file, you must: # $ pipenv install twine --dev import io import os import sys from shutil import rmtree from setuptools import find_packages, setup, Command # Package meta-data. NAME = 'efficientnet_pytorch' DESCRIPTIO...
3,543
27.580645
96
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/hubconf.py
from efficientnet_pytorch import EfficientNet as _EfficientNet dependencies = ['torch'] def _create_model_fn(model_name): def _model_fn(num_classes=1000, in_channels=3, pretrained='imagenet'): """Create Efficient Net. Described in detail here: https://arxiv.org/abs/1905.11946 Args: ...
1,709
37.863636
78
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/efficientnet_pytorch/utils.py
"""utils.py - Helper functions for building the model and for loading model parameters. These helper functions are built to mirror those in the official TensorFlow implementation. """ # Author: lukemelas (github username) # Github repo: https://github.com/lukemelas/EfficientNet-PyTorch # With adjustments and added ...
24,957
39.450567
130
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/efficientnet_pytorch/model.py
"""model.py - Model and module class for EfficientNet. They are built to mirror those in the official TensorFlow implementation. """ # Author: lukemelas (github username) # Github repo: https://github.com/lukemelas/EfficientNet-PyTorch # With adjustments and added comments by workingcoder (github username). import...
17,388
40.402381
107
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/efficientnet_pytorch/__init__.py
__version__ = "0.7.1" from .model import EfficientNet, VALID_MODELS from .utils import ( GlobalParams, BlockArgs, BlockDecoder, efficientnet, get_model_params, )
182
17.3
45
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/examples/imagenet/main.py
""" Evaluate on ImageNet. Note that at the moment, training is not implemented (I am working on it). that being said, evaluation is working. """ import argparse import os import random import shutil import time import warnings import PIL import torch import torch.nn as nn import torch.nn.parallel import torch.backend...
17,107
37.531532
96
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tests/test_model.py
from collections import OrderedDict import pytest import torch import torch.nn as nn from efficientnet_pytorch import EfficientNet # -- fixtures ------------------------------------------------------------------------------------- @pytest.fixture(scope='module', params=[x for x in range(4)]) def model(request): ...
4,122
31.984
99
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/load_tf_weights_tf1.py
import numpy as np import tensorflow as tf import torch def load_param(checkpoint_file, conversion_table, model_name): """ Load parameters according to conversion_table. Args: checkpoint_file (string): pretrained checkpoint model file in tensorflow conversion_table (dict): { pytorch tensor...
10,344
58.797688
126
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/load_tf_weights.py
import numpy as np import tensorflow as tf import torch tf.compat.v1.disable_v2_behavior() def load_param(checkpoint_file, conversion_table, model_name): """ Load parameters according to conversion_table. Args: checkpoint_file (string): pretrained checkpoint model file in tensorflow conve...
10,410
58.491429
126
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/eval_ckpt_main.py
# Copyright 2019 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...
8,644
37.252212
94
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/efficientnet_builder.py
# Copyright 2019 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...
11,804
34.772727
80
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/efficientnet_model.py
# Copyright 2019 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...
26,027
35.453782
80
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/preprocessing.py
# Copyright 2019 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...
9,508
38.293388
80
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/utils.py
# Copyright 2019 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...
15,742
37.775862
91
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/eval_ckpt_main_tf1.py
# Copyright 2019 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...
8,524
37.400901
80
py
EfficientNet-PyTorch
EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/__init__.py
0
0
0
py
neuron-importance-zsl
neuron-importance-zsl-master/mod2alpha.py
# Code to map from any modality to alphas. # Train using class_info and alphas from a trained network import argparse import numpy as np import random random.seed(1234) from random import shuffle import pickle from pprint import pprint from dotmap import DotMap import pdb import csv import os import json import tensorf...
18,735
41.103371
377
py
neuron-importance-zsl
neuron-importance-zsl-master/alpha2w.py
# Finetune a network in tensorflow on the CUB dataset import argparse import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import ntpath import json import pdb import random import torchfile import importlib from scipy.stats import spearmanr import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as p...
49,803
47.589268
419
py
neuron-importance-zsl
neuron-importance-zsl-master/seen_pretraining/alpha_extraction.py
""" Code to extract and save alphas from a trained network 1. Note that we're gonna have to coincide the use of previous and new finetuning dataset JSONs 2. Take bypassing into account 3. Data loader can be the same as the CNN finetuning scheme """ import os import sys import json import codecs import random import imp...
15,568
46.036254
239
py
neuron-importance-zsl
neuron-importance-zsl-master/seen_pretraining/cnn_finetune.py
""" Code to finetune a given CNN on the seen-images for the seen-classes concerned datasets (Have to add special checks to handle images with multiple frames) """ import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import pdb import json import random import importlib import itertools # Add slim folder path ...
40,175
54.877608
173
py
RecommenderSystems
RecommenderSystems-master/featureRec/movielens/code/model.py
''' Tensorflow implementation of AutoInt described in: AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks. author: Chence Shi email: chenceshi@pku.edu.cn ''' import os import numpy as np import tensorflow as tf from time import time from sklearn.base import BaseEstimator, TransformerMix...
22,320
45.502083
190
py
RecommenderSystems
RecommenderSystems-master/featureRec/movielens/code/__init__.py
0
0
0
py
RecommenderSystems
RecommenderSystems-master/featureRec/movielens/code/train.py
import math import numpy as np import pandas as pd import tensorflow as tf from sklearn.metrics import make_scorer from sklearn.model_selection import StratifiedKFold from time import time from .model import AutoInt import argparse import os def str2list(v): v=v.split(',') v=[int(_.strip('[]')) for _ in v] ...
5,236
37.792593
107
py
RecommenderSystems
RecommenderSystems-master/featureRec/movielens/data/preprocess.py
dict = {} user_count = 6040 gender = {} gender['M'] = 1 gender['F'] = 2 dict[1] = "Gender-male" dict[2] = "Gender-female" age = {} age['1'] = 3 age['18'] = 4 age['25'] = 5 age['35'] = 6 age['45'] = 7 age['50'] = 8 age['56'] = 9 dict[3] = "Age-under 18" dict[4] = "Age-18-24" dict[5] = "Age-25-34" dict[6] = "Age-35-...
7,665
20.840456
67
py
RecommenderSystems
RecommenderSystems-master/featureRec/autoint/model.py
''' Tensorflow implementation of AutoInt described in: AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks. author: Chence Shi email: chenceshi@pku.edu.cn ''' import os import numpy as np import tensorflow as tf from time import time from sklearn.base import BaseEstimator, TransformerMix...
20,281
43.772627
205
py
RecommenderSystems
RecommenderSystems-master/featureRec/autoint/train.py
import math import numpy as np import pandas as pd import tensorflow as tf from sklearn.metrics import make_scorer from sklearn.model_selection import StratifiedKFold from time import time from .model import AutoInt import argparse import os def str2list(v): v=v.split(',') v=[int(_.strip('[]')) for _ in v] ...
5,264
37.713235
107
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Kfold_split/config.py
DATA_PATH = './Criteo/' TRAIN_I = DATA_PATH + 'train_i.txt' TRAIN_X = DATA_PATH + 'train_x.txt' TRAIN_Y = DATA_PATH + 'train_y.txt' NUM_SPLITS = 10 RANDOM_SEED = 2018
169
17.888889
35
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Kfold_split/stratifiedKfold.py
#Email of the author: zjduan@pku.edu.cn import numpy as np import config import os import pandas as pd from sklearn.model_selection import StratifiedKFold from sklearn import preprocessing scale = "" train_x_name = "train_x.npy" train_y_name = "train_y.npy" Column = 13 def _load_data(_nrows=None, debug = False): ...
2,976
28.186275
90
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/KDD2012/scale.py
import math import config import numpy as np def scale(x): if x > 2: x = int(math.log(float(x))**2) return x def scale_each_fold(): for i in range(1,11): print('now part %d' % i) data = np.load(config.DATA_PATH + 'part'+str(i)+'/train_x.npy') part = data[:,0:13] fo...
582
23.291667
78
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/KDD2012/preprocess.py
#coding=utf-8 #Email of the author: zjduan@pku.edu.cn ''' 0. Click: 1. Impression(numerical) 2. DisplayURL: (categorical) 3. AdID:(categorical) 4. AdvertiserID:(categorical) 5. Depth:(numerical) 6. Position:(numerical) 7. QueryID: (categorical) the key of the data file 'queryid_tokensid.txt'. 8. KeywordID: (categori...
4,042
29.398496
86
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Criteo/scale.py
import math import config import numpy as np def scale(x): if x > 2: x = int(math.log(float(x))**2) return x def scale_each_fold(): for i in range(1,11): print('now part %d' % i) data = np.load(config.DATA_PATH + 'part'+str(i)+'/train_x.npy') part = data[:,0:13] fo...
582
23.291667
78
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Criteo/config.py
DATA_PATH = './Criteo/' SOURCE_DATA = './train_examples.txt'
60
29.5
36
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Criteo/preprocess.py
import config train_path = config.SOURCE_DATA f1 = open(train_path,'r') dic= {} # generate three fold. # train_x: value # train_i: index # train_y: label f_train_value = open(config.DATA_PATH + 'train_x.txt','w') f_train_index = open(config.DATA_PATH + 'train_i.txt','w') f_train_label = open(config.DATA_PATH + 'train_...
2,286
24.696629
97
py
RecommenderSystems
RecommenderSystems-master/featureRec/data/Dataprocess/Avazu/preprocess.py
#coding=utf-8 #Email of the author: zjduan@pku.edu.cn ''' 0.id: ad identifier 1.click: 0/1 for non-click/click 2.hour: format is YYMMDDHH, so 14091123 means 23:00 on Sept. 11, 2014 UTC. 3.C1 -- anonymized categorical variable 4.banner_pos 5.site_id 6.site_domain 7.site_category 8.app_id 9.app_domain 10.app_category 11....
2,863
22.669421
92
py
RecommenderSystems
RecommenderSystems-master/socialRec/data/preprocess_DoubanMovie.py
import pandas as pd import numpy as np import math import argparse import random from collections import Counter ''' The original DoubanMovie data can be found at: https://www.dropbox.com/s/tmwuitsffn40vrz/Douban.tar.gz?dl=0 ''' PATH_TO_DATA = './Douban/' SOCIAL_NETWORK_FILE = PATH_TO_DATA + 'socialnet/socialnet.ts...
7,559
46.54717
206
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/inits.py
import tensorflow as tf import numpy as np # DISCLAIMER: # This file is derived from # https://github.com/tkipf/gcn # which is also under the MIT license def uniform(shape, scale=0.05, name=None): """Uniform init.""" initial = tf.random_uniform(shape, minval=-scale, maxval=scale, dtype=tf.float32) return...
903
28.16129
95
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/aggregators.py
import tensorflow as tf from .layers import Layer, Dense from .inits import glorot, zeros # Mean, MaxPool, GCN aggregators are collected from # https://github.com/williamleif/GraphSAGE # which is also under the MIT license class MeanAggregator(Layer): """ Aggregates via mean followed by matmul and non-linea...
11,210
32.168639
92
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/test.py
#coding=utf-8 from __future__ import division from __future__ import print_function import os, sys import argparse import tensorflow as tf import numpy as np import time from .utils import * from .minibatch import MinibatchIterator from .model import DGRec seed = 123 np.random.seed(seed) tf.set_random_seed(seed) ...
8,420
39.485577
183
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/utils.py
#coding=utf-8 from __future__ import print_function import numpy as np import pandas as pd import random def load_adj(data_path): df_adj = pd.read_csv(data_path + '/adj.tsv', sep='\t', dtype={0:np.int32, 1:np.int32}) return df_adj def load_latest_session(data_path): ret = [] for line in open(data...
1,519
31.340426
105
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/model.py
import tensorflow as tf import numpy as np from .aggregators import * from .layers import Dense class DGRec(object): def __init__(self, args, support_sizes, placeholders): self.support_sizes = support_sizes if args.aggregator_type == "mean": self.aggregator_cls = MeanAggregator ...
14,311
50.855072
155
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/minibatch.py
#coding=utf-8 from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import sys from .neigh_samplers import UniformNeighborSampler from .utils import * np.random.seed(123) class MinibatchIterator(object): def __init__(self, adj_info, # i...
13,192
41.15016
120
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/layers.py
from __future__ import division from __future__ import print_function import tensorflow as tf from .inits import zeros # DISCLAIMER: # This file is forked from # https://github.com/tkipf/gcn # which is also under the MIT license # global unique layer ID dictionary for layer name assignment _LAYER_UIDS = {} def g...
3,731
31.172414
105
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/neigh_samplers.py
from __future__ import division from __future__ import print_function import numpy as np """ Classes that are used to sample node neighborhoods """ class UniformNeighborSampler(object): """ Uniformly samples neighbors. Assumes that adj lists are padded with random re-sampling """ def __init__(sel...
1,740
37.688889
88
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/__init__.py
from __future__ import print_function from __future__ import division
70
22.666667
37
py
RecommenderSystems
RecommenderSystems-master/socialRec/dgrec/train.py
#coding=utf-8 from __future__ import division from __future__ import print_function import os, sys import argparse import tensorflow as tf import numpy as np import time from .utils import * from .minibatch import MinibatchIterator from .model import DGRec seed = 123 np.random.seed(seed) tf.set_random_seed(seed) de...
10,966
40.541667
141
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/markovChains/sampler.py
#coding=utf-8 ''' Author: Weiping Song Contact: songweiping@pku.edu.cn Reference: https://github.com/kang205/SASRec/blob/master/sampler.py ''' # Disclaimer: # Part of this file is derived from # https://github.com/kang205/SASRec/ import numpy as np from multiprocessing import Process, Queue def random_neg(pos, n, s...
3,798
34.504673
127
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/markovChains/utils.py
#coding=utf-8 ''' Author: Weiping Song Contact: Weiping Song ''' import pandas as pd import numpy as np import random import os import json import datetime as dt from collections import Counter # path of folder that contains all the datas. data_path = 'data/' class Dictionary(object): def __init__(self): ...
10,819
41.101167
130
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/markovChains/model.py
#coding=utf-8 ''' Author: Chence Shi Contact: chenceshi@pku.edu.cn ''' import tensorflow as tf import sys import os import numpy as np def log2(x): numerator = tf.log(x) denominator = tf.log(tf.constant(2, dtype=numerator.dtype)) return numerator / denominator class FOSSIL(object): def __init__(...
11,107
49.262443
151
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/markovChains/__init__.py
0
0
0
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/markovChains/train.py
#coding: utf-8 ''' Author: Chence Shi Contact: chenceshi@pku.edu.cn ''' import tensorflow as tf import argparse import numpy as np import sys import time import math from .utils import * from .model import * from .sampler import * parser = argparse.ArgumentParser(description='Sequential or session-based recommendati...
6,793
38.5
116
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/base.py
# coding: utf-8 ''' Author: Weiping Song, Chence Shi, Zheye Deng Contact: songweiping@pku.edu.cn, chenceshi@pku.edu.cn, dzy97@pku.edu.cn ''' import tensorflow as tf import numpy as np from tensorflow.contrib import rnn class LSTMNet(object): def __init__(self, layers=1, hidden_units=100, hidden_activation="tanh", ...
15,214
43.75
182
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/test.py
#coding: utf-8 ''' Author: Weiping Song Contact: songweiping@pku.edu.cn ''' import tensorflow as tf import argparse import numpy as np import sys import time import math from .utils import * from .model import * from .eval import Evaluation parser = argparse.ArgumentParser(description='Sequential or session-based re...
5,225
41.836066
127
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/sampler.py
#coding=utf-8 ''' Author: Weiping Song Contact: songweiping@pku.edu.cn Reference: https://github.com/kang205/SASRec/blob/master/sampler.py ''' # Disclaimer: # Part of this file is derived from # https://github.com/kang205/SASRec/ import numpy as np from multiprocessing import Process, Queue def random_neg(pos, n, s...
3,473
34.814433
121
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/utils.py
#coding=utf-8 ''' Author: Weiping Song Contact: Weiping Song ''' import pandas as pd import numpy as np import random import os import json import datetime as dt from collections import Counter data_path = 'data/' class Dictionary(object): def __init__(self): self.item2idx = {} self.idx2item = []...
9,599
40.921397
145
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/model.py
#coding=utf-8 ''' Author: Weiping Song Contact: songweiping@pku.edu.cn ''' import tensorflow as tf import sys from .base import LSTMNet from .base import TemporalConvNet from .base import TransformerNet def log2(x): numerator = tf.log(x) denominator = tf.log(tf.constant(2, dtype=numerator.dtype)) return n...
6,096
45.9
171
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/eval.py
import numpy as np class Evaluation: ''' In progress... Eventually, we aim to include popular evaluation metrics as many as possible. ''' def __init__(self, ks = [1, 5, 10, 20], ndcg_cutoff = 20): self.k = ks self.ndcg_cutoff = ndcg_cutoff self.clear() def clear(self):...
2,624
32.653846
89
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/__init__.py
0
0
0
py
RecommenderSystems
RecommenderSystems-master/sequentialRec/neural/train.py
#coding: utf-8 ''' Author: Weiping Song Contact: songweiping@pku.edu.cn ''' import tensorflow as tf import argparse import numpy as np import sys import time import math from .utils import * from .model import * from .sampler import * parser = argparse.ArgumentParser(description='Sequential or session-based recommen...
6,636
41.006329
127
py
BeyondtheSpectrum
BeyondtheSpectrum-main/test.py
import argparse import os import random import shutil import time import warnings import sys import cv2 import numpy as np import scipy.misc import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing...
13,359
39.731707
124
py
BeyondtheSpectrum
BeyondtheSpectrum-main/train_sr.py
import argparse import os import copy import torch from torch import nn import torch.optim as optim import torch.backends.cudnn as cudnn from torch.utils.data.dataloader import DataLoader from tqdm import tqdm from sr_models.model import RDN, VGGLoss from sr_models.datasets import TrainDataset, EvalDataset from sr_mo...
4,950
41.316239
173
py
BeyondtheSpectrum
BeyondtheSpectrum-main/train.py
import argparse import os import random import shutil import time import warnings import sys import cv2 import numpy as np import scipy.misc import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing...
17,834
40.866197
195
py
BeyondtheSpectrum
BeyondtheSpectrum-main/models/customize.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Hang Zhang ## ECE Department, Rutgers University ## Email: zhang.hang@rutgers.edu ## Copyright (c) 2017 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this sou...
10,973
36.71134
99
py
BeyondtheSpectrum
BeyondtheSpectrum-main/models/resnet.py
"""Dilated ResNet""" import math import torch import torch.utils.model_zoo as model_zoo import torch.nn as nn from .customize import GlobalAvgPool2d __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'BasicBlock', 'Bottleneck', 'get_resnet'] model_urls = { 'resnet18': '...
11,165
35.135922
162
py
BeyondtheSpectrum
BeyondtheSpectrum-main/models/resnet_cifar.py
"""Dilated ResNet""" import torch.nn as nn from .customize import FrozenBatchNorm2d model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', } def conv_1_3x3(input_channel): return nn.Sequential(nn.Co...
11,254
37.412969
140
py
BeyondtheSpectrum
BeyondtheSpectrum-main/models/__init__.py
from .resnet import get_resnet from .resnet_cifar import get_cifar_resnet def get_classification_model(arch, pretrained, **kwargs): return get_resnet(arch, pretrained, **kwargs) def get_cifar_classification_model(arch, pretrained, **kwargs): return get_cifar_resnet(arch, pretrained, **kwargs)
304
32.888889
63
py
BeyondtheSpectrum
BeyondtheSpectrum-main/sr_models/utils.py
import torch import numpy as np def convert_rgb_to_y(img, dim_order='hwc'): if dim_order == 'hwc': return 16. + (64.738 * img[..., 0] + 129.057 * img[..., 1] + 25.064 * img[..., 2]) / 256. else: return 16. + (64.738 * img[0] + 129.057 * img[1] + 25.064 * img[2]) / 256. def denormalize(img): ...
1,061
22.086957
97
py
BeyondtheSpectrum
BeyondtheSpectrum-main/sr_models/model.py
import torch from torch import nn class DenseLayer(nn.Module): def __init__(self, in_channels, out_channels): super(DenseLayer, self).__init__() self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=3 // 2) self.relu = nn.ReLU(inplace=True) def forward(self, x): ...
4,943
36.172932
122
py
BeyondtheSpectrum
BeyondtheSpectrum-main/sr_models/datasets.py
import random import h5py import numpy as np from PIL import Image from torch.utils.data import Dataset from scipy.ndimage import gaussian_filter from scipy.ndimage.filters import convolve from io import BytesIO import copy class TrainDataset(Dataset): def __init__(self, file_path, patch_size, scale, aug=False, c...
10,057
32.415282
102
py
BeyondtheSpectrum
BeyondtheSpectrum-main/datasets/base.py
########################################################################### # Created by: Hang Zhang # Email: zhang.hang@rutgers.edu # Copyright (c) 2017 ########################################################################### import random import numpy as np from PIL import Image, ImageOps, ImageFilter import to...
835
22.222222
75
py
BeyondtheSpectrum
BeyondtheSpectrum-main/datasets/image_dataset.py
########################################################################### # Created by: Hang Zhang # Email: zhang.hang@rutgers.edu # Copyright (c) 2018 ########################################################################### import os import sys import random import numpy as np from tqdm import tqdm, trange from ...
2,300
31.871429
144
py
BeyondtheSpectrum
BeyondtheSpectrum-main/datasets/__init__.py
import warnings from torchvision.datasets import * from .base import * from .image_dataset import BinaryImageDataset datasets = { 'image': BinaryImageDataset, } def get_dataset(name, **kwargs): return datasets[name.lower()](**kwargs)
246
16.642857
45
py
ps-lite
ps-lite-master/tracker/dmlc_local.py
#!/usr/bin/env python """ DMLC submission script, local machine version """ import argparse import sys import os import subprocess from threading import Thread import tracker import signal import logging keepalive = """ nrep=0 rc=254 while [ $rc -eq 254 ]; do export DMLC_NUM_ATTEMPT=$nrep %s rc=$?; nr...
3,051
29.217822
88
py
ps-lite
ps-lite-master/tracker/tracker.py
""" Tracker script for DMLC Implements the tracker control protocol - start dmlc jobs - start ps scheduler and rabit tracker - help nodes to establish links with each other Tianqi Chen """ import sys import os import socket import struct import subprocess import time import logging import random from threading imp...
14,308
31.970046
113
py
ps-lite
ps-lite-master/tracker/dmlc_ssh.py
#!/usr/bin/env python """ DMLC submission script by ssh One need to make sure all slaves machines are ssh-able. """ import argparse import sys import os import subprocess import tracker import logging from threading import Thread class SSHLauncher(object): def __init__(self, args, unknown): self.args = a...
3,896
33.184211
92
py
ps-lite
ps-lite-master/tracker/dmlc_mpi.py
#!/usr/bin/env python """ DMLC submission script, MPI version """ import argparse import sys import os import subprocess import tracker from threading import Thread parser = argparse.ArgumentParser(description='DMLC script to submit dmlc job using MPI') parser.add_argument('-n', '--nworker', required=True, type=int, ...
3,173
33.5
92
py
ps-lite
ps-lite-master/tests/lint.py
#!/usr/bin/env python # pylint: disable=protected-access, unused-variable, locally-disabled, redefined-variable-type """Lint helper to generate lint summary of source. Copyright by Contributors """ import codecs import sys import re import os import cpplint from cpplint import _cpplint_state from pylint import epylint...
6,474
36.212644
98
py
ps-lite
ps-lite-master/docs/sphinx_util.py
import sys, os, subprocess if not os.path.exists('../recommonmark'): subprocess.call('cd ..; git clone https://github.com/tqchen/recommonmark', shell = True) else: subprocess.call('cd ../recommonmark; git pull', shell=True) sys.path.insert(0, os.path.abspath('../recommonmark/')) from recommonmark import par...
571
27.6
92
py
ps-lite
ps-lite-master/docs/conf.py
# -*- coding: utf-8 -*- # # ps-lite documentation build configuration file, created by # sphinx-quickstart on Sun Mar 20 20:12:23 2016. # # Mu: additional changes # - add breathe into extensions # - change html theme into sphinx_rtd_theme # - add sphnix_util.py # - add .md into source_suffix # - add setup() a...
10,101
30.968354
80
py
SLIT
SLIT-master/setup.py
from setuptools import setup setup(name='SLIT', version='0.1', description='Code for colour lens/source separation and lensed source reconstruction', author='Remy Joseph, Frederic Courbin, Jean-Luc Starck', author_email='remy.joseph@epfl.ch', packages=['SLIT'], zip_safe=False)
315
30.6
92
py
SLIT
SLIT-master/Tests/Result_slope.py
import numpy as np import matplotlib.pyplot as plt import SLIT import pyfits as pf import matplotlib.cm as cm import os import glob nsim = 11 ranges = np.array([1.9,1.95,2.0,2.025,2.05])#np.linspace(0,1,11) Truth = pf.open('IMG2.fits')[0].data sigma = 0.00119 Sources = 0 FSs = 0 #thetas = np.zeros((nsim, ranges.siz...
3,313
30.865385
156
py
SLIT
SLIT-master/Tests/Launch_Test.py
import Test_center as tc import sys import numpy as np variable = sys.argv[1] shift = sys.argv[2] if variable == 'center': tc.test_center(np.float(shift)) if variable == 'slope': tc.test_slope(np.float(shift))
224
13.0625
35
py
SLIT
SLIT-master/Tests/gaussian.py
import numpy as np import scipy.misc as spm import matplotlib.pyplot as plt import matplotlib.cm as cm def gaussian(n1,n2,x0,y0,A,e1,e2,alpha): #img = gaussian(n1,n2,x0,y0,A,e1,e2,alpha) #produces a gaussian profile image #INPUTS: # n1,n2: size of the output image # x0,y0: centroid of the gaus...
4,915
26.463687
78
py
SLIT
SLIT-master/Tests/Test_center.py
import pyfits as pf import matplotlib.pyplot as plt import numpy as np import matplotlib.cm as cm import SLIT import gaussian as gs import time from scipy import signal as scp import warnings warnings.simplefilter("ignore") #Example of a run of the SLIT algorithm on simulated images. #Here the first part of the file...
5,537
32.97546
116
py
SLIT
SLIT-master/Tests/Results_center.py
import numpy as np import matplotlib.pyplot as plt import SLIT import pyfits as pf import matplotlib.cm as cm import os import glob nsim =49 ranges = np.array([0.0,0.1,0.2,0.3,0.4,0.5])#np.linspace(0,1,11) Truth = pf.open('IMG2.fits')[0].data sigma = 0.00119 Sources = 0 FSs = 0 thetas = np.zeros((nsim, ranges.size)...
3,528
30.508929
155
py
SLIT
SLIT-master/SLIT/Solve.py
#from __future__ import division import wave_transform as mw import numpy as np import matplotlib.pyplot as plt import pyfits as pf import matplotlib.cm as cm from scipy import signal as scp import scipy.ndimage.filters as med import MuSCADeT as wine from numpy import linalg as LA import multiprocess as mtp from patho...
24,278
33.004202
186
py
SLIT
SLIT-master/SLIT/wave_transform.py
import numpy as np import scipy.signal as cp import matplotlib.pyplot as plt import scipy.ndimage.filters as sc def symmetrise(img, size): n3, n4 = np.shape(img) n1,n2 = size img[:(n3-n1)/2, :] = np.flipud(img[(n3-n1)/2:(n3-n1),:]) img[:,:(n4-n2)/2] = np.fliplr(img[:,(n4-n2)/2:(n4-n2)]) img[(n3+n...
3,715
25.169014
81
py
SLIT
SLIT-master/SLIT/tools.py
import numpy as np import matplotlib.pyplot as plt import pyfits as pf from scipy import signal as scp import gaussian as gs import scipy.ndimage.filters as sc import scipy.ndimage.filters as med import scipy.signal as cp def MOM(A, B, levelA, levelB): A = A[:-1,:,:] B = B[:-1,:,:] levelA = levelA[:-1,:,:]...
10,239
27.444444
131
py