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
SOLikeT
SOLikeT-master/soliket/gaussian_data.py
import numpy as np try: import holoviews as hv except ImportError: pass from scipy.linalg import cholesky, LinAlgError def multivariate_normal_logpdf(theory, data, cov, inv_cov, log_det): const = np.log(2 * np.pi) * (-len(data) / 2) + log_det * (-1 / 2) delta = data - theory #print(const,delta,np...
4,889
28.281437
84
py
SOLikeT
SOLikeT-master/soliket/poisson_data.py
import numpy as np import pandas as pd class PoissonData: """Poisson-process-generated data. Parameters ---------- catalog : pd.DataFrame Catalog of observed data. columns : list Columns of catalog relevant for computing poisson rate. samples : dict, optional Each entr...
2,851
34.209877
87
py
SOLikeT
SOLikeT-master/soliket/utils.py
from importlib import import_module from scipy.stats import binned_statistic as binnedstat import numpy as np from cobaya.likelihood import Likelihood from cobaya.likelihoods.one import one def binner(ls, cls, bin_edges): x = ls.copy() y = cls.copy() cents = (bin_edges[:-1] + bin_edges[1:]) / 2.0 bi...
1,140
26.166667
73
py
SOLikeT
SOLikeT-master/soliket/bandpass.py
r""" .. module:: bandpass This module computes the bandpass transmission based on the inputs from the parameter file ``BandPass.yaml``. There are three possibilities: * reading the passband :math:`\tau(\nu)` stored in a sacc file (which is the default now, being the mflike default) * building the passb...
13,271
39.711656
91
py
SOLikeT
SOLikeT-master/soliket/gaussian.py
import numpy as np from typing import Optional, Sequence from cobaya.likelihood import Likelihood from cobaya.input import merge_info from cobaya.tools import recursive_update from cobaya.typing import empty_dict from .gaussian_data import GaussianData, MultiGaussianData from .utils import get_likelihood class Gaus...
3,654
31.061404
88
py
SOLikeT
SOLikeT-master/soliket/poisson.py
import pandas as pd from cobaya.likelihood import Likelihood from .poisson_data import PoissonData class PoissonLikelihood(Likelihood): name = "Poisson" data_path = None columns = None def initialize(self): catalog = self._get_catalog() if self.columns is None: self.colu...
1,084
26.125
83
py
SOLikeT
SOLikeT-master/soliket/__init__.py
from .lensing import LensingLiteLikelihood, LensingLikelihood # noqa: F401 from .gaussian import GaussianLikelihood, MultiGaussianLikelihood # noqa: F401 # from .studentst import StudentstLikelihood # noqa: F401 from .ps import PSLikelihood, BinnedPSLikelihood # noqa: F401 from .mflike import MFLike # noqa: F401 f...
953
37.16
98
py
SOLikeT
SOLikeT-master/soliket/cosmopower.py
""" .. module:: soliket.cosmopower :Synopsis: Simple CosmoPower theory wrapper for Cobaya. :Author: Hidde T. Jense .. |br| raw:: html <br /> .. note:: **If you use this cosmological code, please cite:** |br| A. Spurio Mancini et al. *CosmoPower: emulating cosmological power spectra for accelerated B...
12,879
32.541667
106
py
SOLikeT
SOLikeT-master/soliket/bias.py
""" .. module:: soliket.bias :Synopsis: Class to calculate bias models for haloes and galaxies as cobaya Theory classes. :author: Ian Harrison Usage ----- To use the Linear Bias model, simply add it as a theory code alongside camb in your run settings, e.g.: .. code-block:: yaml theory: camb: soliket.bia...
2,862
26.528846
87
py
SOLikeT
SOLikeT-master/soliket/lensing/lensing.py
import os from pkg_resources import resource_filename import numpy as np import sacc from cobaya.likelihoods.base_classes import InstallableLikelihood from cobaya.model import get_model from cobaya.log import LoggedError # from cobaya.install import NotInstalledError from ..ps import BinnedPSLikelihood class Lensin...
6,836
34.42487
87
py
SOLikeT
SOLikeT-master/soliket/lensing/__init__.py
from .lensing import LensingLiteLikelihood, LensingLikelihood # noqa: F401
76
37.5
75
py
SOLikeT
SOLikeT-master/soliket/tests/test_xcorr.py
# pytest -k xcorr -v --pdb . import pytest import numpy as np from cobaya.yaml import yaml_load from cobaya.model import get_model import os import pdb def get_demo_xcorr_model(theory): if theory == "camb": info_yaml = r""" likelihood: soliket.XcorrLikelihood: stop_a...
5,744
32.208092
90
py
SOLikeT
SOLikeT-master/soliket/tests/test_bias.py
# pytest -k bias -v . import pytest import numpy as np from cobaya.model import get_model from cobaya.run import run info = {"params": { "b_lin": 1.1, "H0": 70., "ombh2": 0.0245, "omch2": 0.1225, "ns": 0.96, ...
1,999
26.027027
85
py
SOLikeT
SOLikeT-master/soliket/tests/test_gaussian.py
# import unittest import numpy as np from sklearn.datasets import make_spd_matrix from soliket.gaussian import GaussianData, MultiGaussianData, CrossCov def toy_data(): name1 = "A" n1 = 10 x1 = np.arange(n1) y1 = np.random.random(n1) name2 = "B" n2 = 20 x2 = np.arange(n2) y2 = np.ran...
2,674
28.395604
89
py
SOLikeT
SOLikeT-master/soliket/tests/test_cash.py
import numpy as np from soliket.cash import CashCData def toy_data(): x = np.arange(20) y = np.arange(20) xx, yy = np.meshgrid(x, y) return x, y, xx, yy def test_cash(): data1d, theory1d, data2d, theory2d = toy_data() cashdata1d = CashCData("toy 1d", data1d) cashdata2d = CashCData("...
484
19.208333
73
py
SOLikeT
SOLikeT-master/soliket/tests/test_lensing.py
import os import tempfile import pytest import numpy as np from cobaya.yaml import yaml_load from cobaya.model import get_model packages_path = os.environ.get("COBAYA_PACKAGES_PATH") or os.path.join( tempfile.gettempdir(), "lensing_packages" ) # Cosmological parameters for the test data from SO sims # See https:/...
1,256
26.326087
79
py
SOLikeT
SOLikeT-master/soliket/tests/test_ccl.py
""" Check that CCL works correctly. """ import pytest import numpy as np from cobaya.model import get_model from cobaya.likelihood import Likelihood class CheckLike(Likelihood): """ This is a mock likelihood that simply forces soliket.CCL to calculate a CCL object. """ def logp(self, **params_valu...
2,033
20.638298
80
py
SOLikeT
SOLikeT-master/soliket/tests/test_cosmopower.py
""" Check that CosmoPower gives the correct Planck CMB power spectrum. """ import os import pytest import numpy as np import matplotlib.pyplot as plt from cobaya.model import get_model from soliket.cosmopower import HAS_COSMOPOWER fiducial_params = { "ombh2": 0.0224, "omch2": 0.122, "h": 0.67, "tau": ...
4,311
30.474453
84
py
SOLikeT
SOLikeT-master/soliket/tests/test_mflike.py
""" Make sure that this returns the same result as original mflike.MFLike from LAT_MFlike repo """ import os import tempfile import unittest import pytest from packaging.version import Version import camb import soliket # noqa from soliket.mflike import TestMFLike import numpy as np packages_path = os.environ.get("...
5,764
29.664894
90
py
SOLikeT
SOLikeT-master/soliket/tests/test_ps.py
import os from tempfile import gettempdir import numpy as np from sklearn.datasets import make_spd_matrix # from scipy.stats import multivariate_normal from soliket.gaussian import GaussianData, CrossCov from soliket import MultiGaussianLikelihood from soliket import PSLikelihood from soliket.utils import get_likeli...
2,554
30.158537
88
py
SOLikeT
SOLikeT-master/soliket/tests/test_poisson.py
import numpy as np import pandas as pd from functools import partial from soliket.poisson_data import PoissonData x_min = 0 x_max = 10 def rate_density(x, a): """simple linear rate density """ return a * x def n_expected(a): return 0.5 * a * (x_max ** 2 - x_min ** 2) # integral(rate_density, x_mi...
1,639
28.285714
87
py
SOLikeT
SOLikeT-master/soliket/tests/test_cross_correlation.py
import numpy as np import os import pytest from soliket.ccl import CCL from cobaya.model import get_model auto_file = 'soliket/data/xcorr_simulated/clgg_noiseless.txt' cross_file = 'soliket/data/xcorr_simulated/clkg_noiseless.txt' dndz_file = 'soliket/data/xcorr_simulated/dndz.txt' sacc_file = 'soliket/tests/data/des_...
8,759
32.822394
88
py
SOLikeT
SOLikeT-master/soliket/tests/test_foreground.py
# pytest -k bandpass -v . import pytest import numpy as np import os from cobaya.model import get_model from cobaya.run import run info = {"params": { "a_tSZ": 3.3044404448917724, "a_kSZ": 1.6646620740058649, "a_p": 6.912474322461401, "beta_...
11,069
46.922078
90
py
SOLikeT
SOLikeT-master/soliket/tests/test_lensing_lite.py
import pytest import numpy as np from cobaya.yaml import yaml_load from cobaya.model import get_model try: import classy # noqa F401 except ImportError: boltzmann_codes = ["camb"] else: boltzmann_codes = ["camb", "classy"] def get_demo_lensing_model(theory): if theory == "camb": info_yaml =...
1,586
20.739726
55
py
SOLikeT
SOLikeT-master/soliket/tests/__init__.py
0
0
0
py
SOLikeT
SOLikeT-master/soliket/tests/test_multi.py
import numpy as np import pytest from soliket.tests.test_mflike import cosmo_params, nuisance_params @pytest.mark.xfail(reason="lensing lhood install failure") def test_multi(): lensing_options = {"theory_lmax": 5000} pre = "data_sacc_" mflike_options = { "input_file": pre + "00000.fits", ...
3,066
34.252874
88
py
SOLikeT
SOLikeT-master/soliket/tests/test_clusters.py
import numpy as np import pytest from cobaya.model import get_model fiducial_params = { "ombh2": 0.02225, "omch2": 0.1198, "H0": 67.3, "tau": 0.06, "As": 2.2e-9, "ns": 0.96, "mnu": 0.06, "nnu": 3.046, } info_fiducial = { "params": fiducial_params, "likelihood": {"soliket.Clust...
1,322
21.05
73
py
SOLikeT
SOLikeT-master/soliket/tests/test_bandpass.py
# pytest -k bandpass -v . import pytest import numpy as np from cobaya.model import get_model from cobaya.run import run from ..constants import T_CMB, h_Planck, k_Boltzmann info = {"params": { "bandint_shift_LAT_93": 0.0, "bandint_shift_LAT_145": 0.0, "bandin...
5,237
30.178571
90
py
SOLikeT
SOLikeT-master/soliket/tests/test_runs.py
import pkgutil import pytest import tempfile from cobaya.yaml import yaml_load from cobaya.run import run import os packages_path = os.environ.get("COBAYA_PACKAGES_PATH") or os.path.join( tempfile.gettempdir(), "lensing_packages" ) import os packages_path = os.environ.get("COBAYA_PACKAGES_PATH") or os.path.join...
2,146
27.25
77
py
SOLikeT
SOLikeT-master/soliket/xcorr/limber.py
import numpy as np import pdb from ..constants import C_HMPC oneover_chmpc = 1. / C_HMPC def mag_bias_kernel(provider, dndz, s1, zatchi, chi_arr, chiprime_arr, zprime_arr): '''Calculates magnification bias kernel. ''' dndzprime = np.interp(zprime_arr, dndz[:, 0], dndz[:, 1], left=0, right=0) norm =...
4,606
36.762295
87
py
SOLikeT
SOLikeT-master/soliket/xcorr/xcorr.py
r""" Likelihood for cross-correlation of CMB lensing and galaxy clustering probes. """ import numpy as np import sacc import pdb from scipy.interpolate import InterpolatedUnivariateSpline as Spline from ..gaussian import GaussianData, GaussianLikelihood from .. import utils from .limber import do_limber class Xco...
9,916
36.422642
110
py
SOLikeT
SOLikeT-master/soliket/xcorr/__init__.py
from .xcorr import XcorrLikelihood
35
17
34
py
SOLikeT
SOLikeT-master/soliket/mflike/mflike.py
r""" .. module:: mflike :Synopsis: Multi frequency likelihood for TTTEEE CMB power spectra for Simons Observatory :Authors: Thibaut Louis, Xavier Garrido, Max Abitbol, Erminia Calabrese, Antony Lewis, David Alonso. MFLike is a multi frequency likelihood code interfaced with the Cobaya sampler and a theory ...
17,618
39.226027
90
py
SOLikeT
SOLikeT-master/soliket/mflike/theoryforge_MFLike.py
""" .. module:: theoryforge The ``TheoryForge_MFLike`` class applies the foreground spectra and systematic effects to the theory spectra provided by ``MFLike``. To do that, ``MFLike`` provides ``TheoryForge_MFLike`` with the appropriate list of channels, the requested temperature/polarization fields, the :math:`\ell`...
13,738
38.366762
88
py
SOLikeT
SOLikeT-master/soliket/mflike/__init__.py
from .mflike import MFLike, TestMFLike from .theoryforge_MFLike import TheoryForge_MFLike
90
29.333333
50
py
SOLikeT
SOLikeT-master/soliket/clusters/massfunc.py
import numpy as np from scipy.interpolate import RegularGridInterpolator from .tinker import dn_dlogM from ..constants import MSUN_CGS, G_CGS, MPC2CM np.seterr(divide='ignore', invalid='ignore') class HMF: def __init__(self, om, Ez, pk=None, kh=None, zarr=None): # Initialize redshift and mass ranges ...
2,360
30.065789
85
py
SOLikeT
SOLikeT-master/soliket/clusters/tinker.py
from builtins import zip import numpy as np from scipy.interpolate import InterpolatedUnivariateSpline as iuSpline from scipy.integrate import simps # Tinker stuff tinker_data = np.transpose([[float(x) for x in line.split()] for line in """200 0.186 1.47 2.57 1....
5,114
29.813253
77
py
SOLikeT
SOLikeT-master/soliket/clusters/survey.py
import os import numpy as np from scipy import interpolate import astropy.io.fits as pyfits # from astLib import astWCS from astropy.wcs import WCS from astropy.io import fits import astropy.table as atpy def read_clust_cat(fitsfile, qmin): list = fits.open(fitsfile) data = list[1].data SNR = data.field...
6,963
31.849057
88
py
SOLikeT
SOLikeT-master/soliket/clusters/sz_utils.py
import numpy as np from scipy import interpolate # from astropy.cosmology import FlatLambdaCDM # from nemo import signals from ..constants import MPC2CM, MSUN_CGS, G_CGS, C_M_S, T_CMB from ..constants import h_Planck, k_Boltzmann, electron_mass_kg, elementary_charge # from .clusters import C_KM_S as C_in_kms rho_cri...
13,757
32.474453
90
py
SOLikeT
SOLikeT-master/soliket/clusters/clusters.py
""" requires extra: astlib """ import numpy as np import pandas as pd from scipy.interpolate import interp1d from pkg_resources import resource_filename import pyccl as ccl from ..poisson import PoissonLikelihood from . import massfunc as mf from .survey import SurveyData from .sz_utils import szutils C_KM_S = 2.997...
7,397
29.697095
89
py
SOLikeT
SOLikeT-master/soliket/clusters/__init__.py
from .clusters import ClusterLikelihood # noqa: F401
54
26.5
53
py
SOLikeT
SOLikeT-master/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # Import SOLikeT (for autodoc) import sys sys.path.insert(0, "..") # Create some mock imports import mock MOCK_MODUL...
1,440
31.022222
87
py
studd
studd-main/utils.py
import numpy as np import pandas as pd import copy def num_cols(df): types = [type(df[col].values[1]) for col in df.columns] is_num = [not int(x is str) for x in types] is_num_idx = np.flatnonzero(is_num) return is_num_idx def any_str_col(df): types = [type(df[col].values[0]) for col in df.colu...
1,397
18.150685
63
py
studd
studd-main/__init__.py
#
1
1
1
py
studd
studd-main/workflows.py
import pandas as pd import numpy as np from studd.studd_batch import STUDD from sklearn import metrics from sklearn.ensemble import RandomForestClassifier as RF from skmultiflow.drift_detection.page_hinkley import PageHinkley as PHT def Workflow(X, y, delta, window_size): ucdd = STUDD(X=X, y=y, n_train=window_s...
6,327
40.090909
73
py
studd
studd-main/studd/studd_batch.py
from skmultiflow.data.data_stream import DataStream from skmultiflow.drift_detection.page_hinkley import PageHinkley as PHT from ht_detectors.tracker_output import HypothesisTestDetector import copy import numpy as np class STUDD: def __init__(self, X, y, n_train): """ :param X: :param y...
16,337
28.813869
92
py
studd
studd-main/studd/__init__.py
#
2
0.5
1
py
studd
studd-main/ht_detectors/tracker_output.py
import numpy as np from scipy import stats class HypothesisTestDetector(object): METHOD = "ks" def __init__(self, method, window, thr): assert method in ["ks", "wrs", "tt"] if method == "ks": # Two-sample Kolmogorov-Smirnov test m = stats.ks_2samp elif method ...
2,561
24.366337
67
py
studd
studd-main/ht_detectors/__init__.py
#
1
1
1
py
studd
studd-main/ht_detectors/tracker_covariates.py
import numpy as np import pandas as pd from scipy.stats import ks_2samp class FeatTracker(object): def __init__(self, ref_window, thr, window_size): self.method = ks_2samp self.alarm_list = [] self.data = [] self.ref_window = np.array(ref_window) self.window_size = window_...
2,842
23.508621
67
py
studd
studd-main/experiments/main.py
import pickle from workflows import Workflow with open('data/real_datasets.pkl', 'rb') as fp: datasets = pickle.load(fp) delta = 0.002 results = dict() for df in datasets: y = data.target.values X = data.drop(['target'], axis=1) small_data_streams = ['AbruptInsects', ...
1,142
24.4
72
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/resample.py
import numpy as np import SimpleITK as sitk import os import argparse parser = argparse.ArgumentParser(description='Resampling CT img or seg to 256 or 512') parser.add_argument('-p1', '--path1_filename', default=None, type=str, metavar='path1_filename', help='Raw file folder ') ...
2,903
28.333333
119
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/train_sf_partial.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 5 16:00:33 2017 @author: yan """ # %% train the network import argparse import datetime import math import numpy as np import os from os import path import shutil import time import torch from torch import cuda from torch import optim #from torch....
24,733
35.480826
110
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/train_concave0.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 5 16:00:33 2017 @author: yan """ # %% train the network import argparse import datetime import math import numpy as np import os from os import path import shutil import time import torch from torch import cuda from torch import optim #from torch....
24,809
35.485294
131
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/segment_sf_partial.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 28 16:24:59 2017 @author: yan Load pre-trained network to segment a new image Code v0.01 """ # %% Resnet blocks in U-net import argparse import datetime import nibabel as nib import numpy as np import os from os import path from scipy import ndi...
17,990
34.001946
126
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/dataset/dataset_liverCT_2D.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 22 14:10:33 2017 @author: yanrpi """ # %% import glob import numpy as np import nibabel as nib import random import torch from torch.utils.data import Dataset, DataLoader from torchvision import transforms from os import path # from scipy.misc impo...
16,145
31.552419
99
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/PIPO-FAN-master/pipo_fan/dataset/dataset_muor_2D.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 22 14:10:33 2017 @author: yanrpi """ # %% import glob import numpy as np import nibabel as nib import random import torch from torch.utils.data import Dataset, DataLoader from torchvision import transforms from os import path # from scipy.misc impo...
15,824
31.428279
93
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/model/denseu_net.py
import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict class _DenseLayer(nn.Sequential): def __init__(self, num_input_features, growth_rate, bn_size, drop_rate): super(_DenseLayer, self).__init__() self.add_module('norm1', nn.BatchNorm2d(num_input_fea...
7,830
42.505556
114
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/model/unet.py
import torch import torch.nn as nn import torch.nn.functional as F class double_conv(nn.Module): '''(conv => BN => ReLU) * 2''' def __init__(self, in_ch, out_ch): super(double_conv, self).__init__() self.conv = nn.Sequential( nn.Conv2d(in_ch, out_ch, 3, padding=1), nn.B...
2,971
26.266055
86
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/model/resu_net.py
import torch import torch.nn as nn import torch.nn.functional as F class double_conv(nn.Module): '''(conv => BN => ReLU) * 2''' def __init__(self, in_ch, out_ch): super(double_conv, self).__init__() self.conv = nn.Sequential( nn.BatchNorm2d(in_ch), nn.ReLU(inplace=True)...
3,831
27.176471
86
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/model/concave_dps.py
import torch import torch.nn as nn import torch.nn.functional as F class double_conv(nn.Module): '''(conv => BN => ReLU) * 2''' def __init__(self, in_ch, out_ch): super(double_conv, self).__init__() self.conv = nn.Sequential( nn.BatchNorm2d(in_ch), nn.ReLU(inplace=True)...
8,568
29.386525
86
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 16/model/concave_dps_w.py
import torch import torch.nn as nn import torch.nn.functional as F from .concave_dps import ResUNet as ResUNet_0 class attention(nn.Module): def __init__(self, in_ch, out_ch): super(attention, self).__init__() self.conv = nn.Sequential( nn.BatchNorm2d(in_ch), nn.ReLU(inplace...
1,754
26.421875
54
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 5/main.py
print(__doc__) import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from sklearn.neural_network import MLPRegressor from sklearn.datasets.california_housing import fetch_california_housing import math from itertools import combinations import shap ## Use House Dataset cal_hous...
2,784
28.62766
142
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/Gradient_DeepTaylorLRP.py
import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm import lrp import pandas as pd from pylab import rcParams ### Import Data From TensorFlow rcParams['figure.figsize'] = 8, 10 mnist = input_data.read_data_sets('/...
3,595
32.607477
119
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/Gradient_Sundararajan.py
import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm import lrp import pandas as pd from pylab import rcParams ### Import Data From TensorFlow rcParams['figure.figsize'] = 8, 10 mnist = input_data.read_data_sets('/t...
3,861
30.655738
92
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/Gradient_Simonyan.py
import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm import pandas as pd from pylab import rcParams ### Import Data From TensorFlow rcParams['figure.figsize'] = 8, 10 mnist = input_data.read_data_sets('/tmp/tensorf...
3,554
31.614679
92
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/Gradient_Smilkov.py
import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm import pandas as pd from pylab import rcParams ### Import Data From TensorFlow rcParams['figure.figsize'] = 8, 10 mnist = input_data.read_data_sets('/tmp/tensorf...
3,777
30.22314
92
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/ShowSaliency.py
import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm import lrp import pandas as pd from pylab import rcParams import numpy as np import tensorflow as tf import h5py import os import matplotlib.pyplot as plt import ...
7,312
25.305755
88
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 6/lrp.py
import sys from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np from tqdm import tqdm from tensorflow.python.ops import nn_ops, gen_nn_ops import matplotlib.pyplot as plt from scipy.stats.mstats import zscore #Helper Method for def lrp(F, lowest, highest, graph=None, ...
6,252
35.354651
109
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/main.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import scipy.linalg as slin import scipy.sparse....
12,510
35.263768
168
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/dataset_poisoning.py
import IPython import numpy as np import os import time from shutil import copyfile from influence.inceptionModel import BinaryInceptionModel from influence.binaryLogisticRegressionWithLBFGS import BinaryLogisticRegressionWithLBFGS import influence.experiments from influence.dataset import DataSet import tensorflow ...
8,970
40.532407
188
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/logisticRegressionWithLBFGS.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import scipy.linalg as slin import scipy.sparse.l...
6,886
33.094059
114
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/image_utils.py
import numpy as np import matplotlib.pyplot as plt import seaborn as sns from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential, model_from_json from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Convolution2D, MaxPooling2D from keras.optimizers ...
1,739
30.636364
99
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/all_CNN_c.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import matplotlib.pyplot as plt import seaborn as...
5,279
36.183099
137
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/experiments.py
import numpy as np import os import time import IPython from scipy.stats import pearsonr def get_try_check(model, X_train, Y_train, Y_train_flipped, X_test, Y_test): def try_check(idx_to_check, label): Y_train_fixed = np.copy(Y_train_flipped) Y_train_fixed[idx_to_check] = Y_train[idx_to_check] ...
7,208
40.67052
125
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/smooth_hinge.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster, svm import matplotlib.pyplot as plt import seabo...
11,722
32.686782
114
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/dataset.py
# Adapted from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/mnist.py import numpy as np class DataSet(object): def __init__(self, x, labels): if len(x.shape) > 2: x = np.reshape(x, [x.shape[0], -1]) assert(x.shape[0] == labels.s...
2,619
27.172043
123
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/imagenet_utils.py
# Taken from https://github.com/fchollet/keras/blob/master/keras/applications/imagenet_utils.py import numpy as np import json from keras.utils.data_utils import get_file from keras import backend as K CLASS_INDEX = None CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_in...
1,663
31.627451
105
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/nlprocessor.py
# from spacy.en import English # import spacy from sklearn.feature_extraction.text import CountVectorizer import numpy as np import en_core_web_sm class NLProcessor(object): def __init__(self): # self.nlp = English() self.nlp = en_core_web_sm.load() # self.nlp = spacy.load('en_core_web_sm-...
3,105
33.131868
109
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/inception_v3.py
# -*- coding: utf-8 -*- """Inception V3 model for Keras. Note that the input image format for this model is different than for the VGG16 and ResNet models (299x299 instead of 224x224), and that the input preprocessing function is also different (same as Xception). # Reference - [Rethinking the Inception Architecture...
15,178
35.753027
152
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/genericNeuralNet.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import scipy.linalg as slin import scipy.sparse....
33,790
39.565426
158
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/binaryLogisticRegressionWithLBFGS.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import scipy.linalg as slin import scipy.sparse.l...
5,853
34.695122
142
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/inceptionModel.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import abc import sys import numpy as np import pandas as pd from sklearn import linear_model, preprocessing, cluster import scipy.linalg as slin import scipy.sparse.l...
11,113
34.059937
165
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 3/influence/hessians.py
### Adapted from TF repo import tensorflow as tf from tensorflow import gradients from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops def hessian_vector_product(ys, xs, v): """Multiply the Hessian of `ys` wrt `xs` by `v`. This is an e...
5,137
40.772358
83
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 17/main_BioLearning.py
import scipy.io import numpy as np import matplotlib.pyplot as plt import pickle ### Loading CIFAR100 def load_cifar100(filename): with open(filename, 'rb')as f: datadict = pickle.load(f, encoding='latin1') images = datadict['data'] labels = datadict['fine_labels'] labels = np.arr...
3,108
23.674603
107
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 7/main_rule_extraction.py
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from sklearn import datasets import numpy as np import tensorflow as tf ### Import Iris Data to play with # Sepal Length, Sepal Width, Petal Length and Petal Width iris = datasets.load_iris() X = iris.data # we only take the first two features...
6,727
27.033333
96
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 9/main_lime.py
from __future__ import print_function import sklearn import sklearn.datasets import sklearn.ensemble import numpy as np import lime import lime.lime_tabular ### Before running this code, you need to install package lime np.random.seed(1) iris = sklearn.datasets.load_iris() train, test, labels_train, labels_test = s...
864
28.827586
150
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 10/main_adjointMethods.py
import numpy as np import numpy.random as npr import tensorflow as tf from tqdm import tqdm import matplotlib.pyplot as plt import tensorflow.contrib.eager as tfe from main_neural_ode import NeuralODE ### tf.enable_eager_execution must be called at program startup. Please restart your kernel. plt.rcParams["font.f...
2,914
25.026786
92
py
IndependentEvaluation
IndependentEvaluation-main/Code For Figure 10/main_neural_ode.py
from typing import Optional, List import numpy as np import tensorflow as tf from tensorflow.python.framework.ops import EagerTensor import tensorflow.contrib.eager as tfe keras = tf.keras def zip_map(zipped, update_op): return [update_op(*elems) for elems in zipped] def euler_update(h_list, dh_list, dt): ...
4,469
28.215686
85
py
enpheeph
enpheeph-main/.noxfile.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
4,819
27.52071
94
py
enpheeph
enpheeph-main/src/enpheeph/__init__.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
12,581
37.477064
88
py
enpheeph
enpheeph-main/src/enpheeph/__about__.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
2,648
37.955882
77
py
enpheeph
enpheeph-main/src/enpheeph/abc/libraryhandlerpluginabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
2,244
35.803279
77
py
enpheeph
enpheeph-main/src/enpheeph/abc/lowleveltorchmaskpluginabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
3,069
35.117647
85
py
enpheeph
enpheeph-main/src/enpheeph/abc/indexingpluginabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
3,462
37.910112
86
py
enpheeph
enpheeph-main/src/enpheeph/abc/sqlstoragepluginabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
14,542
37.070681
88
py
enpheeph
enpheeph-main/src/enpheeph/abc/pytorchinjectionabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
2,730
34.934211
86
py
enpheeph
enpheeph-main/src/enpheeph/abc/pytorchsparseinterfacepluginabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
3,162
35.356322
85
py
enpheeph
enpheeph-main/src/enpheeph/abc/injectionabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
2,066
35.910714
77
py
enpheeph
enpheeph-main/src/enpheeph/abc/faultabc.py
# -*- coding: utf-8 -*- # enpheeph - Neural Fault Injection Framework # Copyright (C) 2020-2023 Alessio "Alexei95" Colucci # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version...
1,662
41.641026
77
py