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 |
|---|---|---|---|---|---|---|
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/rewind_info.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 892 | 25.264706 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/memory_manager.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,042 | 30.606061 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/__init__.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 576 | 37.466667 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/matlab_utils.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 700 | 30.863636 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/parametric_line.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 9,143 | 33.37594 | 160 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/pivot_storage.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 7,981 | 30.674603 | 98 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/col_info_stack.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,659 | 27.135593 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/calc_order_ratio.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,947 | 44.37931 | 107 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/sparse_matrix_constructor.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 5,025 | 36.507463 | 131 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/SCLP_formulation.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 18,372 | 46.722078 | 159 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/extract_rates.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,873 | 42.044444 | 136 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/problem_dimensions.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,164 | 24.888889 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/generic_SCLP_solution.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 15,553 | 40.477333 | 163 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/equation_tools/setup.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,246 | 28 | 141 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/equation_tools/calc_equations.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 4,045 | 40.71134 | 136 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/equation_tools/__init__.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 576 | 37.466667 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/vector_list.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,184 | 30.184211 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/setup.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,498 | 33.068182 | 133 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/loc_min_storage.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 4,596 | 40.790909 | 93 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/calc_states.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 2,784 | 46.20339 | 117 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/__init__.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 576 | 37.466667 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/state_tools/calc_statecollide.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,664 | 42.117647 | 130 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/setup.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,253 | 28.162791 | 147 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/pivot.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 2,036 | 34.736842 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/in_out_pivot.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 1,906 | 30.262295 | 89 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/simplex_procedures.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 11,852 | 46.60241 | 196 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/LP_formulation.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 7,975 | 39.48731 | 172 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/__init__.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 576 | 37.466667 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/subroutines/lp_tools/matlab_utils.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 634 | 34.277778 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/MCQN_test_new.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,212 | 40.192308 | 141 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/MCQN_test_mpc.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,851 | 40.419355 | 141 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/simple_reentrant_test.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 3,998 | 46.607143 | 134 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/pivot_time_test.py | import sys
sys.path.append('C:\DataD\Work\CERBERO\CLP\SCLPsolver')
import os
import numpy as np
from subroutines.lp_tools.cy_lp_tools import copy_pivot
def relative_to_project(file_path):
if os.path.isabs(file_path):
return file_path
else:
proj = os.path.realpath(os.path.join(os.path.dirname(o... | 1,695 | 36.688889 | 111 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/MCQN_test.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 4,389 | 46.204301 | 132 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/tests/__init__.py | # Copyright 2020 IBM Corporation
#
# 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 applicable law or agreed to in writing, ... | 576 | 37.466667 | 74 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/pytests/MCQN_basic_test.py | import pytest
import os, sys
proj = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
sys.path.append(proj)
from SCLPsolver.SCLP import SCLP, SCLP_settings
from SCLPsolver.doe.data_generators.MCQN import generate_MCQN_data
seeds = range(1001, 1009)
@pytest.mark.parametrize("seed", ... | 2,366 | 37.177419 | 118 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/pytests/WorkloadPlacementPaper_test.py | import pandas as pd
import pytest
from scipy.integrate import quad
import matplotlib.pyplot as plt
import os, sys
import numpy as np
proj = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
sys.path.append(proj)
from SCLPsolver.SCLP import SCLP, SCLP_settings
from SCLPsolver.doe.data_... | 14,581 | 47.284768 | 145 | py |
SCLPsolver | SCLPsolver-master/SCLPsolver/pytests/__init__.py | 0 | 0 | 0 | py | |
SCLPsolver | SCLPsolver-master/SCLPsolver/pytests/WorkloadPlacement_test.py | import pytest
import os, sys
import numpy as np
proj = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
sys.path.append(proj)
from SCLPsolver.SCLP import SCLP, SCLP_settings
from SCLPsolver.doe.data_generators.WorkloadPlacement import *
from SCLPsolver.doe.doe import *
def test_ge... | 16,320 | 42.756032 | 164 | py |
RandomNeuralField | RandomNeuralField-main/train.py | import sys
from pathlib import Path
import numpy as np
from sklearn.model_selection import train_test_split
import torch
import torch.nn as nn
from torch import optim
from torch.utils.data import DataLoader, TensorDataset
from torchvision import datasets, transforms
from src.utils.factory import read_yaml
from src.... | 5,899 | 30.382979 | 112 | py |
RandomNeuralField | RandomNeuralField-main/src/tools/relative_frob.py | import sys
from os.path import join, dirname
import torch
import torch.nn as nn
from torch import optim
sys.path.append(join(dirname(__file__), "../.."))
from src.ntk.generate import generate_ntk
from src.utils.factory import calc_diff_frob, calc_acc
def calc_ntk_frob(cfg, net, lr, train_loader, test_loader):
... | 1,949 | 31.5 | 78 | py |
RandomNeuralField | RandomNeuralField-main/src/tools/train.py | import sys
from os.path import join, dirname
import torch
import torch.nn as nn
from torch import optim
sys.path.append(join(dirname(__file__), "../.."))
from src.utils.factory import calc_acc
def train(cfg, net, lr, database):
n_epochs = cfg.GENERAL.EPOCH
input_shape = cfg.MODEL.INPUT_FEATURES
dev... | 2,554 | 32.181818 | 82 | py |
RandomNeuralField | RandomNeuralField-main/src/dataset/dataset.py | import numpy as np
from sklearn.model_selection import train_test_split
import torch
from torch.utils.data import DataLoader, TensorDataset
from torchvision import datasets, transforms
class MakeDataset:
def __init__(self, cfg):
self.cfg = cfg
self.dataset_name = cfg.DATA.NAME
s... | 2,678 | 30.151163 | 78 | py |
RandomNeuralField | RandomNeuralField-main/src/ntk/learning_curve.py | import sys
from os.path import join, dirname
from tqdm.auto import tqdm
import numpy as np
import scipy as sp
sys.path.append(join(dirname(__file__), "../.."))
from src.utils.factory import calc_acc , calc_loss_NTK
class LearningCurve:
def __init__(self, cfg, lr, NTK_train, train_label, f_train_0, f_test_0):
... | 2,625 | 32.240506 | 84 | py |
RandomNeuralField | RandomNeuralField-main/src/ntk/generate.py | from tqdm.auto import tqdm
import numpy as np
import torch
from torch.autograd import grad
def generate_ntk(net, label, train, test, cfg, calc_lr=False):
input_shape = cfg.MODEL.INPUT_FEATURES
device_id = cfg.GENERAL.GPUS
if len(train.size()) > 2:
train = train.view(-1, input_shape)
... | 1,997 | 31.754098 | 75 | py |
RandomNeuralField | RandomNeuralField-main/src/ntk/regression.py | import numpy as np
def calc_acc_for_reg(yhat, y):
correct = 0
for i in range(len(y)):
label, pred = np.argmax(y[i]), np.argmax(yhat[i])
if label == pred:
correct += 1
return correct / len(y)
def ntk_regression(cfg, NTK_train, NTK_test, y_train, y_test):
... | 562 | 22.458333 | 71 | py |
RandomNeuralField | RandomNeuralField-main/src/models/initializers.py | import sys
from os.path import join, dirname
import numpy as np
import torch.nn as nn
from torch import Tensor
sys.path.append(join(dirname(__file__), "../.."))
from src.models.utils import sym_mat, receptive_mat, weight_correlation, matern_kernel
class Initializers(nn.Module):
def __init__(self, cfg):
... | 3,358 | 31.931373 | 86 | py |
RandomNeuralField | RandomNeuralField-main/src/models/utils.py | from math import pow
import numpy as np
from scipy.stats import multivariate_normal
from sklearn.gaussian_process.kernels import Matern
def sym_mat(features):
vec = np.arange(features).reshape(-1, 1)
X = np.tile(vec**2, (1, features))
H = np.dot(vec, vec.T)
return X - 2*H + X.T
def recept... | 1,806 | 26.378788 | 64 | py |
RandomNeuralField | RandomNeuralField-main/src/models/networks.py | import sys
from os.path import join, dirname
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
sys.path.append(join(dirname(__file__), "../.."))
from src.models.initializers import Initializers
def read_model(cfg):
init_type = cfg.INITIALIZER.TYPE
device_id = cfg.GE... | 3,468 | 28.905172 | 87 | py |
RandomNeuralField | RandomNeuralField-main/src/utils/factory.py | import os
from omegaconf import OmegaConf
import numpy as np
def read_yaml(fpath='config/config.yaml'):
config = OmegaConf.load(fpath)
return config
def calc_acc(outputs, labels):
correct = 0
for i in range(len(outputs)):
if outputs[i].argmax() == labels[i].argmax():
corre... | 748 | 18.710526 | 63 | py |
RandomNeuralField | RandomNeuralField-main/src/utils/visualize.py | from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
def mean_output_dynamics(results, ntk_results):
# train and test outputs of normal training
train_outputs = np.array(results['train_outputs'])
test_outputs = np.array(results['test_outputs'])... | 4,163 | 33.131148 | 80 | py |
snlpy | snlpy-master/scripts/structural-preprocess.py | from snlpy.ppr import ppr
from scipy import sparse
from sys import argv
import numpy as np
import pickle as pkl
def ppr_prepocess(adj, alpha=0.8, tol=0.00001, workers=20, seeds=None):
if seeds is None:
seeds = range(adj.shape[0])
return sparse.vstack([ppr(adj, [seed], alpha, tol) for seed in seeds])
... | 483 | 27.470588 | 74 | py |
snlpy | snlpy-master/scripts/link-prediction.py | import getopt
from sys import argv
import numpy as np
import matplotlib.pyplot as plt
from snlpy import structural_feats
import random
from sklearn.model_selection import ShuffleSplit
from sklearn.multiclass import OneVsRestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc... | 5,186 | 36.861314 | 130 | py |
snlpy | snlpy-master/snlpy/setup.py | from setuptools import setup
setup(name='snlpy',
version='0.1',
install_requires=['numpy', 'sklearn', 'numba', 'gensim'])
| 136 | 18.571429 | 63 | py |
snlpy | snlpy-master/snlpy/structural.py | import numpy as np
from multiprocessing import Pool
from scipy import sparse
from numba import njit, prange
def structural_feats(pairs, adj, ppr, chunksize=10000):
chunked_pairs = [pairs[i * chunksize:(i + 1) * chunksize]
for i in range(int(len(pairs) / chunksize))]
if int(len(pairs) / ch... | 3,532 | 31.412844 | 83 | py |
snlpy | snlpy-master/snlpy/__init__.py | from snlpy.ppr import ppr
from snlpy.embeddings import DeepWalk, NetMF, Node2Vec, Structural
from snlpy.structural import structural_feats
| 139 | 34 | 66 | py |
snlpy | snlpy-master/snlpy/ppr.py | """
Implementation for the Andersen-Chung-Lang approximate ppr algorithm
METHODS
-------
ppr(G, seed, alpha=0.85, tol=0.0001)
"""
from numba import njit, prange
from scipy import sparse
import numpy as np
import collections
def ppr(adj, seed, alpha=0.85, tol=0.0001):
"""
Compute approximate ppr vector for th... | 1,594 | 26.5 | 79 | py |
snlpy | snlpy-master/snlpy/embeddings/deepwalk.py | """
Implementation for DeepWalk
"""
from numba import njit, prange
from numpy import random
import numpy as np
from gensim.models.word2vec import Word2Vec
def DeepWalk(adj, walk_number=10, walk_length=80, dimensions=128,
workers=4, window_size=5, epochs=1, learning_rate=0.05):
"""
Fit an embeddin... | 4,088 | 26.26 | 74 | py |
snlpy | snlpy-master/snlpy/embeddings/node2vec.py | """
Node2Vec embedding implementation
"""
from gensim.models.word2vec import Word2Vec
import numpy as np
from numba import njit, prange
from snlpy.embeddings.deepwalk import _WalkContainer, process_adj
def Node2Vec(adj, walk_number=10, walk_length=80, dimensions=128,
workers=4, window_size=5, epochs=1, l... | 6,726 | 35.166667 | 94 | py |
snlpy | snlpy-master/snlpy/embeddings/structural.py | import numpy as np
from numba import njit, prange
@njit(parallel=True)
def compute_features(X, community, j, row_ptrs, row_indxs):
for i in prange(len(row_ptrs) - 1):
for u in row_indxs[row_ptrs[i]:row_ptrs[i + 1]]:
for c in community:
if u == c:
X[i, j] += 1... | 864 | 23.714286 | 65 | py |
snlpy | snlpy-master/snlpy/embeddings/netmf.py | """
Implementation of NetMF embedding method
"""
from scipy import sparse
import numpy as np
from sklearn.decomposition import TruncatedSVD
def NetMF(graph, dimensions=128, iterations=10, order=2, negative_samples=1):
"""
Fits a NetMF embedding to the given graph.
PARAMETERS
----------
graph : C... | 3,060 | 30.556701 | 96 | py |
snlpy | snlpy-master/snlpy/embeddings/__init__.py | from snlpy.embeddings.deepwalk import DeepWalk
from snlpy.embeddings.node2vec import Node2Vec
from snlpy.embeddings.netmf import NetMF
from snlpy.embeddings.structural import Structural
from snlpy.ppr import ppr
| 212 | 34.5 | 50 | py |
mdf_modeling_paper | mdf_modeling_paper-main/mdf_decompose.py | import numpy as np
import dynesty.utils as dyutil
import multiprocessing as mp
import scipy.special
import dynesty, dynesty.pool
import contextlib
import math
mv_sun = 4.81
class KirbyMassMetInfo:
"""
Class representing the mass metallicity relation
"""
def mass_met(log10l):
""" avg feh at a... | 11,538 | 34.179878 | 79 | py |
DivMF | DivMF-master/src/main.py | '''
Top-K Diversity Regularizer
This software may be used only for research evaluation purposes.
For other purposes (e.g., commercial), please contact the authors.
'''
import time
import math
import click
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from model ... | 8,840 | 37.947137 | 110 | py |
DivMF | DivMF-master/src/utils.py | '''
Top-K Diversity Regularizer
This software may be used only for research evaluation purposes.
For other purposes (e.g., commercial), please contact the authors.
'''
import random
import numpy as np
from numpy.core.numeric import indices
import pandas as pd
import scipy.sparse as sp
import torch
from torch._C imp... | 6,732 | 30.316279 | 86 | py |
DivMF | DivMF-master/src/model.py | '''
Top-K Diversity Regularizer
This software may be used only for research evaluation purposes.
For other purposes (e.g., commercial), please contact the authors.
'''
import torch.nn as nn
class BPR(nn.Module):
def __init__(self, user_num, item_num, factor_num):
super(BPR, self).__init__()
"""
user_num: nu... | 972 | 25.297297 | 66 | py |
topcat | topcat-master/python/topcat.py | from py4j.java_gateway import (JavaGateway, GatewayParameters, launch_gateway)
import numpy as np
import os, sys
def absolutejarpath():
filepath = os.path.abspath(__file__)
projectdir = os.path.split(os.path.split(filepath)[0])[0]
jarpath = os.path.join(os.path.join(projectdir, "target"), "topcat-1.0-SNAPSHOT.jar")... | 3,678 | 40.337079 | 123 | py |
elderflower | elderflower-master/setup.py | import os
import builtins
from setuptools import setup, find_packages
abspath = os.path.abspath(os.path.dirname(__file__))
def readme():
with open('README.md') as f:
return f.read()
install_requires = []
requirementPath = os.path.join(abspath, 'requirements.txt')
if os.path.isfile(requirementPath):
... | 1,016 | 19.34 | 78 | py |
elderflower | elderflower-master/elderflower/panstarrs.py | """
API for querying PANSTARRS
From http://ps1images.stsci.edu/ps1_dr2_api.html
"""
from astropy.io import ascii
from astropy.table import Table
import sys
import re
import numpy as np
import json
import requests
try: # Python 3.x
from urllib.parse import quote as urlencode
from urllib.request import urlretr... | 6,737 | 30.783019 | 112 | py |
elderflower | elderflower-master/elderflower/container.py | import os
import numpy as np
import matplotlib.pyplot as plt
from .io import logger
class Container:
"""
A container storing the prior, the loglikelihood function and
fitting data & setups. The container is passed to the sampler.
"""
def __init__(self,
n_spline=2,
... | 6,449 | 32.59375 | 106 | py |
elderflower | elderflower-master/elderflower/image.py | import os
import sys
import numpy as np
import matplotlib.pyplot as plt
from astropy import wcs
from astropy.io import fits
import astropy.units as u
from astropy.utils import lazyproperty
from photutils.segmentation import SegmentationImage
from .io import logger
from .mask import mask_param_default
from .plotting i... | 34,037 | 36.904232 | 96 | py |
elderflower | elderflower-master/elderflower/plotting.py | import os
import string
import numpy as np
from copy import copy, deepcopy
try:
import seaborn as sns
seaborn_plot = True
except ImportError:
seaborn_plot = False
import matplotlib.pyplot as plt
from matplotlib import rcParams
plt.rcParams['image.origin'] = 'lower'
plt.rcParams['image.cmap'] = 'gnuplot... | 34,006 | 36.576796 | 98 | py |
elderflower | elderflower-master/elderflower/norm.py | import os
import re
import sys
import math
import warnings
import numpy as np
import matplotlib.pyplot as plt
from astropy import wcs
from astropy.io import fits
from astropy.table import Table
from astropy.stats import sigma_clip
from photutils import CircularAnnulus
from .io import logger, save_pickle, load_pickle... | 13,674 | 36.568681 | 136 | py |
elderflower | elderflower-master/elderflower/sampler.py | import os
import time
import warnings
import numpy as np
import matplotlib.pyplot as plt
import multiprocess as mp
from scipy.optimize import minimize
try:
import dynesty
from dynesty import plotting as dyplot
from dynesty import utils as dyfunc
dynesty_installed = True
except ImportError:
warning... | 13,270 | 34.579088 | 92 | py |
elderflower | elderflower-master/elderflower/task.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import warnings
import numpy as np
from pathlib import Path
from functools import partial
from astropy.io import fits
from astropy.table import Table
from .io import logger
from .io import find_keyword_header, check_save_path, clean_pickling_object
f... | 42,957 | 39.412041 | 136 | py |
elderflower | elderflower-master/elderflower/modeling.py | import os
import time
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy.integrate import quad
from scipy.spatial import distance
from scipy.special import gamma as Gamma
from astropy import units as u
from astropy.io import fits, ascii
from astropy.modeling import model... | 64,315 | 35.357264 | 150 | py |
elderflower | elderflower-master/elderflower/utils.py | import os
import re
import sys
import math
import time
import string
import random
import warnings
from functools import partial
import numpy as np
from scipy import stats
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from astropy import wcs
from astropy import units as u
from astropy.io impor... | 73,388 | 35.971788 | 121 | py |
elderflower | elderflower-master/elderflower/__init__.py | __version__ = "0.3.3"
# Pixel scale (arcsec/pixel) for reduced and raw Dragonfly data
DF_pixel_scale = 2.5
DF_raw_pixel_scale = 2.85
# Gain (e-/ADU) of Dragonfly
DF_Gain = 0.37
try:
__SETUP__ = True
except NameError:
__SETUP__ = False
if not __SETUP__:
from . import io
from . import numeric
... | 707 | 17.153846 | 63 | py |
elderflower | elderflower-master/elderflower/stack.py | import os
import re
import sys
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import binary_dilation
from astropy.io import fits
from astropy.table import Table
from photutils.aperture import CircularAperture
from .io import logger
from .plotting import LogNorm
from .utils import ... | 13,695 | 32.568627 | 111 | py |
elderflower | elderflower-master/elderflower/numeric.py | import math
import numpy as np
from scipy.integrate import quad
from scipy.spatial import distance
from scipy.special import gamma as Gamma
try:
from numba import njit
except ImportError:
def njit(*args, **kwargs):
def dummy_decorator(func, *args, **kwargs):
return func
return dummy... | 15,181 | 31.579399 | 115 | py |
elderflower | elderflower-master/elderflower/io.py | import os
# Path
package_dir = os.path.dirname(__file__)
test_dir = os.path.normpath(os.path.join(package_dir, '../tests'))
script_dir = os.path.normpath(os.path.join(package_dir, '../scripts'))
config_dir = os.path.normpath(os.path.join(package_dir, '../configs'))
# Default configuration path
default_config = os.pat... | 8,489 | 30.917293 | 94 | py |
elderflower | elderflower-master/elderflower/atlas.py | """
Query HLSP-Atlas using Casjobs Command Line tool
"""
import os
import time
import glob
import subprocess
import numpy as np
from shutil import copyfile
from .io import script_dir, config_dir
default_atlas_config = os.path.join(config_dir, './casjobs.config')
exe_path = os.path.join(script_dir, 'casjobs.jar')
de... | 2,045 | 27.816901 | 183 | py |
elderflower | elderflower-master/elderflower/parallel.py | """
Submodule for parallel computing
Adapted from https://github.com/pycroscopy/sidpy (S.Somnath, C.Smith)
"""
import numpy as np
import joblib
def parallel_compute(data, func, cores=None, lengthy_computation=False, func_args=None, func_kwargs=None, verbose=False):
"""
Computes the provided function using mul... | 7,075 | 41.884848 | 121 | py |
elderflower | elderflower-master/elderflower/mask.py | import os
import math
import warnings
import numpy as np
from astropy.io import fits
from astropy.coordinates import SkyCoord
import astropy.units as u
from .io import logger
from .modeling import Stars
from .utils import background_extraction, crop_pad
from . import DF_pixel_scale
mask_param_default = dict(
mas... | 23,378 | 35.415888 | 196 | py |
elderflower | elderflower-master/elderflower/detection.py | """
Submodule for running SExtractor from dfreduce (credit: Johnny Greco).
Will be replaced by an independent module.
"""
import os
from subprocess import call
import numpy as np
from astropy.io import ascii, fits
from .io import logger
from .io import config_dir
# default SExtractor paths and files
input_file_path... | 8,487 | 35.429185 | 84 | py |
elderflower | elderflower-master/elderflower/crossmatch.py | import os
import re
import sys
import math
import random
import warnings
import numpy as np
from astropy import wcs
from astropy import units as u
from astropy.io import fits, ascii
from astropy.coordinates import SkyCoord
from astropy.table import Table, Column, join, vstack
from .io import logger
from .utils impo... | 18,154 | 41.717647 | 102 | py |
elderflower | elderflower-master/elderflower/.ipynb_checkpoints/utils-checkpoint.py | import os
import re
import sys
import math
import time
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
from astropy import wcs
from astropy import units as u
from astropy.io import fits, ascii
from astropy.table import Table, Column
from astropy.coordinates import SkyCoord
from astropy.stat... | 66,081 | 38.641272 | 142 | py |
elderflower | elderflower-master/elderflower/.ipynb_checkpoints/plotting-checkpoint.py | import os
import numpy as np
try:
import seaborn as sns
seaborn_plot = True
except ImportError:
import warnings
warnings.warn("Seaborn is not installed. Plot with matplotlib.")
seaborn_plot = False
import matplotlib.pyplot as plt
from matplotlib import rcParams
plt.rcParams['image.origin'] = 'lo... | 27,795 | 36.511471 | 101 | py |
elderflower | elderflower-master/elderflower/.ipynb_checkpoints/task-checkpoint.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import numpy as np
def Match_Mask_Measure(hdu_path, image_bounds,
SE_segmap, SE_catalog,
weight_map=None,
obj_name='', band="G",
pixel_scale=2.5,
... | 16,785 | 37.5 | 83 | py |
elderflower | elderflower-master/elderflower/.ipynb_checkpoints/modeling-checkpoint.py | import os
import time
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy.integrate import quad
from scipy.spatial import distance
from scipy.special import gamma as Gamma
from astropy import units as u
from astropy.io import fits, ascii
from astropy.modeling import model... | 80,363 | 35.134892 | 142 | py |
elderflower | elderflower-master/scripts/Run_Fitting_Mock.py | import galsim
import dynesty
from dynesty import plotting as dyplot
from dynesty import utils as dyfunc
from utils import *
from modeling import *
from plotting import *
import matplotlib
matplotlib.use('Agg')
# Option
save = True
dir_name = os.path.join('tmp', id_generator())
check_save_path(dir_name)
# dir_name = ... | 5,464 | 29.361111 | 103 | py |
elderflower | elderflower-master/scripts/Run_Fitting.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Run 2D Bayesian PSF fitting on a sub-region with
dynamic nested sampling. The Model PSF is composed
of an inner (fixed) Moffat core and an outer (user-
specified) multi-power law aureole. The fitting
result containing the joint PDF, samples and
weights, etc. and diag... | 6,660 | 37.50289 | 131 | py |
elderflower | elderflower-master/scripts/Measure_Rnorm.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Preparatory script doing the following tasks:
1) Crossmatch a source table (e.g. from SExtractor,
SEP, etc.) with star catalog(s), by default using
PANSTARRS DR2 catalog. A new table will be saved which
contains corrected source magnitude (e.g. MAG_AUTO).
2) Make en... | 4,319 | 36.241379 | 136 | py |
elderflower | elderflower-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,136 | 33.467742 | 112 | py |
3SD | 3SD-main/data_loader.py | # data loader
from __future__ import print_function, division
import glob
import torch
from skimage import io, transform, color
import numpy as np
import random
import math
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
from PIL import Image
#... | 9,040 | 32.609665 | 113 | py |
3SD | 3SD-main/new_data_loader.py | # data loader
from __future__ import print_function, division
import glob
import torch
from skimage import io, transform, color
import numpy as np
import random
import math
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
from PIL import Image
#... | 10,287 | 33.756757 | 147 | py |
3SD | 3SD-main/basenet_train.py | import os
import torch
import torchvision
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms as T
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
import torch.optim as optim
import torchvision.transform... | 21,206 | 37.279783 | 204 | py |
3SD | 3SD-main/3SD_train.py | import os
import torch
import torchvision
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms as T
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
import torch.optim as optim
import torchvision.transform... | 23,488 | 38.018272 | 204 | py |
3SD | 3SD-main/compute_and_plot.py | import os
import torch
from sklearn.metrics import f1_score, precision_score, recall_score
'''from sklearn.metrics import (precision_recall_curve, PrecisionRecallDisplay)
from sklearn.metrics import precision_recall_curve'''
import cv2
import pdb
import numpy as np
import torch.nn.functional as F
from torch.autograd i... | 9,521 | 33.625455 | 172 | py |
3SD | 3SD-main/u2net_test_pseudo_dino_final.py | import os
from skimage import io, transform
import torch
import torchvision
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms as T
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms#, utils
# import torch.optim a... | 12,334 | 34.14245 | 169 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.