sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
81575f69bbca297d9650d80986abe7fa86312900b1b8bd8ac3fc675e7add28fa
Python
2,762
81
""" Configuration singleton for global access to Hydra configuration. This module provides a singleton pattern implementation for managing the application's configuration throughout the codebase. The configuration is typically initialized once at the start of training/evaluation scripts with a Hydra configuration obje...
d3095a56f3a121b9656cc6b89ea6654747a5f0fdfde2763ec299abae698aac8a
Python
2,769
80
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed # under the Apache License Version 2.0, see <https://www.apache.org/licenses/> # Script to strip outputs of Jupyter notebooks except for plots and prints so that there # are displayed nicely on the documentation website. import os ...
c8bc41c8332b13285b426bcbbf8dcbcda4b9acf039676d731ad70466bc146c11
Python
2,770
81
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed # under the Apache License Version 2.0, see <https://www.apache.org/licenses/> """Progress bar helpers shared by the samplers. Samplers that draw from a proposal, e.g. `accept_reject_sample` or SIR, show a progress bar of their own....
19a210e263e733dc39bb293806a8ecfb2ec6d0e6940172f906c387eca378d4fe
Python
2,771
68
import torch import torch.testing as testing # from selbstaufsicht.models.self_supervised.msa.modules import InpaintingHead, JigsawHead, ContrastiveHead from selbstaufsicht.models.self_supervised.msa.modules import InpaintingHead, JigsawHead def test_inpainting_head(): num_classes = 4 bs, S, L, D = 2, 3, 4, ...
2a130ba4c44d9dfe39e315879abd4b85ea0184a6f386abaa9a0f1f010fd2cdd3
Python
2,772
96
import logging import numpy as np import torch.utils.data as data from PIL import Image from torchvision.datasets import CIFAR10 logging.basicConfig() logger = logging.getLogger() logger.setLevel(logging.INFO) IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp') def accimage...
d46db3471214ce6fc2b2bb3624dc92549d12408057225aeeec9d0dea62b469b0
Python
2,773
64
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source...
45b704443bf9adefe380c0485d89d9a775d76d84194905581e7fb8ca89165a28
Python
2,777
72
""" subsample slices and shift the short axis and long axis slices """ import cv2 import numpy as np import random from scipy import ndimage from scipy.ndimage.interpolation import shift class ExpDtToSeg: """ Select Short axis image and convert the distance transform to binary mask. """ def __init__(...
949f423127c05c66addee7b1bf8d4b8b0e8c024879eed7edd0cd066a177d0488
Python
2,777
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
1f5e2dbed2808e705bee4fd0dbd3a28336fb1ea72ac18f09922f362ed330122e
Python
2,778
26
label_map = { "mfc_gparam_hj_forward11": {'legend': "MFC $g$-parameter 1D -> 1D", 'linestyle': '-', 'marker': 'o', 'xlabel': r"$x$"}, "mfc_gparam_hj_forward12": {'legend': "MFC $g$-parameter 1D -> 2D", 'linestyle': '--', 'marker': 'o', 'xlabel': r"$x$"}, "mfc_gparam_hj_forward22": {'legend': "MFC $g$-para...
083424259abd8a4ea77a200e35eddaba1d1017f637b68af7073a52a88d13c94b
Python
2,782
81
import utils import xml.etree.ElementTree import random import math # gate prospector rpc url prospector_url = 'http://192.168.100.101:8080/gwt/gate.prospector.rpc.ProspectorRpc/rpc' # Mimir Web Service mimir_service_url = 'http://192.168.100.101:8080/dcf68f8f-14b1-49e9-ab44-3380eec0a22f/search' mimir_ns = {'m': 'htt...
f0c20f6f3aebbfb8e5fef915811a0f489b5cf25a09862c78a1d2243ea8c1f732
Python
2,783
53
#! /usr/bin/env python # *********************************************************************************** # * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. * # * * # * Redistribution and use in source ...
e4af6b7e7af405c281a94a0ee7cad0afd5181834b31109db6f9c43671b301df8
Python
2,786
74
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch from mmdet.models.dense_heads import GFLHead def test_gfl_head_loss(): """Tests gfl head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad_shape...
164cb570031d1d8d5f37dc527fa79788bf69595c80e3ff298180a917245f621c
Python
2,788
81
import os import sys import numpy as np import h5py import scipy.io as spio import nibabel as nib import argparse parser = argparse.ArgumentParser(description='Argument Parser') parser.add_argument("-sub", "--sub",help="Subject Number",default=1) args = parser.parse_args() sub=int(args.sub) assert sub in [1,2,5,7] r...
9c170bc23b5a4db0782430756c597271b4a0e5105ec37c66c9711965bb4960b9
Python
2,789
73
import os import json import torch import sep.helpers.utils as utils import mir_eval import numpy as np from asteroid.metrics import get_metrics def get_items(curr_dir, denoise_gt=False): """ This is a modified version of the SpatialAudioDataset DataLoader """ # Load metadata with open(os.path.jo...
23a9b1be71c1bc0feefc7e2b287186f35a83d16e534be05b6bfafc362f3885f4
Python
2,790
105
import sys, signal import numpy as np import moderngl from PyQt5 import QtWidgets from PyQt5.QtWidgets import QOpenGLWidget from PyQt5.QtGui import QSurfaceFormat def make_qt_format(): fmt = QSurfaceFormat() fmt.setVersion(3, 3) fmt.setProfile(QSurfaceFormat.CoreProfile) return fmt class StimDisplay(...
ca3f61d981945c25dfd502f79fdf1b19d10b17f6d4c0721cb472c1967af6bd04
Python
2,792
65
import logging from fedml_api.distributed.fedavg_robust.message_define import MyMessage from fedml_api.distributed.fedavg.utils import transform_list_to_tensor from fedml_core.distributed.client.client_manager import ClientManager from fedml_core.distributed.communication.message import Message class FedAvgRobustCli...
18c0744b8ef0c3476785692f18d22ed0e247b954f026cd673a861a5dcc8d1e27
Python
2,794
71
# Same structure as pre-trained network for transfer learning | standard learning # Created: 5/22/2021 # Status: OK # CUBLAS_WORKSPACE_CONFIG=:4096:8 python cnn_main.py # Consider merge into 1 main file import sys import torch sys.path.insert(1, '../plot/') from networks import CNN_Wrapper from utils import read_json ...
92452154808d18b18140e6fe5a3df323f5f74c8b05865e4549d61c9478e07d89
Python
2,794
94
# Copyright (c) OpenMMLab. All rights reserved. import os from argparse import ArgumentParser import mmcv from xtcocotools.coco import COCO from mmpose.apis import (inference_mesh_model, init_pose_model, vis_3d_mesh_result) def main(): """Visualize the demo images. Require the json...
b7d2e26908ace10735a63f9dda7b79cd2e741e1e7ff440ba9dc9091c35784f0b
Python
2,795
111
import numpy as np import pandas as pd import datetime import time from model import Net1 import torch.optim as optim from scipy import io import argparse import os # nn.BatchNorm2d(2,affine=False), import torch from torch import nn from torch.utils.data import Dataset, DataLoader import h5py impor...
305d873050377630fde4c54f1c1292f0d0a186a1ace8399b4eb93b2ff6237832
Python
2,797
71
import pycroscopy3D as pycro import multipagetiff as mtif import logging import argparse import os import sys from . import utils defaults = dict(size_tolerance=0.7, expected_size=[-1,-1,-1]) def main(*args, **kwargs): parser = argparse.ArgumentParser(description="Calculate an average psf from \ a stack c...
e2b8ab22e74ceaf06848660c59944881eea0c258e387238b90f8af565842e897
Python
2,799
74
import sklearn.model_selection import numpy as np from sklearn.model_selection import ShuffleSplit, StratifiedShuffleSplit, cross_val_score, StratifiedKFold def normal(X, labels, test_size): """Split a dataset into training and test parts. Args: X (numpy.ndarray): 2D features matrix ...
f84c0746453fd12d53eb1262dd52e73ed5a497db7caee2a01912bed766983172
Python
2,801
88
import sys sys.path.append('versatile_diffusion') import os import PIL from PIL import Image import numpy as np import torch from lib.cfg_helper import model_cfg_bank from lib.model_zoo import get_model from lib.experiments.sd_default import color_adjust, auto_merge_imlist from torch.utils.data import DataLoader, Data...
0e57ab268d39459d7d28d756cff8162652410592a5ca2d3eb903daa9f6e628c4
Python
2,805
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
22d25ef418f49e72b522b5e7a8a1703a9ee021e7405278b3208333c77c68cea2
Python
2,805
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
68629245f6c758931f91439d57f79f3450f3c546a4bd578e195e79a39539f0af
Python
2,805
100
from .gradient_descent_base import L1BaseGradientDescent from .gradient_descent_base import L2BaseGradientDescent from .gradient_descent_base import LinfBaseGradientDescent from ..models.base import Model from ..criteria import Misclassification, TargetedMisclassification from .base import T from typing import Union, A...
07b3ef2a37760de04c39d17b1723c6d3f4f2d2954fe36a85e55e66510d9d6670
Python
2,806
84
"""test_advanced_activation_layers.py This file is part of the test suite for keras2c Implements tests for advanced activation layers """ #!/usr/bin/env python3 import unittest import tensorflow.keras as keras from keras2c import keras2c_main import subprocess import time import os from test_core_layers import build_...
d3c400bd984c292c570e1ccf74d2c2dbdb45ebcc0526a8ecd937cdcdc1a808a4
Python
2,807
85
import torch import numpy as np from graphrepr.config import csv_section, optimizer_section from graphrepr.data import load_data_from_df from graphrepr.chemprop.data_utils import filter_invalid_smiles from graphrepr.chemprop.data_data import MoleculeDatapoint, construct_molecule_batch, MoleculeDataLoader def load_d...
918dfb287961e1d28d89d61dacfe9eb02b7aa696c9140213bcf6a90e301f0123
Python
2,812
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
f7c6e9f679fd6ca9ba7d9da951a447210554807f2bb0b094bfb6ff8601325967
Python
2,812
80
"""IUPAC ambiguity definitions and helpers used during alignment analysis.""" from collections.abc import Iterable NT_RESOLVED_STATES = frozenset("ACGTU") AA_RESOLVED_STATES = frozenset("ACDEFGHIKLMNPQRSTVWYOU") # Nucleotide ambiguity definitions use T internally. For RNA-only alignments, # ``ambiguity_map`` substit...
a3f7291d1127b306e3420c59fba8ce0cd93063ba3a49861724f0265c36ca98e3
Python
2,813
77
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
c6ae0618e906977248703201b689765e1a3b6a225a2f6441d68b5c38c42ced81
Python
2,814
64
#!/usr/bin/env python3 from flystim.stim_server import launch_stim_server from flystim.screen import Screen, SubScreen from flystim.trajectory import Trajectory import numpy as np from flystim.draw import draw_screens from time import sleep def main(): subscreens = [SubScreen(pa=(-0.1, 0.2, -0.1), pb=(0.1, 0.2, -...
31a9fa318109e9d4dfdd1d573bb16e10bb76b6eec4def3f0db8169fa896ded4a
Python
2,819
66
# -*- coding: utf-8 -*- """ Created on Fri Jun 11 19:45:55 2021 @author: fhu14 Updates the targets of the underlying molecules based on the output results from the DFTBlayer for a single feed. These methods should be invoked during the training loop process when information is being fed through the DFTB layer """ ...
3fa0fe7723a28243e7bace1fc89617b5e897e25cb5d6390f7a2abde62f13fd89
Python
2,819
82
import numpy as np import trefide.extras.noise_estimator as noise_estimator #import trefide.extras.spatial_filtering as spatial_filtering import trefide.extras.tool_grid as tool_grid import time #from trefide.utils.noise import estimate_noise # ____________________________ # Wrapper to call denoisers # see individ...
bb462c405b08b89e5e204c6f3a1a67225711387505eef896fcb1572c32e8a6f3
Python
2,821
86
# Copyright (c) OpenMMLab. All rights reserved. import copy from abc import ABCMeta, abstractmethod import numpy as np from torch.utils.data import Dataset from mmpose.datasets.pipelines import Compose class GestureBaseDataset(Dataset, metaclass=ABCMeta): """Base class for gesture recognition datasets with Mult...
ee1e5e442de3b7ab70c9758f74c89a653a7dd93f4efc42fe1c81caa7869148bb
Python
2,822
77
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
3fec3a774b92e328df500fb8b02284a1b2a11cfd11923a042452bd17ffd0dbc9
Python
2,828
77
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
c5b18c9ef45ba7d35f3d53857ce7e3167144a05c37f753d615093fd063b0b02d
Python
2,829
79
import sys import os import requests from zipfile import ZipFile def __convert_size(size_in_bytes, unit): """ Converts the bytes to human readable size format. Args: size_in_bytes (int): The number of bytes to convert unit (str): The unit to convert to. """ if unit == 'GB': return '{:....
bb77c23ea07373b94978fb909929cbec8df9ffb517782afc8883c931939520c0
Python
2,833
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
738e031582565b80c7bbecb2ebe6ee1705f8486fc9f66dafc63312a4baec48ca
Python
2,834
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
f87f9c0b358d66958d23d92e952226abf603842bf7ea5b46c099e3e091981bb3
Python
2,834
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
9a85de67a617b4a2e0ee4e50c7796cf59b42238712a6fdea1a83458048fa7d8e
Python
2,837
103
import os import cv2 as cv from skimage.metrics import structural_similarity as ssim from skimage.metrics import peak_signal_noise_ratio as psnr import numpy as np import matplotlib.pyplot as plt np.random.seed(3) #2 img_ori_path = 'E:/Zhu/ETreg/paper/compareimg/synapse1206/myown/ori/' img_fine_path = 'E:/Zhu/ETreg/...
665cbb96842273e9af58afa29f4f16a69a3d4a563dbf8466d2977c5c18e140e6
Python
2,838
89
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed # under the Apache License Version 2.0, see <https://www.apache.org/licenses/> from __future__ import annotations from dataclasses import asdict import pytest from torch import Tensor, eye, zeros from torch.distributions import Mul...
2433ae32c7ca292fa71e6e8c7c13ce02c8ee67196852b304e99e88d37affb829
Python
2,840
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
4c17e9eb66c4e851b02f28bb7cbd56f8bcb0343df99931347bf0802d4de5bb05
Python
2,841
82
#!/usr/bin/env python3 from flystim.stim_server import launch_stim_server from flystim.screen import Screen, SubScreen from flystim.trajectory import Trajectory from math import pi, radians import matplotlib.pyplot as plt from flystim.draw import draw_screens from time import sleep def get_subscreen(dir): ''' ...
85a29de198b5567955cb5df43900c3f235306f0540b559d14d0e6cbe24b06248
Python
2,841
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
ed7f679fb4bd5242b08451cd65adf1199ac20e26fd4b8ae7aa903e3b69359f6c
Python
2,841
82
import numpy as np import pandas as pd import requests from ftplib import * import ftplib import wget import os import time import glob df = pd.read_excel('Download_List.xlsx') empiar_ids = df['EMPIAR_ID'] data_link = df['Data_Link'] gain_link = df['Gain_Link'] for i in range(len(empiar_ids)): #running for indiv...
242aa35c6e6692f53e6b7a438ad9eef6ba09994936ee35a0f3c38d12b6d5e2ef
Python
2,846
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
64d2aa6bfd973508aa2742f69970f1a295e35258afe1c65c71aeaf9bb0795f2c
Python
2,846
105
import numpy as np from daart import transforms def test_compose(): # motion energy -> zscore t = transforms.Compose([transforms.MotionEnergy(), transforms.ZScore()]) T = 10 D = 4 signal = np.random.randn(T, D) s = t(signal) assert s.shape == (T, D) assert np.allclose(np.mean(s, axis=...
64be843e74aed9dc91d5421db2cc7def889cd7f1898cc28e62838b1d0a3d958b
Python
2,847
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
a06bd537d1f630e59c5eb504a7be5b6e5c9dd9cc9c33c9506bc4bda71f9fc77a
Python
2,847
76
import sys sys.path.append("..") import math import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Parameter from metrics import calculate_kl as KL_DIV from ..misc import ModuleWrapper class BBBLinear(ModuleWrapper): def __init__(self, in_features, out_features, bias=True, prio...
83c741fa9348045d9b580ca3349be2421e013205d973da05daa590f332c52a08
Python
2,848
85
#format CNVnator output ##CNV_type coordinates CNV_size normalized_RD e-val1 e-val2 e-val3 e-val4 q0 #deletion 10:43698001-43698700 700 0.302088 0.0409004 5.72382e-13 1 1 0 import re import sys import os if len(sys.argv) != 3: print "Usage: <cnvnator ou...
8311720eb034b959e1cc84c9052bdae098d79bcb05ae398f8671880cd25a4322
Python
2,849
86
# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod import torch.nn.functional as F from mmcv.runner import BaseModule, force_fp32 from ..builder import build_loss from ..utils import interpolate_as class BaseSemanticHead(BaseModule, metaclass=ABCMeta): """Base module of Sema...
49795691f60ff52467772822e86493fec109619d71ebac9ce6dbc34057749b90
Python
2,851
78
import os import os.path as osp from ..config import parse_data_config, parse_model_config, parse_representation_config from ..config import utils_section, data_section, csv_section from ..data import load_dataset def get_all_subfolders(path, extend=False): subfolders = [folder for folder in os.listdir(path) if ...
a58074fc298d4d5cba9fb0f6021b97d25a96aa146f4bdd3dea5d3e04c76fca09
Python
2,860
116
''' Author: ---- Date: 2022-04-29 09:43:08 LastEditors: GhMa LastEditTime: 2022-09-20 14:35:41 ''' import torch import torch.nn as nn import numpy as np import math def heaviside(x: torch.Tensor): return (x >= 0.0).to(x) class StochasticST(torch.autograd.Function): r""" default noise type: gauss...
a8b5db657454992c1d196d3fa2dce37a908391e7bbccbba638f3f71ac3998f63
Python
2,860
106
import pytest import numpy as np from daart import transforms def test_compose(): # motion energy -> zscore t = transforms.Compose([transforms.MotionEnergy(), transforms.ZScore()]) T = 10 D = 4 signal = np.random.randn(T, D) s = t(signal) assert s.shape == (T, D) assert np.allclose(np...
cebbe14cf35881c930017283dd5e015556fd675feb9a8ae3e60251bd53c53e46
Python
2,868
70
# Copyright (c) OpenMMLab. All rights reserved. from ..builder import DETECTORS from .faster_rcnn import FasterRCNN @DETECTORS.register_module() class TridentFasterRCNN(FasterRCNN): """Implementation of `TridentNet <https://arxiv.org/abs/1901.01892>`_""" def __init__(self, backbone, ...
925bb8d403c44ad8bab0b9a7de86b940a8165f4b824a1b8beda9cf772fe38b26
Python
2,869
86
import math import torch from torch import nn from pybrid import utils class Layer(nn.Module): def __init__( self, in_size, out_size, act_fn, use_bias=False, kaiming_init=False, is_amortised=False ): super().__init__() self.in_size = in_size self.out_size = out_size sel...
b998a62423d135ecc53fda5503c17dc65dfd5dc4c1ceedc0dd2e5c66de80c4be
Python
2,871
65
from pathlib import Path import sys root_dir = Path(r'') git_dir = Path(r'') for i in [str(root_dir), str(git_dir)]: sys.path.insert(0, i) class Project(object): def __init__(self, root, raw_data_dir): self.root_dir = root self.rdata_dir = raw_data_dir self.data_dir = root / 'data' ...
1fd1733b3c3175097c5e1f512cde642120f1137786d9d74a7f9fa0b0d4144ba9
Python
2,875
79
# Copyright Universitat Pompeu Fabra 2020-2023 https://www.compscience.org # Distributed under the MIT License. # (See accompanying file README.md file or copy at http://opensource.org/licenses/MIT) import torch as pt from tempfile import TemporaryDirectory from torch_geometric.loader import DataLoader from torchmdne...
42da9cce4103c98c90b3d63c7bc58df001dc726c0331c6ab790e956f9d769066
Python
2,875
79
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
cf02277d77ca79ea9ea34f41d78167e7ab02b296fadadef2fd12224a5c51ce18
Python
2,875
97
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 16 15:35:32 2020 @author: bariskuru """ '''poisson noise for variable max firing rate for grid cells''' import seaborn as sns, numpy as np import os from grid_poiss_input_gen import inhom_poiss from grid_trajs import grid_population, draw_traj imp...
dd4bdf99576281caeabbf5185f8b56e2b850e614ffaa11dfeb0354830ed9ac07
Python
2,875
138
#!/usr/bin/python # -*- coding: UTF-8 -*- """ ``sg.py``: Routines for Savitsky-Golay filtering """ import numpy as np def SGOrd(m,fc,fs): ''' Compute polynomial order for Savitsky-Golay filter Fc = (N+1)/(3.2M-4.6) For fixed M, Fc N = Fc*(3.2M-4.6)-1 Parameters ---------- m ...
5ce618266cc11e035543820ed11b8e5a9f1ce7fa57d697e55665f1a6f73e2fb2
Python
2,877
111
''' Author: ---- Date: 2022-06-30 11:22:52 LastEditors: GhMa LastEditTime: 2022-09-20 14:35:24 ''' import torch import torch.nn as nn import torch.distributions as distrib import numpy as np import math def heaviside(x: torch.Tensor): return (x >= 0.0).to(x) class StochasticST(torch.autograd.Fun...
9eb4f0cf80f679586071c5a02ccdce7179c40f98fbfec9cf1cb0edead6b8668c
Python
2,879
70
# Copyright (c) 2020-present Joindbre.com # Authors: Patricia Maraver. # # This program is free software: you can redistribute it and/or modify # it under the GNU Affero General Public License version 3 # as published by the Free Software Foundation. # You should have received a copy of the Server Side Public Lic...
1267c1e664cb63bbf5dc570ceae3ba40f17a5314f4130ed4a9427a5870bfc6bb
Python
2,884
79
from numpy import linalg as la from sklearn.preprocessing import normalize from utils import graph_to_adj import math import numpy as np import scipy.sparse as sp # For dynamic loading: name of this method should be the same as name of this python FILE. def grarep(ctrl, graph): '''Use GraRep as the base embedding...
e4bdfce6f8e385e4d91dc2d7f1b769ae7fce82da62fac2f4347d12d1b69139c1
Python
2,884
88
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np def bbox_xyxy2xywh(bbox_xyxy): """Transform the bbox format from x1y1x2y2 to xywh. Args: bbox_xyxy (np.ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, right, bottom, [score]) Returns: ...
75f66c875c1e9e6065f8bbdf8d17c01108181bcb23346c33eb1cbeba2f8910b4
Python
2,885
68
import opuslib import torch import numpy as np class OpusCodec(): """ Runs Opus compression with the same parameters used on each of the robots """ def __init__(self, channels, sr, frame_width=0.02) -> None: self.channels = channels # Initialize encoder self.encoder = ...
b8ed57faf63bf433cbeb1ab020baf9691fb13dc598b0d6278f5583afa659c853
Python
2,886
68
import logging import torch from torch import nn from fedml_api.distributed.turboaggregate.utils import transform_tensor_to_list class TA_Trainer(object): def __init__(self, client_index, train_data_local_dict, train_data_local_num_dict, train_data_num, device, model, args): self.client...
e761e4a0c4e5e13291d4ed77e6aa852da9c319c500f5f6e5b0a6d4db6348f609
Python
2,889
69
import setuptools import pathlib ## build with python setup.py bdist_wheel ## upload to testpypi w/ python3 -m twine upload --repository testpypi dist/* here = pathlib.Path(__file__).parent.resolve() with open(here / "README.md", "r") as fh: long_description = fh.read() with open(here / "requirements.txt", "r...
4f184a4a33f3772f357def1372196a423edc98836f0d5f156dd659f40894d577
Python
2,890
91
# -*- coding: utf-8 -*- """Process the outputs and generate ROC""" __author__ = "Sean Benson" __copyright__ = "MIT" from dtor.utilities.utils_stats import stats_from_results import numpy as np import argparse import torch from dtor.utilities.utils import set_plt_config from dtor.utilities.model_retriever import load_...
0f1fcabd04a66855c0e0cbe402bc7f36e32b5f8a470ae3d5cb53844e1af31e1a
Python
2,891
104
import copy import torch from daart.models import Segmenter from daart.models.tcn import DilatedTCN def test_tcn(hparams, data_generator, check_batch): hp = copy.deepcopy(hparams) hp['backbone'] = 'dtcn' hp['variational'] = False model = Segmenter(hp) model.to(hp['device']) # load the corr...
96f8b5cbf9456a05c7ac492a423369f3e1c605b2cd56effaa13afc7ac17e2a9a
Python
2,891
99
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from torch.nn.modules import GroupNorm from torch.nn.modules.batchnorm import _BatchNorm from mmpose.models.backbones import ViPNAS_MobileNetV3 from mmpose.models.backbones.utils import InvertedResidual def is_norm(modules): """Check if i...
565d3b0a2ce05e50dca78c1479bf742f887676b41911f9a067083bfcc238fe5f
Python
2,892
83
""" Converts dictionaries from h5 files and back. """ import numpy as np import h5py import os class h5_handler(object): @classmethod def save_dict_new_h5(cls, dic: dict, dest: str): r"""Entry point to turning a dictionary to an h5 file Arguments: dic: The dictionary to be sa...
2070001c6733645a0a559b3cb2dedd5d2b532af5816745c655f420a4182a441b
Python
2,895
91
import subprocess import sys from pathlib import Path import pytest from clipkit.clipkit import main def _run_clipkit(*args, **kwargs): cmd = [sys.executable, "-m", "clipkit"] + list(args) return subprocess.run(cmd, **kwargs) class TestEntrypoint(object): def test_help(self): result = _run_cli...
6b2000b2291e449ebf34a2926a9f154defdf0534fa77920495a9d5eee89bb67f
Python
2,898
81
# These are to prevent bad matrix exponentiations var.PIVEC_MIN = 1.e-7 var.RATE_MIN = 1.e-7 var.BRLEN_MIN = 1.e-6 var.GAMMA_SHAPE_MIN = 0.1 # You may be doing more than one run, and if so you will want to set # the runNum arg when you instantiate the Mcmc object below. I have # runNum=rNum below. If you are using t...
b86c98d08d36038dba34d6f926fa51b2bae0b3f9af262f1d13f602790a39bbd1
Python
2,899
111
''' Author: ---- Date: 2022-06-30 11:22:52 LastEditors: GhMa LastEditTime: 2022-09-20 14:35:24 ''' import torch import torch.nn as nn import torch.distributions as distrib import numpy as np import math def heaviside(x: torch.Tensor): return (x >= 0.0).to(x) class StochasticST(torch.autograd.Fun...
d2c4e5dfec83838035ccf13989777669a73f1dad83a10638f2b39bee5a9f2dfd
Python
2,906
76
''' Script for plotting predicitons plot all 5 folds of complete training data and validation https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html ''' import numpy as np import pandas as pd import csv import scipy import pickle from sklearn.ensemble import RandomForestR...
1abbbe4535052cd89b644b0871fa3bc9a139063ecee8e92c8c15d7efcd0a70ab
Python
2,908
80
# Copyright (c) OpenMMLab. All rights reserved. import copy import torch.nn as nn from mmcv.cnn import ConvModule, Scale from mmdet.models.dense_heads.fcos_head import FCOSHead from ..builder import HEADS @HEADS.register_module() class NASFCOSHead(FCOSHead): """Anchor-free head used in `NASFCOS <https://arxiv.o...
d22bfe8ce41d005f355e6ee26067c29974953bbb03b259da368a79fd8d436a62
Python
2,911
111
import sys, signal import numpy as np import moderngl from PyQt5 import QtWidgets from PyQt5.QtOpenGL import QGLWidget from PyQt5.QtOpenGL import QGLFormat def make_qt_format(): fmt = QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QGLFormat.CoreProfile) return fmt class StimDisplay(QGLWidget): d...
ad5f6a3b220c646c70ad9d683131c2fde7ab5a705e3c9471b8e95c470361ae70
Python
2,912
85
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 16 15:35:32 2020 @author: bariskuru """ '''poisson noise for variable cell number for grid cells''' import seaborn as sns, numpy as np import os from grid_poiss_input_gen import inhom_poiss from grid_trajs import grid_population, draw_traj import ...
ae7f94bc7c60ca2cfb30536308916ef6b5c6340ede3b33da8f999d2ef5ec8d41
Python
2,912
88
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def knowledge_distillation_kl_div_loss(pred, so...
919f1951c4c9af04e9751cf0e680246e96c138242fcaf492be8eac7444441863
Python
2,915
88
#!/usr/bin/python # -*- coding: UTF-8 -*- """ Matplotlib and numpy configuration """ # Relative import regardless of file nesting depth import os, sys path = os.getcwd().split(os.sep) while len(path) and path[-1]!='notebooks': path = path[:-1] sys.path.append(os.sep.join(path[:-1])) datadir = os.sep.join(path[:-2]+['e...
58b6c5b12c19f6361a3eb8950d96212549cd91e056a59addfbda4773848c0737
Python
2,917
67
import argparse def main(args): import json import torch from .dataset import worker_init_fn, get_pdbs, loader_pdb, build_training_clusters, PDB_dataset data_path = args.path_for_training_data params = { "LIST" : f"{data_path}/list.csv", "VAL" : f"{data_path}/valid_clust...
754f2aae629b43d80870cb0eff2c5e0ca8124d79521ed102aa75372639432411
Python
2,917
78
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
af2089053ba675c7fa42eefa4d191ec7859a5a63be49c2e7bf74e574caa2fe3a
Python
2,917
78
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
8b90d6d7e33e1ffdc7bb1998b1fbfe4cf3ab0d5a05e6f44a45003624dc6cab30
Python
2,919
80
# Copyright (c) OpenMMLab. All rights reserved. import argparse import mmcv from mmcv import Config, DictAction from mmdet.datasets import build_dataset def parse_args(): parser = argparse.ArgumentParser(description='Evaluate metric of the ' 'results saved in pkl format') ...
aac6b52d8c9b83d17faa7e9b72aa47fb3fcf1e1940422fe8e6c616e1d48a0c7c
Python
2,920
102
import numpy as np """ Adapted from UniTVelo (Gao et al. 2022, bioRxiv) Selects a set of genes to regularize in gene-space """ def get_weight(x, y=None, perc=95): from scipy.sparse import issparse xy_norm = np.array(x.A if issparse(x) else x) if y is not None: if issparse(y): y = y.A...
d635f19c66fc1816e4d6c7f1aa10e8042ad0ad1978ed76e474c681e3ead2277e
Python
2,920
72
import utils import sqldbutils as dutil import json # query concept sql autoimmune_concepts_sql = """ select distinct concept_name from [SQLCRIS_User].[Kconnect].[ulms_concept_mapping] """ # query patient sql patients_sql = """ select brcid, primary_diag, diagnosis_date, dob, gender_id, ethnicitycleaned from [SQLCRIS...
b76e448b692efc7e43f9440fc377baa9e890dcd92549c152fc7edf37d126b1e9
Python
2,921
102
import math import os import re import subprocess import tempfile from concurrent.futures import ThreadPoolExecutor from shutil import which def count_sequences(file): n = 0 with open(file) as fin: for line in fin: if line.startswith(">"): n += 1 return n def run_prod...
417be3ffdd4ccd85b7d8d5180f975bb48afada0821bdf3729e4b931e77d57d16
Python
2,922
103
import math import os import re import subprocess import tempfile from concurrent.futures import ThreadPoolExecutor from shutil import which def count_sequences(file): n = 0 with open(file) as fin: for line in fin: if line.startswith(">"): n += 1 return n def run_prod...
aaffa5725da6e370bbe771765357aef8697bdd9e976182f7d030eeac22e7c051
Python
2,922
76
from copy import copy, deepcopy from transformers import TrainingArguments import os from os.path import join from model.torch_models.bert_cnn import CNN_Over_BERT training_splits = [0,1,4,6,7,9] number_reports = [11182,7382,2897,1214, 865, 453 ] number_patients= [884,592,214,103,68, 35 ] filename = os.path.basenam...
617b4b70cfc5458e4ff4a3f12b35e26a6ab049a8af7f987be525da6ae4f191a1
Python
2,925
81
import numpy as np import random from scipy import ndimage, misc class RotationTransformBase(SpatialTransformBase): """ Rotation transformation base class. """ @staticmethod def get_rotation_transform(dim, angles): """ Returns the sitk transform based on the given parameters. ...
687985d7aa93217e8f89f307a405009eb821b656b122695677fab48b042444d7
Python
2,925
85
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import PLUGIN_LAYERS eps = 1e-6 @PLUGIN_LAYERS.register_module() class DropBlock(nn.Module): """Randomly drop some regions of feature maps. Please refer to the method proposed in...
1f5f32b3517253c133dac46e359277a779a65a872ee74af476ed9708bf0123c8
Python
2,927
91
import numpy as np import pytest from daart.eval import get_precision_recall, run_lengths def test_precision_recall(): # basic binary test: perfect predictions T = 20 true = np.zeros(T,) pred = np.zeros_like(true) pr = get_precision_recall(true, pred, background=None) assert pr['precision'] ...
90fcf6f9e8ee7d4b4e34aa056b0119382f50bd7f835940406b6c775f3b91352a
Python
2,930
93
import argparse import os import shutil UTT_PREFIX = "natsume" DEV_LIST = ["9", "22", "38", "43", "44"] TEST_LIST = ["2", "13", "24", "25", "27"] def train_check(song): return (song not in DEV_LIST) and (song not in TEST_LIST) def dev_check(song): return song in DEV_LIST def test_check(song): return ...
20194066e7b9680e6adff8d828cdf529f6fa6945b4cb924aff4fae6ffa2a1fc7
Python
2,931
93
from unittest.mock import patch import torch import torch.nn as nn import torch.nn.functional as F from mmdet.models.utils import AdaptiveAvgPool2d, adaptive_avg_pool2d if torch.__version__ != 'parrots': torch_version = '1.7' else: torch_version = 'parrots' @patch('torch.__version__', torch_version) def te...
61443af230a6d385544226ec22222fa8e988aa87e91c788d01c14c3bc388a490
Python
2,931
71
import os import sys import time import json import shutil import logging def save_history(train_loss, valid_loss, fold_subdirectory): """saves model history in fold_subdirectory""" timestamp = time.strftime('%Y-%m-%d-%H-%M') # casting to float because float32 is not JSON-serializable hist = {'train':...
7f58b23ebb29d8877ae7e9b4d19b298a8c8c8625fc12cf29336dbfa6eef799d9
Python
2,933
72
import numpy as np import cv2 from havoc_clustering_v2.general_utility.tile_image_utils import TileUtils # from general_utility.tile_image_utils import TileUtils class ImageCreator: def __init__(self, height, width, scale_factor=1, channels=3): ''' Creates an image of the specified size except ...
6727009735bbcd9c3de78b67e72cdbebea5451096719bd06289061ea43357b32
Python
2,935
72
import json import os from torchvision import datasets, transforms from torchvision.datasets.folder import ImageFolder, default_loader # for imagenet from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from med_dataset.dataset_lngrowth import LnGrowthDataset # #for fundus # IMAGENET_DEFAULT_M...
90d8d39104994784140c3372850bdb710712ad735a099b89395f7d89a98303d2
Python
2,935
92
""" Generate per-channel sleep stage logits (raw model outputs). This script runs inference on a dataset and saves the raw logits (pre-softmax outputs) for each recording and channel combination. Unlike predict-high-freq.py, this preserves the full probability distribution rather than just the predicted class. Usage:...