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
apicarver
apicarver-main/testCarver/pythonCode/toolExecutionStats.py
import glob import os from constants import APPS from plotCoverage import getAppData from runCarver import getExistingCarverRun from utilsRun import importJson, writeCSV, writeCSV_Dict from urllib.parse import urlparse def findResultResponses(): allOutputs = {} for appName in APPS: carverOutput = None...
7,591
40.714286
220
py
apicarver
apicarver-main/testCarver/pythonCode/coverageStats.py
import datetime import glob import os import xml.etree.ElementTree as ETree from bs4 import BeautifulSoup import constants # import utilsRun from subprocess import check_call, CalledProcessError # combine schemathesis(vanilla) coverage with carver and prober coverage import utilsRun from runGeneratedTests import get...
26,599
52.846154
170
py
apicarver
apicarver-main/testCarver/pythonCode/runCarver.py
import os import shutil from datetime import datetime # from globalNames import FILTER, THRESHOLD_SETS, DB_SETS, APPS, isDockerized, DOCKER_LOCATION, isNd3App, getHostNames, \ # ALGOS, getDockerName, getDockerList, getURLList import glob from constants import APPS, RUN_CARVER_COMMAND, STATUS_SUCCESSFUL, STATUS_SKIPPED...
4,439
29.62069
121
py
apicarver
apicarver-main/testCarver/pythonCode/plotCoverage.py
import json import os from urllib.parse import urlsplit, parse_qs import ruamel.yaml import constants import runRestats import matplotlib.pyplot as plt def parsePostData(postData): params = {} if postData is None: print("Cannot parse None") return None if type(postData) is dict and "str...
6,614
29.767442
111
py
a2dr
a2dr-master/setup.py
from setuptools import setup, find_packages import codecs import os.path # code for single sourcing versions # reference: https://packaging.python.org/guides/single-sourcing-package-version/ def read(rel_path): here = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.join(here, rel_path), 'r'...
1,673
37.045455
105
py
a2dr
a2dr-master/examples/other_examples/simple_logistic.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
3,761
35.524272
120
py
a2dr
a2dr-master/examples/other_examples/stratified_model.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
3,750
30
101
py
a2dr
a2dr-master/examples/paper_examples/coupled_qp.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
4,224
39.625
133
py
a2dr
a2dr-master/examples/paper_examples/single_commodity_flow.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
6,153
38.961039
133
py
a2dr
a2dr-master/examples/paper_examples/l1_trend_filtering.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
3,203
34.6
133
py
a2dr
a2dr-master/examples/paper_examples/nnls_reg.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
2,825
32.642857
124
py
a2dr
a2dr-master/examples/paper_examples/optimal_control.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
5,945
41.471429
133
py
a2dr
a2dr-master/examples/paper_examples/sparse_inv_cov_est.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
3,718
38.147368
133
py
a2dr
a2dr-master/examples/paper_examples/nnls.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
2,824
31.471264
101
py
a2dr
a2dr-master/examples/paper_examples/multitask_reg_logistic.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
4,133
39.135922
133
py
a2dr
a2dr-master/examples/paper_examples/paper_plots.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
20,198
43.393407
132
py
a2dr
a2dr-master/a2dr/acceleration.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
2,012
33.706897
84
py
a2dr
a2dr-master/a2dr/utilities.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
2,883
32.929412
81
py
a2dr
a2dr-master/a2dr/__init__.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
719
30.304348
68
py
a2dr
a2dr-master/a2dr/solver.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
17,229
40.518072
112
py
a2dr
a2dr-master/a2dr/precondition.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
4,872
37.984
115
py
a2dr
a2dr-master/a2dr/tests/test_proximal.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
36,504
50.127451
134
py
a2dr
a2dr-master/a2dr/tests/test_basic.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
5,654
37.209459
114
py
a2dr
a2dr-master/a2dr/tests/test_precondition.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
4,577
38.465517
128
py
a2dr
a2dr-master/a2dr/tests/base_test.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
5,778
40.876812
157
py
a2dr
a2dr-master/a2dr/tests/test_projection.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
3,037
37.948718
90
py
a2dr
a2dr-master/a2dr/tests/__init__.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
660
33.789474
68
py
a2dr
a2dr-master/a2dr/proximal/norm.py
import numpy as np from scipy import sparse from a2dr.proximal.interface import NUMPY_FUNS, SPARSE_FUNS, apply_to_nonzeros from a2dr.proximal.projection import proj_l1 from a2dr.proximal.composition import prox_scale def prox_norm1(v, t = 1, *args, **kwargs): """Proximal operator of :math:`tf(ax-b) + c^Tx + d\\|x\...
5,328
42.680328
109
py
a2dr
a2dr-master/a2dr/proximal/constraint.py
import numpy as np from scipy import sparse from a2dr.proximal.interface import NUMPY_FUNS, SPARSE_FUNS from a2dr.proximal.composition import prox_scale def prox_box_constr(v, t = 1, v_lo = -np.inf, v_hi = np.inf, *args, **kwargs): """Proximal operator of :math:`tf(ax-b) + c^Tx + d\\|x\\|_2^2`, where :math:`f` is the...
5,589
43.015748
116
py
a2dr
a2dr-master/a2dr/proximal/misc.py
import numpy as np import warnings from scipy import sparse from scipy.special import expit, lambertw from scipy.optimize import minimize from a2dr.proximal.projection import proj_simplex from a2dr.proximal.composition import prox_scale def prox_kl(v, t = 1, u = None, *args, **kwargs): """Proximal operator of :ma...
3,886
40.351064
117
py
a2dr
a2dr-master/a2dr/proximal/projection.py
import numpy as np from scipy.optimize import bisect TOLERANCE = 1e-6 def proj_l1(x, r = 1, method = "bisection"): if np.isscalar(x): x = np.array([x]) if not np.isscalar(r) or r < 0: raise ValueError("r must be a non-negative scalar.") if np.linalg.norm(x,1) <= r: return x els...
1,730
35.829787
111
py
a2dr
a2dr-master/a2dr/proximal/__init__.py
""" Copyright 2019 Anqi Fu, Junzi Zhang This file is part of A2DR. A2DR is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A2DR is distribute...
1,329
48.259259
117
py
a2dr
a2dr-master/a2dr/proximal/interface.py
import numpy as np import scipy as sp from scipy import sparse def shape_to_2d(shape): if np.isscalar(shape) or len(shape) == 0: return 1,1 elif len(shape) == 1: return shape[0],1 else: return shape def apply_to_nonzeros(fun, v): if sparse.issparse(v): v_new = v.copy() ...
1,157
29.473684
100
py
a2dr
a2dr-master/a2dr/proximal/elementwise.py
import numpy as np from scipy import sparse from scipy.special import lambertw from a2dr.proximal.interface import NUMPY_FUNS, SPARSE_FUNS, apply_to_nonzeros from a2dr.proximal.composition import prox_scale def prox_abs(v, t = 1, *args, **kwargs): """Proximal operator of :math:`tf(ax-b) + c^Tx + d\\|x\\|_2^2`, whe...
6,182
44.131387
116
py
a2dr
a2dr-master/a2dr/proximal/quadratic.py
import numpy as np from cvxpy import * from scipy import sparse from a2dr.proximal.composition import prox_scale def prox_quad_form(v, t = 1, Q = None, method = "lsqr", *args, **kwargs): """Proximal operator of :math:`tf(ax-b) + c^Tx + d\\|x\\|_2^2`, where :math:`f(x) = x^TQx` for symmetric :math:`Q \\succeq 0...
6,958
43.608974
121
py
a2dr
a2dr-master/a2dr/proximal/matrix.py
import numpy as np from scipy import sparse from a2dr.proximal.composition import prox_scale from a2dr.proximal.norm import prox_norm_inf_base def prox_neg_log_det(B, t = 1, *args, **kwargs): """Proximal operator of :math:`tf(aB-b) + cB + d\\|B\\|_F^2`, where :math:`f(B) = -\\log\\det(B)`, where `B` is a symme...
3,154
46.089552
117
py
a2dr
a2dr-master/a2dr/proximal/composition.py
import numpy as np from scipy import sparse def prox_scale(prox, *args, **kwargs): """Given the proximal operator of a function :math:`f`, returns the proximal operator of :math:`g` defined as .. math:: g(x) = `tf(ax-b) + <c,x> + d\\|x\\|_F^2`, where :math:`t > 0`, :math:`a \\neq 0` is a scaling te...
1,980
48.525
119
py
longitudinalCOVID
longitudinalCOVID-master/main.py
import argparse import os import random from collections import defaultdict from copy import copy import numpy as np import torch import data_loader as module_data_loader import dataset as module_dataset import model as module_arch import model.utils.loss as module_loss import model.utils.metric as module_metric impo...
6,108
41.72028
123
py
longitudinalCOVID
longitudinalCOVID-master/majority_voting.py
import argparse import os import nibabel import numpy as np import torch from scipy.ndimage import rotate from tqdm import tqdm import data_loader as module_data_loader import dataset as module_dataset import model as module_arch import model.utils.metric as module_metric from dataset.DatasetStatic import Phase from ...
7,995
41.084211
115
py
longitudinalCOVID
longitudinalCOVID-master/parse_config.py
import logging import os from datetime import datetime from functools import reduce from importlib.machinery import SourceFileLoader from operator import getitem from pathlib import Path from logger import setup_logging from utils.util import write_config def parse_cmd_args(args): # parse default cli options ...
5,244
35.423611
142
py
longitudinalCOVID
longitudinalCOVID-master/trainer/LongitudinalWithProgressionTrainer.py
import numpy from logger import Mode from trainer.Trainer import Trainer from utils.illustration_util import log_visualizations import torch.nn.functional as F import torch class LongitudinalWithProgressionTrainer(Trainer): """ Trainer class for training with original loss + difference map loss + reverse ord...
5,986
51.982301
140
py
longitudinalCOVID
longitudinalCOVID-master/trainer/StaticTrainer.py
from logger import Mode from trainer.Trainer import Trainer from utils.illustration_util import log_visualizations import torch.nn.functional as F class StaticTrainer(Trainer): """ Trainer class for base training """ def __init__(self, model, loss, metric_ftns, optimizer, config, data_loader, fold=N...
5,253
51.54
141
py
longitudinalCOVID
longitudinalCOVID-master/trainer/LongitudinalTrainer.py
import numpy from logger import Mode from trainer.Trainer import Trainer from utils.illustration_util import log_visualizations import torch.nn.functional as F import torch class LongitudinalTrainer(Trainer): """ Trainer class """ def __init__(self, model, loss, metric_ftns, optimizer, config, data...
6,063
47.512
140
py
longitudinalCOVID
longitudinalCOVID-master/trainer/Trainer.py
from abc import abstractmethod import numpy as np import torch from base import BaseTrainer from logger import Mode from utils import MetricTracker class Trainer(BaseTrainer): """ Trainer class """ def __init__(self, model, loss, metric_ftns, optimizer, config, data_loader, fold=None, ...
5,947
40.594406
132
py
longitudinalCOVID
longitudinalCOVID-master/data_loader/Dataloader.py
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, WeightedRandomSampler from torch.utils.data.dataloader import default_collate import numpy as np class Dataloader(DataLoader): """ data loading -- uncomment the commented lines for reverse weight sampling the classes """ def __...
1,242
34.514286
125
py
longitudinalCOVID
longitudinalCOVID-master/dataset/dataset_utils.py
import csv import os import sys from collections import defaultdict, OrderedDict from enum import Enum from glob import glob import gc import h5py import numpy as np import pickle from skimage.transform import resize from dataset.dynamic.preprocessing import DatasetPreprocessor class Modalities(Enum): SIMPLE = '...
19,416
41.863135
177
py
longitudinalCOVID
longitudinalCOVID-master/dataset/rigid_and_deformable_registration.py
from pathlib import Path import SimpleITK as sitk import numpy as np import sys import torch import nibabel as nib from skimage.transform import resize def iteration_callback(filter): global itr print("deformable iter:", itr, "loss:", filter.GetMetricValue(), flush=True) itr += 1 def save(filter, fixed...
6,550
45.792857
118
py
longitudinalCOVID
longitudinalCOVID-master/dataset/DatasetStatic.py
import os import sys import h5py import numpy as np import torch import torch.nn.functional as F from PIL import Image from matplotlib import cm from skimage.transform import resize from torch.utils.data import Dataset from pathlib import Path from skimage import feature from torchvision.transforms import transforms ...
4,367
43.571429
165
py
longitudinalCOVID
longitudinalCOVID-master/dataset/DatasetLongitudinal.py
import os import h5py import numpy as np import torch import torch.nn.functional as F from PIL import Image from skimage import feature from skimage.transform import resize from torch.utils.data import Dataset from torchvision import transforms from dataset.dataset_utils import Phase, Modalities, Mode, retrieve_data_d...
4,962
46.721154
157
py
longitudinalCOVID
longitudinalCOVID-master/dataset/dynamic/preprocessing.py
import os import yaml from pathlib import Path import numpy as np import pandas as pd from skimage.transform import resize from tqdm import tqdm from dataset.rigid_and_deformable_registration import deformable_registration from .util import ( load_config_yaml, split_idxs, rm_tree, verify_config_hash, ...
16,929
40.192214
164
py
longitudinalCOVID
longitudinalCOVID-master/dataset/dynamic/util.py
from pathlib import Path import yaml import numpy as np from sklearn.model_selection import train_test_split import pandas as pd import hashlib import torch def load_config_yaml(path): """loads a yaml config from file and returns a dict""" path = Path(path) with open(path) as file: cfg = yaml.full...
7,244
32.082192
217
py
longitudinalCOVID
longitudinalCOVID-master/logger/visualization.py
import importlib from datetime import datetime from enum import Enum class Mode(Enum): TRAIN = 'Train' VAL = 'Val' class TensorboardWriter(): def __init__(self, log_dir, logger, enabled): self.writer = None self.selected_module = "" if enabled: log_dir = str(log_dir)...
3,020
36.296296
125
py
longitudinalCOVID
longitudinalCOVID-master/logger/logger.py
import logging import logging.config from pathlib import Path from utils import read_json def setup_logging(save_dir, log_config='logger/logger_config.json', default_level=logging.INFO): """ Setup logging configuration """ log_config = Path(log_config) if log_config.is_file(): config = re...
751
30.333333
96
py
longitudinalCOVID
longitudinalCOVID-master/logger/__init__.py
from .logger import * from .visualization import *
51
16.333333
28
py
longitudinalCOVID
longitudinalCOVID-master/configs/Static_Network.py
import os from polyaxon_client.tracking import get_outputs_path CONFIG = { "name": f"{os.path.basename(__file__).split('.')[0]}", "n_gpu": 1, "arch": { "type": "FCDenseNet", "args": { "in_channels": 1, "n_classes": 5 } }, "dataset": { "type"...
1,637
22.73913
119
py
longitudinalCOVID
longitudinalCOVID-master/configs/Longitudinal_Late_Fusion.py
import os from polyaxon_client.tracking import get_outputs_path CONFIG = { "name": f"{os.path.basename(__file__).split('.')[0]}", "n_gpu": 1, "arch": { "type": "LateLongitudinalFCDenseNet", "args": { "in_channels": 1, "n_classes": 5 } }, "dataset": {...
1,693
23.911765
119
py
longitudinalCOVID
longitudinalCOVID-master/configs/Longitudinal_Network.py
import os from polyaxon_client.tracking import get_outputs_path CONFIG = { "name": f"{os.path.basename(__file__).split('.')[0]}", "n_gpu": 1, "arch": { "type": "LongitudinalFCDenseNet", "args": { "in_channels": 1, "siamese": False, "n_classes": 5 ...
1,767
24.257143
119
py
longitudinalCOVID
longitudinalCOVID-master/configs/Longitudinal_Network_with_Progression_Learning.py
import os from polyaxon_client.tracking import get_outputs_path CONFIG = { "name": f"{os.path.basename(__file__).split('.')[0]}", "n_gpu": 1, "arch": { "type": "LongitudinalFCDenseNet", "args": { "in_channels": 1, "siamese": False, "n_classes": 5 ...
1,782
24.471429
119
py
longitudinalCOVID
longitudinalCOVID-master/base/base_model.py
from abc import abstractmethod import numpy as np import torch.nn as nn class BaseModel(nn.Module): """ Base class for all models """ @abstractmethod def forward(self, *inputs): """ Forward pass logic :return: Model output """ raise NotImplementedError ...
650
22.25
79
py
longitudinalCOVID
longitudinalCOVID-master/base/base_trainer.py
from abc import abstractmethod import torch from numpy import inf from logger import TensorboardWriter class BaseTrainer: """ Base class for all trainers """ def __init__(self, model, loss, metric_ftns, optimizer, config, fold=None): self.config = config self.logger = config.get_log...
7,505
39.354839
133
py
longitudinalCOVID
longitudinalCOVID-master/base/base_data_loader.py
import numpy as np from torch.utils.data import DataLoader from torch.utils.data.dataloader import default_collate from torch.utils.data.sampler import SubsetRandomSampler class BaseDataLoader(DataLoader): """ Base class for all data loaders """ def __init__(self, dataset, batch_size, shuffle, valida...
1,971
30.301587
112
py
longitudinalCOVID
longitudinalCOVID-master/base/__init__.py
from .base_data_loader import * from .base_model import * from .base_trainer import *
86
20.75
31
py
longitudinalCOVID
longitudinalCOVID-master/utils/util.py
import json import pprint from collections import OrderedDict from itertools import repeat from pathlib import Path import pandas as pd def write_config(content, fname): with fname.open('wt') as handle: handle.write("CONFIG = " + pprint.pformat(content)) handle.close() def read_json(fname): ...
3,525
34.979592
119
py
longitudinalCOVID
longitudinalCOVID-master/utils/__init__.py
from .util import *
20
9.5
19
py
longitudinalCOVID
longitudinalCOVID-master/utils/illustration_util.py
import cv2 import numpy as np import torch from torchvision.transforms import transforms from torchvision.utils import make_grid from PIL import Image, ImageDraw def warp_flow(img, flow): h, w = flow.shape[:2] flow = -flow flow[:, :, 0] += np.arange(w) flow[:, :, 1] += np.arange(h)[:, np.newaxis] ...
7,893
40.547368
158
py
longitudinalCOVID
longitudinalCOVID-master/model/FCDenseNet.py
from base import BaseModel from model.utils.layers import * class FCDenseNetEncoder(BaseModel): def __init__(self, in_channels=1, down_blocks=(4, 4, 4, 4, 4), bottleneck_layers=4, growth_rate=12, out_chans_first_conv=48): super().__init__() self.down_blocks = down_blocks self.skip_connecti...
4,679
45.8
156
py
longitudinalCOVID
longitudinalCOVID-master/model/LongitudinalFCDenseNet.py
from base import BaseModel from model.FCDenseNet import FCDenseNetEncoder, FCDenseNetDecoder from model.utils.layers import * class LongitudinalFCDenseNet(BaseModel): def __init__(self, in_channels=1, down_blocks=(4, 4, 4, 4, 4), up_blocks=(4, 4, 4, 4, 4), bottleneck_layers=4, ...
1,858
45.475
128
py
longitudinalCOVID
longitudinalCOVID-master/model/LateLongitudinalFCDenseNet.py
from base import BaseModel from model.FCDenseNet import FCDenseNetEncoder, FCDenseNetDecoder from model.utils.layers import * class LateLongitudinalFCDenseNet(BaseModel): def __init__(self, in_channels=1, down_blocks=(4, 4, 4, 4, 4), up_blocks=(4, 4, 4, 4, 4), bottleneck_layers=4...
1,423
38.555556
128
py
longitudinalCOVID
longitudinalCOVID-master/model/utils/metric_utils.py
import numpy as np import torch def asymmetric_loss(beta, output, target): g = flatten(target) p = flatten(output) pg = (p * g).sum(-1) beta_sq = beta ** 2 a = beta_sq / (1 + beta_sq) b = 1 / (1 + beta_sq) g_p = ((1 - p) * g).sum(-1) p_g = (p * (1 - g)).sum(-1) loss = (1. + pg) / (...
1,646
32.612245
70
py
longitudinalCOVID
longitudinalCOVID-master/model/utils/loss.py
import torch import torch.nn.functional as F from model.utils import metric_utils import numpy as np def inf(*args): return torch.as_tensor(float("Inf")) def gradient_loss(s): dy = torch.abs(s[:, :, 1:, :] - s[:, :, :-1, :]) ** 2 dx = torch.abs(s[:, :, :, 1:] - s[:, :, :, :-1]) ** 2 return (torch.me...
1,817
26.969231
108
py
longitudinalCOVID
longitudinalCOVID-master/model/utils/layers.py
import torch import torch.nn as nn import torch.nn.functional as F class SpatialTransformer(nn.Module): def __init__(self, size, mode='bilinear'): super(SpatialTransformer, self).__init__() vectors = [torch.arange(0, s) for s in size] grid = torch.unsqueeze(torch.stack(torch.meshgrid(vect...
3,420
32.871287
142
py
longitudinalCOVID
longitudinalCOVID-master/model/utils/metric.py
import numpy as np import torch from sklearn.metrics import f1_score, precision_score, recall_score, roc_curve from medpy import metric from model.utils import metric_utils def precision(output, target): with torch.no_grad(): target = metric_utils.flatten(target).cpu().detach().float() output = me...
5,769
30.703297
99
py
CONTAIN
CONTAIN-main/contain.py
import networkx as nx import networkx.algorithms.community as nx_comm import matplotlib.pyplot as plt from networkx.generators.random_graphs import gnm_random_graph import random as rnd import time from SparseShield_NIvsHS.Scripts.SparseShieldSolver import SparseShieldSolver from SparseShield_NIvsHS.Scripts.NetShieldSo...
2,793
41.333333
217
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/Simulator.py
import time import networkx as nx import random import numpy as np import logging from collections import defaultdict import warnings from joblib import Parallel, delayed class Simulator(): def __init__(self, G, seeds): self.G = G self.seeds = seeds self.blocked = {} self.log = {}...
4,867
37.634921
115
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/main.py
from DomSolver import DomSolver from networkx.generators.random_graphs import gnm_random_graph import random as rnd import time if __name__ == "__main__": en_pair = (978, 10217) G = gnm_random_graph(en_pair[0], en_pair[1], seed=None, directed=True) E = [] for e in G.edges: E.append((e[0], e[...
496
28.235294
74
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/RandomSolver.py
import networkx as nx import time import numpy as np from Solver import * class RandomSolver(Solver): def run(self): t1 = time.time() random_blocked_set = np.random.choice([node for node in self.G.nodes() if node not in self.seeds], self.k, replace=False) t2 = time.time() self.log...
424
27.333333
129
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/SparseShieldSeedlessSolver.py
from Solver import * import networkx as nx import numpy as np import time import sys import itertools from scipy.sparse.linalg import eigsh import os from heapq import * sys.path.append(os.path.dirname(os.path.abspath(__file__))) class PriorityQueue: def __init__(self, initlist): self.counter = itertools....
3,440
32.086538
89
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/run_solver.py
from Simulator import * from SparseShieldSolver import * from SparseShieldSeedlessSolver import * from SparseShieldPlusSolver import * from NetShieldSolver import * from NetShapeSolver import * from RandomSolver import * from DomSolver import * from DegreeSolver import * import os import sys import time import argparse...
2,623
34.945205
100
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/NetShieldSolver.py
import networkx as nx import numpy as np import time import sys import itertools from scipy.linalg import eigh import os from heapq import * sys.path.append(os.path.dirname(os.path.abspath(__file__))) from Solver import * class PriorityQueue: def __init__(self, initlist): self.counter = itertools.count() ...
3,193
32.270833
85
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/SparseShieldPlusSolver.py
from Solver import * import networkx as nx import numpy as np import time import sys import itertools from scipy.sparse.linalg import eigsh import os from heapq import * sys.path.append(os.path.dirname(os.path.abspath(__file__))) class PriorityQueue: def __init__(self, initlist): self.counter = itertools....
3,424
31.311321
78
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/SparseShieldSolver.py
from Solver import * import networkx as nx import numpy as np import time import sys import itertools from scipy.sparse.linalg import eigsh import os from heapq import * sys.path.append(os.path.dirname(os.path.abspath(__file__))) class PriorityQueue: def __init__(self, initlist): self.counter = itertools....
3,240
31.41
78
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/Generator.py
import networkx as nx from networkx.algorithms import approximation import random import sys import time import os import argparse import numpy as np import hashlib from scipy.sparse import csr_matrix class Generator: def __init__(self, params): self.params = params self.generators = { ...
5,605
43.141732
155
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/SetSelector.py
import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) import helpers import time import logging from collections import defaultdict, Counter class SetSelector(): def __init__(self, ranking, is_weighted=True): self.ranking = ranking self.is_weighted = is_weighted ...
4,718
38.991525
120
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/Solver.py
import time class Solver: def __init__(self, G, seeds, k, **params): if len(G) == 0: raise Exception("Graph can not be empty") if len(seeds) == 0: raise Exception("Seeds can not be empty") if k > len(G) - len(seeds): raise Exception("Seeds can not be bloc...
730
27.115385
68
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/DomSolver.py
''' The class implements DAVA - the seed-aware immunization algorithm based on dominator trees. ''' import networkx as nx import time from collections import defaultdict import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) import Solver as slv from functools import reduce import math import...
4,932
43.044643
142
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/DegreeSolver.py
import networkx as nx import time from Solver import * class DegreeSolver(Solver): def run(self): t1 = time.time() degrees = [(node, self.G.degree([node])[node]) for node in self.G.nodes() if node not in self.seeds] blocked = [] degrees.sort(key=lambda t: t[1]) for i in ran...
512
27.5
108
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/NetShapeSolver.py
import networkx as nx import numpy as np from scipy.linalg import eigh import time import sys import os import math sys.path.append(os.path.dirname(os.path.abspath(__file__))) from Solver import * class NetShapeSolver(Solver): def clear(self): np.warnings.filterwarnings('ignore') self.epsilon = se...
4,674
31.465278
105
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/helpers/runners.py
from os import system from joblib import Parallel, delayed def run_against_config(results_path, nodes_to_cut, algorithm_name, graph_file, seed_file, just_solve): output_name = results_path + "result_" + \ str(nodes_to_cut) + "_" + algorithm_name + "_" + \ graph_file.replace('.pkl', ...
1,322
54.125
244
py
CONTAIN
CONTAIN-main/SparseShield_NIvsHS/Scripts/helpers/graph_builder_helpers.py
import networkx as nx import pickle import json import os from os import listdir from os.path import isfile, join from networkx.utils import open_file user_list_property = 'UniqueUsers' user_count_property = 'UniqueUsersCount' number_of_nodes = 2789474.0 active_factor = 0.5 active_multiplier = active_factor * (1 / (...
4,138
36.972477
192
py
RAML
RAML-master/incremental/main.py
from tqdm import tqdm import network import utils import os import random import argparse import numpy as np import torch.nn.functional as F from torch.utils import data from datasets import VOCSegmentation, Cityscapes, cityscapes from utils import ext_transforms as et from metrics import StreamSegMetrics import torc...
28,621
42.170437
171
py
RAML
RAML-master/incremental/main_metric.py
from tqdm import tqdm import network import utils import os import random import argparse import numpy as np import torch.nn.functional as F from torch.utils import data from datasets import VOCSegmentation, Cityscapes, cityscapes, Cityscapes_Novel from utils import ext_transforms as et from metrics import StreamSegMe...
40,855
43.408696
152
py
RAML
RAML-master/incremental/test_metric.py
from datasets.cityscapes_novel import Cityscapes_Novel from tqdm import tqdm import network import utils import os import random import argparse import numpy as np import torch.nn.functional as F from torch.utils import data from datasets import VOCSegmentation, Cityscapes, Cityscapes_Novel from utils import ext_trans...
31,049
46.40458
153
py
RAML
RAML-master/incremental/metrics/stream_metrics.py
import numpy as np from sklearn.metrics import confusion_matrix class _StreamMetrics(object): def __init__(self): """ Overridden by subclasses """ raise NotImplementedError() def update(self, gt, pred): """ Overridden by subclasses """ raise NotImplementedError() def get_r...
3,982
30.611111
82
py
RAML
RAML-master/incremental/metrics/__init__.py
from .stream_metrics import StreamSegMetrics, AverageMeter
60
19.333333
58
py
RAML
RAML-master/incremental/datasets/voc.py
import os import sys import tarfile import collections import torch.utils.data as data import shutil import numpy as np from PIL import Image from torchvision.datasets.utils import download_url, check_integrity DATASET_YEAR_DICT = { '2012': { 'url': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrain...
6,061
36.190184
128
py
RAML
RAML-master/incremental/datasets/cityscapes.py
import json import os from collections import namedtuple from matplotlib import set_loglevel import torch import torch.utils.data as data from PIL import Image import numpy as np import matplotlib.pyplot as plt from torchvision import transforms import cv2 class Cityscapes(data.Dataset): """Cityscapes <http://ww...
11,663
51.540541
168
py
RAML
RAML-master/incremental/datasets/utils.py
import os import os.path import hashlib import errno from tqdm import tqdm def gen_bar_updater(pbar): def bar_update(count, block_size, total_size): if pbar.total is None and total_size: pbar.total = total_size progress_bytes = count * block_size pbar.update(progress_bytes - pb...
3,804
29.198413
93
py
RAML
RAML-master/incremental/datasets/cityscapes_novel.py
import json import os from collections import namedtuple from matplotlib import set_loglevel import torch import torch.utils.data as data from PIL import Image import numpy as np import matplotlib.pyplot as plt from torchvision import transforms class Cityscapes_Novel(data.Dataset): """Cityscapes <http://www.ci...
8,742
48.39548
168
py
RAML
RAML-master/incremental/datasets/__init__.py
from .voc import VOCSegmentation from .cityscapes import Cityscapes from .cityscapes_novel import Cityscapes_Novel
114
37.333333
46
py
RAML
RAML-master/incremental/datasets/.ipynb_checkpoints/cityscapes-checkpoint.py
import json import os from collections import namedtuple from matplotlib import set_loglevel import torch import torch.utils.data as data from PIL import Image import numpy as np import matplotlib.pyplot as plt from torchvision import transforms import cv2 class Cityscapes(data.Dataset): """Cityscapes <http://ww...
11,663
51.540541
168
py