sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
e6faaf7e4240e56fab1e683904ec251eaa143fe46cb914f906fd0f95590ab1fc
Python
2,578
68
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 27 17:56:04 2020 @author: bariskuru """ import numpy as np from elephant import spike_train_generation as stg from neo.core import AnalogSignal import quantities as pq from scipy import interpolate def inhom_poiss(arr, n_traj, dt_s=0.0001, speed_c...
2c642713aafb4f48d7c20e5702aa684ac7d408d883a8efa8b3e3b0ea3b45b5e6
Python
2,579
61
# 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...
ab8458a167a19b4bd5e1ab8ba8e1eafbdd59b89c04e6ef596e8395aab2758153
Python
2,581
68
import numpy as np import os import pandas as pd import pathlib import SimpleITK as sitk import argparse from imutils import paths from dtor.utilities.utils import image_search, bbox3d, crop3d parser = argparse.ArgumentParser() parser.add_argument("--labels", type=str, help="Location of labels", default="data/external...
c7107008fd293efd986a54cd9d79e51768d2cd2cccb14278c63fefa2a6023f7a
Python
2,587
80
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.runner import BaseModule, auto_fp16 from mmdet.models.backbones import ResNet from mmdet.models.builder import SHARED_HEADS from mmdet.models.utils import ResLayer as _ResLayer @SHARED_HEADS.register_module() class ResLa...
b6f56ada2bf0e6a4ddad65924547bff94a7ae2f8e39a223a72b81f53c680b44f
Python
2,592
77
# Copyright (c) OpenMMLab. All rights reserved. # Code is modified from `HRNet/DEKR <https://github.com/HRNet/DEKR>`. import torch from mmcv.runner import load_checkpoint class DekrRescoreNet(torch.nn.Module): """Rescore net used to predict the OKS score of predicted pose. We use the off-the-shelf rescore ne...
1a555fa29414dfe6b7f33c8afdfa4483ba6b72132796b207634d64702f849224
Python
2,593
49
import cv2 import xml.etree.ElementTree as ET import os from pathlib import Path import numpy as np import random # 原图片、标签文件、裁剪图片路径 img_path = r'D:\Tuo\yolov5-cell\detect\output\image' xml_path = r'D:\Tuo\yolov5-cell\detect\output\detect_xml' obj_img_path = r'D:\Tuo\yolov5-cell\detect\output\split' # 声明一个...
9ac9a3521075d8ce598ac7a5f31663e27ec2be47f19c50f2090ef20dac589fe0
Python
2,595
69
import os import sys import csv import logging import subprocess import glob import torch import numpy as np import pandas as pd import importlib from collections import OrderedDict from timm.utils import get_state_dict def save_best_model(model, model_ema, optimizer, lr_scheduler, epoch, loss_scaler, trained_epochs...
9365ab7f42a88feba5a02717a456b380d59b178501fec34d8309b2b2c5e1780a
Python
2,603
84
import numpy as np import torch import matplotlib.pyplot as plt plt.switch_backend('agg') def adjust_learning_rate(optimizer, epoch, args): # lr = args.learning_rate * (0.2 ** (epoch // 2)) if args.lradj == 'type1': lr_adjust = {epoch: args.learning_rate * (0.5 ** ((epoch - 1) // 1))} elif args.l...
9ac07178f2ce6cce97eefaf0b0f8ec3ab33c8d268ac58bd094331479f8fcb498
Python
2,604
87
import pytest import torch import lightning as pl from torchmdnet.models.model import create_model from utils import create_example_batch def _make_args_tensornet2(static_shapes): return { "model": "tensornet2", "embedding_dimension": 128, "num_layers": 2, "num_rbf": 32, "...
b162b2b70ae5de813c65de65b3f7e5934d2a5d4490dd198e570abbf1e8a2e038
Python
2,608
83
# Copyright (c) OpenMMLab. All rights reserved. """Tests for async interface.""" import asyncio import os import sys import asynctest import mmcv import torch from mmdet.apis import async_inference_detector, init_detector if sys.version_info >= (3, 7): from mmdet.utils.contextmanagers import concurrent class ...
e3b84655f8f3d210d941b2062a9a547aa323cbfc9a68394bb92dcace1f8d591c
Python
2,612
50
# 导入模块 import cv2 import xml.etree.ElementTree as ET import os from pathlib import Path import numpy as np import random # 原图片、标签文件、裁剪图片路径 img_path = r'D:\Tuo\yolov5-cell\detect\output\image/' xml_path = r'D:\Tuo\yolov5-cell\detect\output\detect_xml/' obj_img_path = r'D:\Tuo\yolov5-cell\detect\output\split/...
6be3e2863f49328127a160cd19c3c2f5093d287510afa76b0b74ccb467a6d5da
Python
2,614
110
#!/usr/bin/env python import sys from optparse import OptionParser def interval_to_bedpe(size, call, sv_type, i): half = size/2 chrom,interval = call.split(':') start,end = [int(x) for x in interval.split('-')] length = end-start bedpe = '\t'.join([chrom, str( max(1,start-hal...
91c21fe6a99bc805338c4d53ac99af3ea6faae417931d1b4645f6705ac4df289
Python
2,614
69
import numpy as np from matplotlib import pyplot as plt import tensorflow as tf import argparse from utils import log_1px_transform, siren_model, scheduler if __name__ == "__main__": argparser = argparse.ArgumentParser(description="Train ML model with specific hparams") argparser.add_argument("--lr", type=fl...
b945089b8b98ce97fd7a86601c748ae2f539d55e22a637010aba4742ae2e78dc
Python
2,620
69
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 27 17:56:04 2020 @author: bariskuru """ import numpy as np from elephant import spike_train_generation as stg from neo.core import AnalogSignal import quantities as pq from scipy import interpolate def inhom_poiss(arr, n_traj, dt_s=0.0001, speed_c...
a3c1decc0e363dfda193cb836a29b3c5b592314aabe7408533c0327a9c7f7100
Python
2,622
83
import pytest from binn import BINN, Network import pandas as pd import torch @pytest.fixture def binn_model(): input_data = pd.DataFrame({"Protein": ["a", "b", "c"]}) pathways = pd.DataFrame( {"source": ["A", "B", "C"], "target": ["path1", "path1", "path2"]} ) translation = pd.DataFrame( ...
38d6b1fc864115ad89267d9c738e3c10b16211a13e9c48b13cbe77dfc1eb84c6
Python
2,623
40
#! /usr/bin/env python # *********************************************************************************** # * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. * # * * # * Redistribution and use in source ...
5cf0c342c0a958ffd04febc6f5cef096317913f0eb052a6529f9d0a1cbe02d3c
Python
2,626
73
from torch.nn import CrossEntropyLoss, MSELoss from transformers import BertModel, PreTrainedModel, BertConfig, load_tf_weights_in_bert from transformers.modeling_outputs import Seq2SeqSequenceClassifierOutput, SequenceClassifierOutput import torch from torch import nn import torch.nn.functional as F from model.bert_mo...
028bb6ea32ef099f8d68cd286ec09d96bac75f60e08f75ca9d43819bc6487826
Python
2,631
111
# 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 sbi.neural_nets.factory import ( classifier_nn, likelihood_nn, marginal_nn, posterior_flow_nn, posterior_nn, posterior_score_...
c9f5cecedc7bb5e1bd6a80232912710d211def03ab2ba4415e3f37a2dfc6f421
Python
2,635
76
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcv.cnn import is_norm from torch.nn.modules import GroupNorm from mmdet.models.utils import InvertedResidual, SELayer def test_inverted_residual(): with pytest.raises(AssertionError): # stride must be in [1, 2] Inv...
cbb8dae088a7646f654fc6bda6f17bf7c72ad3a79716fd52c15c96e60004ee7d
Python
2,635
74
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...
11d54fd63871e58f80c9186487b250432768bb4d3104cff79cb7381a39621a27
Python
2,637
87
#!/usr/bin/env python3 # Copyright 2020 Tomoki Hayashi # 2023 Jiatong Shi # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Variance predictor related modules.""" import torch from typeguard import check_argument_types from parallel_wavegan.layers.layer_norm import LayerNorm class VarianceP...
9b402a15f8ac8e3fd00b5478f80ed18dc97b81bea79af4c98d82c83c168379e6
Python
2,637
74
from typing import Union import torch from torch import Tensor from torch.distributions import Binomial, Distribution, InverseGamma from sbi.inference.potentials.base_potential import BasePotential from sbi.utils.torchutils import atleast_2d class BinomialGammaPotential(BasePotential): """Binomial-Gamma potenti...
ce254ef7ff02e3dcb55deb0107a7f6c44d9124ae15c88624fda45f30b30123b8
Python
2,638
91
import tensorflow as tf import tensorflow_datasets as tfds from tensorflow.keras.models import load_model from gradient_accumulator import GradientAccumulateModel from gradient_accumulator import unitwise_norm from tensorflow.keras import mixed_precision import os def normalize_img(image, label): """Normalizes im...
ceacac97b527947bdb7adbe97e554491996433965bfb4750f4853b2ee1eb82d3
Python
2,641
70
import plotly.graph_objects as go import os import colorcet as cc import pandas as pd import numpy as np from statistics.utilities import CONFIG from statistics.clustered_mlp_output_wrappers import load_adni_clusters, load_adni_ad_clusters def sankey_plot(cluster_to_cluster_map, label): fig = go.Figure(data=[go.Sa...
375cb3f99e88efaf589e6057932e103ca54958fc5831461e69d5685972e597fd
Python
2,643
77
import pandas as pd import numpy as np from utils.tools_processing import compute_distance_to_midline def calc_DFF(f, baseline): f0 = np.nanmedian(f[baseline[0]:baseline[1]]) dff = [(i - f0) / f0 for i in range(len(f))] return dff class Cell: dff = [] def __init__(self, exp, plane, cell, id): ...
a64f51d4d5d4ee008bbda105b12c20db205a94673cdc5d349dd65403983c3c7c
Python
2,643
66
# This script shows how to use a TorchMD-Net model as a force field in OpenMM # We will run some simulation steps with OpenMM on chignolin using a pretrained model. try: import openmm import openmmtorch except ImportError: raise ImportError( "Please install OpenMM and OpenMM-Torch (you can use cond...
6f1e65d4935b7798737c37febae886b715c1adf8bd3ed5c870a329670817ae5a
Python
2,646
91
#! /usr/bin/env python3.5 """ This is a sample script that programmatically controls OSC1Lite using the API """ import ok # The OpalKelly SDK, you may need to manually copy it to current folder import osc1lite # The OSC1Lite python interface import os # Enable debug logging import logging logging.basicConfi...
7bf6126c540fb42a8a1a933160e749105c21fa005cb62ca45150011441b81d8d
Python
2,647
68
import numpy as np import random from .common_func import flip class RandomFlip: def __init__(self, horizontal=True, vertical=True, training=True): self.horizontal = horizontal self.vertical = vertical self.training = training def __call__(self, sample): """ Randomly f...
d6f6c14874038158c53dbc4e3116e93d9e43dc78751485085b74f65f96d132e1
Python
2,649
94
# IMPORT STATEMENTS import cv2 import re import numpy as np import matplotlib matplotlib.use('agg') from matplotlib import pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size from mpl_toolkits.axes_grid1 import SubplotDivider, Size from mpl_toolkits.axes_grid1.mpl_axes import Axes import ma...
600189ac30ac70604e8bf2d4ca746cb20a2925141263f0aecbb3a79b7472c788
Python
2,651
47
from mpi4py import MPI from fedml_api.distributed.fedavg_robust.FedAvgRobustAggregator import FedAvgRobustAggregator from fedml_api.distributed.fedavg_robust.FedAvgRobustTrainer import FedAvgRobustTrainer from fedml_api.distributed.fedavg_robust.FedAvgRobustClientManager import FedAvgRobustClientManager from fedml_api...
bab653b9fb3436b425bb2c401ec4679190037e952632c5540d6f9e71228c4c08
Python
2,653
103
import pickle from pathlib import Path import torch from sbi.inference import SNPE, simulate_for_sbi from consbi.simulators import ( RuleSimulator, default_rule, ) from consbi.simulators.utils import get_batch_simulator, seed_all_backends seed = 42 seed_all_backends(seed) # set parameters BASE_DIR = Path(__...
dcba5061738c55956db2107be5da1e2064999c11d1dcd6d6adcf4946da2d1350
Python
2,653
67
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, ModuleList class ConvUpsample(BaseModule): """ConvUpsample performs 2x upsampling after Conv. There are several `ConvModule` layers. In the first few layers, ups...
0f85be3ec372badee562eab0685634e4a7658f3eb1be95921581c562ed30efac
Python
2,656
62
import pandas as pd from tqdm import tqdm import numpy as np import rdkit from rdkit import Chem from rdkit.Chem import rdMolDescriptors from rdkit.Chem import Descriptors from rdkit.Chem import AllChem from rdkit import DataStructs #Fingerprint generation #(@ming if we want to use inchi as an input, inch...
d72288ee347592a34880488c3541fdb1e626e3bc74ceaf1a9d10fd8048c63e3b
Python
2,656
76
import numpy as np import os import time as t import nibabel as nib from os.path import join, basename, dirname import re import matplotlib.pyplot as plt import ants import multiprocessing as mp import pandas as pd """ This class PREP is created to preprocess raw MRI images by 1. Normalization with ANTs. """ def regis...
f7226021526275014747e734788923abce8302e778d2272707aeeb26b725f067
Python
2,656
86
# -*- 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 from dtor.utilities.utils import set_plt_config from dtor.utilities.model_retriever import load_model from dt...
a2d523f04bdfbcc01d490a8f9d104194cfed83e843ff411a30eb1a1970d4be4d
Python
2,658
67
import h5py import torch.utils.data as data class StackOverflowDataset(data.Dataset): """StackOverflow dataset""" __train_client_id_list = None __test_client_id_list = None def __init__(self, h5_path, client_idx, datast, preprocess=None): """ Args: h5_path (string) : path...
59164a294c9153447656a6d4f137e994d8a51aa26f328c1b02964646b040f027
Python
2,663
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 ExpRandomShiftNaive: """ Subsample the 3D numpy [h, w, d] by slice max number. """ def __init__(self, random...
744f5f536f640582849b4205c7b3cd477b8a8463411a93a89d9ce2a59557b277
Python
2,664
84
import tensorflow as tf import tensorflow_datasets as tfds from tensorflow.keras.models import load_model from gradient_accumulator import GradientAccumulateOptimizer def normalize_img(image, label): """Normalizes images: `uint8` -> `float32`.""" return tf.cast(image, tf.float32) / 255., label def test_opti...
b2b82f2bfcc9f49e592500f635ca0240357be0913ad0f17db87b4c68af435e43
Python
2,664
101
""" Methods for loading test datasets. For information on test datasets, including sources (where available) see the documentation. One dataset, ``weblinks.hist`` is given as a histogram, not sampled data so we can't analyze it with this library. """ import numpy as np import os import pathlib from .plotting import...
81d25c624c5f681fe90ee7133b4e4706eaab4f3ed947937d6d85d79fcbe4182e
Python
2,665
74
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...
4ff5343bd6ec4f4cbcc053cc2ae04713eb85854aad96b19f8add3ec1044eec85
Python
2,667
58
import sys import glob import shutil import os import pandas as pd from pathlib import Path from F_post_processsing import F100_analyze_hindcast_output from A_config import a10_config import tuner import threading import manager_0_user_params as upar from manager_20_tune import monitor_condor_q if __name__ == '__main_...
809e5a2b927e865f308e1e0ab055332d85b62ea893e280a8460a33e2f06f74d1
Python
2,673
45
#! /usr/bin/env python # *********************************************************************************** # * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. * # * * # * Redistribution and use in source ...
00bc8807d771cef9f02570f4edb63d3aa638447f785e3e713f47ba74385fe701
Python
2,678
58
import pandas as pd import numpy as np import os import shutil """ Split Nigeria (Wet, sorghum and maize) in two items: mono and bimodal areas. Prepare Tuning data. Config must be adapted manually """ pd.set_option('display.max_columns', None) pd.set_option('display.max_rows', None) pd.set_option('display.expand_frame...
4cdca7fd7862448a3303342b35ac45c2252df22e7fd2a132050ebba8730c53e7
Python
2,678
50
# *********************************************************************************** # * Copyright 2010-2017 Paulo A. Herrera. All rights reserved. * # * * # * Redistribution and use in source and binary forms, w...
f300772c6ec88cb38752d7c366b70173adc4fd68ebaafc63ac43b9b8bb8ab946
Python
2,679
86
# Copyright (c) OpenMMLab. All rights reserved. import tempfile import numpy as np import pytest from mmpose.core import (imshow_bboxes, imshow_keypoints, imshow_keypoints_3d, imshow_multiview_keypoints_3d) def test_imshow_keypoints_2d(): img = np.zeros((100, 100, 3), dtype=np.uint8) ...
723483dd9238a8912d2876e61c46360dfed0ed4198d69f81b3974440c5403044
Python
2,684
65
import math import torch """ IMPORTANT NOTE: Piecewise functions can be a bit tricky in pytorch: If there are divisions by 0 in different branches of the piecewise definition, this can lead to nan values in gradients when automatic differentiation is used (even if the problematic branch should in theory not be evaluat...
bb72f40e80ff73367bf1c6ca17e7d41c40b63f17a25b92608784f5474366012c
Python
2,684
75
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...
dda9cad5dbf52d4178d997bbced540817b2ac3e9e7675994326be3f494eb4540
Python
2,684
54
import logging from fedml_api.distributed.fedgkt.message_def import MyMessage from fedml_core.distributed.client.client_manager import ClientManager from fedml_core.distributed.communication.message import Message class GKTClientMananger(ClientManager): def __init__(self, args, trainer, comm=None, rank=0, size=0...
543045dc18b824c978968790bce632bd61cc5a7649a7e38a63e972b43a89014f
Python
2,686
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...
a741a6075a1cca17519acfce05c1e61e9b4a7a5a793363dc0e99eccce0be9c2d
Python
2,688
81
import numpy as np from importlib import reload import sys sys.path.insert(2,'support') import functions reload(functions) import functions as f import parameters reload(parameters) import parameters as p import matplotlib import matplotlib.pyplot as plt direc_data = sys.argv[0].split('script')[0]+'data/' direc_fig = ...
0130868ded86d21bbd89106da78f1d0ac9531ad145f0fcb19c6cddec2ebffeb0
Python
2,691
97
import os.path as osp import numpy as np import numpy.random as npr import PIL import cv2 import torch import torchvision import xml.etree.ElementTree as ET import json import copy from ...cfg_holder import cfg_unique_holder as cfguh def singleton(class_): instances = {} def getinstance(*args, **kwargs): ...
d43307f290a6ca776b8f5dbdedadec4a84888f08637ce026f3f0a3b4dee04750
Python
2,694
76
# 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/> import pytest import torch from sbi.analysis import ActiveSubspace, conditional_corrcoeff, conditional_pairplot from sbi.inference import NPE from sbi.ut...
f2fbf21a972913f48a2fb09252fbea8f887fd40473eeb01d9233d876b1c78e7a
Python
2,694
78
# This program 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. # # This program is distributed in the hope that it will be usef...
14ea81310913a5fead7bfd51743ea75569535752c35cea7eb99453c2e2a22869
Python
2,695
78
####################################################################### # Software License Agreement (AGPL-3 License) # # OpenViBE SDK Test Software # Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015 # Copyright (C) Inria, 2015-2017,V1.0 # # This program is free software: you can redistribute it and/or modify ...
8a85c30fd3bb663e77af6931a5dc3c95985ff4d531e7b7e3a0d554769b4b1a73
Python
2,697
75
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...
939dcd354b64b30986f5beadfda8c1d7fecb384466bb703bf04415b8829417e7
Python
2,697
83
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmpose.models.backbones.swin import SwinBlock, SwinTransformer def test_swin_block(): # test SwinBlock structure and forward block = SwinBlock(embed_dims=64, num_heads=4, feedforward_channels=256) assert block.ffn.embed_dims ...
43f9b05c8e69bc79d22c228431e5201f303f62bad55cd72e14e74624c42d3824
Python
2,698
73
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: MIT # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without res...
40732a6b7b65f094108923b4608976ff282b3545102259d5c33d54ce6b40a5fa
Python
2,702
72
# -*- coding: utf-8 -*- """ Created on Mon Jun 7 20:09:22 2021 @author: fhu14 """ import numpy as np from scipy.spatial.distance import pdist, squareform from .util import TriuToSymm class Repulsion(object): def __init__(self, atomList, parDict): self._atomList = atomList self.__parDict = ...
baaa9a43bc1c85171c9efc9a58b0e8dc196cdd65a250b3b35d7a90dda0d74194
Python
2,703
62
import torch import torch.nn as nn import torch.nn.functional as F ##https://github.com/RaffaeleGalliera/pytorch-cnn-text-classification/blob/master/model.py class CNN(nn.Module): def __init__(self, vocab_size, embedding_dim, n_filters, filter_sizes, output_dim, dropout, hidden_dims): sup...
054ca0f016bd4c5ea5cf3e186538e85e9ef36d06872c2502576ccdc04d3b8b7c
Python
2,705
88
""" Generate per-recording confusion matrices for detailed error analysis. Used to create Figure 1a in our manuscript. This script runs inference on a dataset and computes a confusion matrix for each recording and channel combination, enabling fine-grained analysis of model performance across different subjects and ch...
00d3a6aac9d291bc051011f8d437538ed6325fc586bc9f72c9592c5fd67fe4c3
Python
2,712
57
# Copyright (C) 2023-2025 ETH Zurich, Marc Lehner and other DASH contributors. import pickle import os from typing import Sequence import argparse from serenityff.charge.utils import command_to_shell_file from serenityff.charge.tree.tree_utils import ( get_DASH_tree_from_DEV_tree, ) from serenityff.charge.tree_de...
bb37ae62ca73d2102f3d6fafe4c4d9d9f97423593fc8c43f9c11cbd27151e1f3
Python
2,716
76
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch from mmdet.models.dense_heads import YOLOFHead def test_yolof_head_loss(): """Tests yolof head loss when truth is empty and non-empty.""" s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'scale_factor': 1, 'pad...
b1750c5302a690ac57b8962c7545a9116d4a57b3e9b262c39eff4863a679316d
Python
2,718
83
import numpy as np import numpy.testing as testing import xgboost as xgb from selbstaufsicht.models.xgb import xgb_utils def test_sigmoid(): x = np.array([-np.log(42), 0, np.log(42)]) y = xgb_utils.sigmoid(x) y_ref = np.array([1/43, 0.5, 1 - 1/43]) testing.assert_allclose(y, y_ref) def te...
b8d2859198f6f7985cd9b66a359a75dac5c365424739a16773e6b42e99a8e6a2
Python
2,718
104
# Copyright (C) 2021 Grzegorz Chojnowski # EMBL-Hamburg import os,sys from setuptools import setup import setuptools import subprocess import distutils.log import distutils.command.build from distutils.command.install import install as DistutilsInstall from pathlib import Path from setuptools.command.build import build...
31e3f8bcf21ed3239300fa0cb481555e70f27985f6b59db8df903e55792c3de0
Python
2,719
97
#!/usr/bin/python """ Saving output files """ import numpy as np import pandas as pd from pathlib import Path import shutil # ----------------------------------------------------------------------- def save_best_model(path, pattern): """ """ best_dir = path / 'best_model' best_dir.mkdir(parents=True,...
178cd50aa084c360a1d88a2af3084f86a378675298676fe4a28fb07bee2691db
Python
2,720
112
import pathlib import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import backend from functions import * ############### #signal2 --> data1 predictions / lo #signal --> data2 ...
7ad2daa722980233d804a3deb0c0b28907bbf7e047c226dd2a4b02dab172e59e
Python
2,720
75
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...
212469dd52e1b110839dfa35635968a870ea3b2f5c82ec850ccea91e9f71e543
Python
2,721
94
# -*- coding: utf-8 -*- """ Created on Wed Jun 9 13:47:35 2021 @author: fhu14 Testing for the functionalities implemented in DataPrecompute NOTE: This test does NOT guarantee correctness, only that the code can run through the fold generation and precompute processes! TODO: Incorporate gammas precompute in...
31fc87548ee770e950c31dcb363d8bf598af8319247c094a369b451aa39ce707
Python
2,721
80
# Copyright (c) OpenMMLab. All rights reserved. import pytest from mmdet.datasets import get_loading_pipeline, replace_ImageToTensor def test_replace_ImageToTensor(): # with MultiScaleFlipAug pipelines = [ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', ...
9de790a2ffeefce02dd91b1b2f7a6927aac5029207e00708d13b9ceb6f7800e2
Python
2,722
59
# Author: Alfred Lim # Location: Singapore # Date: 2021-11-27 # Task: build example files for Lens # Reference: Lim, O'Brien, & Luca (submitted) ## Import libraries import numpy as np import pandas as pd import random import math import time ## Define function that write example files for Lens def write...
ae03abf44fb3cbfbe9af3a4d9fd7e989a09373a02d482f23e392ebe8dc83686f
Python
2,722
78
import os import json import random from torch.utils.data import Dataset from torchvision.datasets.utils import download_url from PIL import Image from data.utils import pre_caption class nlvr_dataset(Dataset): def __init__(self, transform, image_root, ann_root, split): ''' image_root (string)...
bb46e58968f732c315f5032d529ac34f1f9fd52d734447cb1c0d50fde33b79bc
Python
2,723
69
import pytest from foolbox import accuracy from foolbox.models import ThresholdingWrapper from foolbox.devutils import flatten from foolbox.attacks import BinarySearchContrastReductionAttack from foolbox.attacks import BinarizationRefinementAttack from conftest import ModeAndDataAndDescription def test_binarization...
e4c208bcdee9afd8df904ffc7f64c8954e5b2f55d5f8f82e38185a802849ef42
Python
2,725
96
import logging import numpy as np import torch.utils.data as data from PIL import Image from torchvision.datasets import CIFAR100 logging.basicConfig() logger = logging.getLogger() logger.setLevel(logging.INFO) IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp') def accimag...
80d3e9220463b2e3e828a7bc4895abc5aa67be26324b7a8b5916f2b9f9ab0e15
Python
2,729
46
# Copyright (c) OpenMMLab. All rights reserved. from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset from .dataset_info import DatasetInfo from .pipelines import Compose from .samplers import DistributedSampler from .datasets import ( # isort:skip AnimalATRWDataset, AnimalFlyDataset, AnimalHo...
8407d294a8d3d70f3d15eff1d383b7e81321672a4be5ee0e85d1317d986e3f57
Python
2,729
82
#!/usr/bin/env python3 """ test_advanced_activation_layers.py This file is part of the test suite for keras2c Implements tests for advanced activation layers """ import unittest from tensorflow import keras from keras2c import keras2c_main import time from test_core_layers import build_and_run __author__ = "Rory Con...
f5494dfa05ded809476d8e6db0acf1cf89f7ea179367a2d083bf4b42edaf34c8
Python
2,729
63
""" SI figure for Reviewer 1, comment 1: per-electrode encoding correlation r of each SFM at its best layer, plotted on the template brain (same plotting recipe as interpretable_unique_r2_on_brain.ipynb). """ #### ChatGPT was used to assist writing code. The authors reviewed, edited, and take full responsibility for th...
435f1adcb592383a7ea1af395fa314455837654228a5c167d4ebde721a95518c
Python
2,730
69
import os from pathlib import Path import numpy as np import scipy.io as sio from PIL import Image from torch.utils.data import Dataset class PascalVocDataset(Dataset): def __init__(self, root_dir, split='train', transform=None, dataidxs=None): self.images_dir = Path('{}/dataset/img'.format(root_dir)) ...
ba5586616a1496e064a1042df27d6293ed5e258ec40f82882e08d260240714ef
Python
2,730
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/> from __future__ import annotations import pytest import torch from torch import eye, zeros from torch.distributions import MultivariateNormal from sbi.n...
18ad3c8980b4eedbb2cb90e52935021fe360425785dcc36c6142c40e62a841de
Python
2,731
75
from jax.config import config config.update("jax_enable_x64", True) import jax.numpy as jnp import jax import weno_scheme import numpy as np import weno_roll import matplotlib.pyplot as plt import tabulate def test_reconstruct(N, u_fn, u_integral_fn, get_w, get_u_roll): dx = 1/N x = jnp.linspace(0, 1, N+1) x_lef...
5f0734ae6c1dd025c6882ffb609fbdd4000c9211fb9f44c82d32552511aa86a5
Python
2,733
51
from datetime import datetime import matplotlib.pyplot as plt from matplotlib.pyplot import cm import numpy as np import pandas as pd import geopandas as gpd import os import pathlib import calendar from D_modelling import d090_model_wrapper, d140_modelStats from D_modelling import d140_modelStats from E_viz import e50...
a154958d2b20a7708345b49a4ed5ff5b0b8b450a9bbbd4124dcbcf4ac97efe06
Python
2,733
75
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...
68b2b730fee1e2275d5d5703611078e45380156646b5992a9f18138c36150eef
Python
2,734
85
import os import numpy as np import json from glob import glob import cv2 from sklearn.model_selection import train_test_split from os import getcwd classes = ["cell"] # 1.标签路径 labelme_path = "LabelmeData/" isUseTest = True # 是否创建test集 if isUseTest: #labelme_path = "LabelmeData/" labelme_path="....
9f73be088b9304c594ffed261f7beef45cc5a8fa3aeec1e14a7ae62d443360df
Python
2,735
76
import numpy as np from scipy.integrate import odeint from importlib import reload import sys sys.path.insert(2,'support') import functions reload(functions) import functions as f import parameters reload(parameters) import parameters as p direc = sys.argv[0].split('script')[0]+'data/' sim_idx = int(sys.argv[2]) plast...
509ec2898a8e7ffdbefa57203fbd9d1f0073cc15ffc2231693e36fffc5000865
Python
2,736
86
# -*- coding: utf-8 -*- """ Created on Wed Jul 21 19:15:47 2021 @author: fhu14 Test module for testing construction of gammas from gammas saved per fold """ #%% Imports, definitions import os import pickle import numpy as np from DataManager import load_config_tracker_per_fold, load_gammas_per_fold from InputLayer ...
b3ee8f422c29b321addb552a88bf344f8c8bcd6e2b060fcc0a8fce1939fb6b0d
Python
2,736
79
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 import utils from metrics import calculate_kl as KL_DIV import config_bayesian as cfg from ..misc import ModuleWrapper class BBBLinear(ModuleWrapper): def __init__(self...
d12affddc83ea5b337742015c057ff71b68a973f66c67d61bce63ae425e3a30c
Python
2,736
90
''' assumes that the user has already generated .json file(s) containing data ''' import argparse import json import os import numpy as np from scipy import stats parser = argparse.ArgumentParser() parser.add_argument('--name', help='name of dataset to parse; default: sent140;', ...
3145fb8de965f19d134a95f933928818c497c20dc3074d2220df444c5697dcb2
Python
2,738
76
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 '{:....
285666a601fe1dda3e263e5757f692c914bd4fb08d437b4cb8195c2e29697217
Python
2,739
76
#!/usr/bin/env python # -*- coding: utf-8 -*- """Test utilities based on Octave""" import numpy as np from numpy.testing import assert_allclose from oct2py import octave import pytest from pystoi.stoi import DYN_RANGE, FS, MINFREQ, N_FRAME, NFFT, NUMBAND, OBM from pystoi.utils import remove_silent_frames, stft, thirdo...
f509ed50afbc936d7b7ae6e767525ee74deff06f9b69a4bd44e9cb86ac3d3857
Python
2,739
101
import pandas as pd import numpy as np import matplotlib.pyplot as plt from collections import defaultdict import scipy.stats as st def get_path(file): steps = file.split("_") path = ' '.join((steps[-2], steps[-1])) return path.split('.csv')[0] def col(x, dico): return plt.get_cmap("nipy_spectral")(x/...
46ebea4bcb52a36aee08062f777aec7f33e674ae8d0c1da61ade63d0529ef19c
Python
2,740
105
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...
d218697deb7fe7718f69636abaf29dd84820eac971974b335b8579c1a8d57846
Python
2,742
83
# This program 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. # # This program is distributed in the hope that it will be usef...
ec14ad594e9908d37cb71c141c24c0b77861ecde72e795c45a001362a258dd8f
Python
2,743
84
# test_dit_dataPs.py # This file compares admUI with the algorithm implemented in dit # on the distributions in dataPs.mat (see directory /data/). # The results are used in Figure 3 of the paper. # # Distributed under the terms of the GNU General Public License v3 from admUI import computeQUI import dit import time imp...
924a8c6445df7f1776dbe27a9bfd0ebd3d73f6ee110953b6b3a786ad8b9fcfae
Python
2,745
73
import numpy as np def non_max_suppression_malisiewicz(boxes, overlap_threshold): """ Eliminates redundant boxes using NMS adapted from Malisiewicz et al. Args: boxes (np.ndarray): A >=5 by N array of bounding boxes where each of the N rows represents a bounding box with format of ...
e4ff6a1f56c754ef56e6c5954064a2e74255cf2b8c7514a37cdda106bab53b0b
Python
2,749
95
import json import random import numpy as np from tqdm import trange NUM_USER = 30 def softmax(x): ex = np.exp(x) sum_ex = np.sum(np.exp(x)) return ex / sum_ex def generate_synthetic(alpha, beta, iid): dimension = 60 NUM_CLASS = 10 np.random.seed(0) samples_per_user = np.random.lognorm...
25eae53cc28d0606c657e1edddbc3ae9b4e7e94311c5d6f3cd719ec552b48b4c
Python
2,753
92
#!/usr/bin/env python """ Test script for parallel processing implementation in ClipKIT """ import time import sys from clipkit.clipkit import execute from clipkit.files import FileFormat from clipkit.modes import TrimmingMode def test_parallel_processing(): """Test that parallel processing works correctly""" ...
ae57d3bf74d8213dd49dfc887ecd4275cabec2188338f278fdf3f2334fda2dbf
Python
2,753
97
# coding=utf-8 from typing import Callable, Union from torch_geometric.typing import OptPairTensor, Adj, OptTensor, Size import torch import torch.nn as nn import torch.nn.functional as F from torch_scatter import scatter_mean, scatter_add class MeanReadout(nn.Module): """Mean readout operator over graphs with v...
e7af36291bd9f6af992669501a3ad7c99b46ae900e3f9590f55bf2bcd2c176ae
Python
2,755
49
#! /usr/bin/env python # *********************************************************************************** # * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. * # * * # * Redistribution and use in source ...
f41c21abf8f37a3b327d1b2f0be8409bda1326e3cb648154430a6e0019948d38
Python
2,755
74
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...
0ef7b6c30dabbe550bf660ca1b97e7fb0967c41350f787d803e4b7f00f5f55f0
Python
2,761
76
import numpy as np def non_max_suppression_malisiewicz(boxes, overlap_threshold): """Eliminates redundant boxes using NMS adapted from Malisiewicz et al. Args: boxes (np.ndarray): A >=5 by N array of bounding boxes where each of the N rows represents a bounding box with format of ...
69a138bab2d3cf59124a96398b1892ef102b4e32ea4ed6a40bdad98c14177214
Python
2,761
95
import numpy as np import pytest import nengo from nengo.utils.stdlib import Timer from nengo_extras import Conv2d, Pool2d @pytest.mark.parametrize('local', [False, True]) def test_conv2d(local, Simulator, rng): f = 4 c = 2 ni, nj = 30, 32 si, sj = 5, 3 # f = 64 # c = 64 # ni, nj = 32, ...