sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
6201b25c3c814aff69c0fa2b53325525d7a820bd6c722afa4fdcb1b95edcc3f3 | Python | 7,545 | 187 | import pickle
import random
import numpy as np
import re
import csv
from keras.models import Model, load_model
import matplotlib.pyplot as plt
from imblearn.metrics import classification_report_imbalanced
from sklearn.metrics import roc_curve, auc, precision_score, recall_score,f1_score
from keras import backe... |
5d35fb3f8f9463d4a37ab36081159aba462c9dd6a62c06b0aea98a93bc456365 | Python | 7,553 | 222 | # 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 shutil
from pathlib import Path
import pytest
import torch
from pytest_harvest import get_session_results_df, is_main_process
from sbi.inference.... |
fb3ee13241dd2d0dfc9bba5d4301e8659c94650ff141a5679eccc7c5a971677f | Python | 7,553 | 191 | # -*- coding=utf-8 -*-
"""
Created on 2019-6-19 21:39:53
@author: fangsh.Alex
"""
import os
from attention import AttentionLayer
from model.transformer4 import TokenAndPositionEmbedding
num = "1"
import keras
import cv2
import numpy as np
import keras.backend as K
from keras import initializers
from PIL... |
f1b654b66ef4d2917149bc8b99a521ac077bf8638ffc68a697b7ba1d2f13b260 | Python | 7,558 | 196 | import os
import numpy as np
import pandas as pd
from os.path import join, exists, basename
from os import makedirs
from matplotlib import pyplot as plt
from config_path import PLOTS_PATH, TEST_RESULTS_PATH
from paper_analysis_revision2.data_utils import optimal_threshold
from paper_analysis_revision2.file_browser impo... |
7620c1d0cdfb25ece57844026e5d4115ec0e747890d97e213f59fc46f129202f | Python | 7,570 | 174 | import time
from collections import deque
import openslide
import cv2
import numpy as np
from havoc_clustering_v2.general_utility.image_creator import ImageCreator
# from general_utility.image_creator import ImageCreator
class TileExtractor:
def __init__(self, slide, tile_size=512, map_scale_fac=16, coordinates... |
2824a3e37a8ee77ea42622eb766b595adc7b3e8a2bc8f69a9f2f71f13707b71f | Python | 7,578 | 239 | # Copyright (c) OpenMMLab. All rights reserved.
import os
import warnings
from argparse import ArgumentParser
import cv2
import mmcv
import numpy as np
import torch
from torchvision.transforms import functional as F
from mmpose.apis import init_pose_model, vis_pose_result
from mmpose.datasets import DatasetInfo
try:... |
59ae94ee0adc4b7714e4cb0375374ca5212c18087a724da881d6642e05c193c9 | Python | 7,578 | 182 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss
from ..builder import LOSSES
from .utils import weight_reduce_loss
# This method is only for debugging
def py_sigmoid_focal_loss(pred,
... |
6c19b00808861b1fa282f5fc4b946deb2381b706a62cf0141a6c6f0df3ba8fdd | Python | 7,581 | 163 | import numpy as np
import jax.numpy as jnp
import jax
from einshape import jax_einshape as einshape
import pickle
from functools import partial
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
import sys
sys.path.append('../')
sys.path.append('weno/')
import utils
from absl import app, flags, logging
i... |
4d9a1f3c4200593b4e51a589fd74e67b28df13dda909f223196ab5cc29c21acb | Python | 7,588 | 184 | 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, criterion, metric_ftns, optimizer, config):
self.config = config
self.logger = config.get_logger('t... |
cb49956bca550ccc037fbb81cb0e87624488b403f6dc530709f687b237aea564 | Python | 7,588 | 209 |
from skimage.measure import label
from sklearn.metrics import accuracy_score, roc_auc_score
from sklearn.metrics import f1_score
from sklearn.metrics import recall_score, precision_score
from scipy.spatial.distance import directed_hausdorff as hausdorff
from scipy.ndimage.measurements import center_of_mass
import nump... |
214036371c7b6f51b6c012b9a68aca6de5e828ae8765b0c222fa0c8a2945935b | Python | 7,592 | 230 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
from collections import defaultdict
import numpy as np
import pytest
import torch
from mmcv import Config
@pytest.mark.parametrize(
'cfg_file',
['./tests/data/configs_mmtrack/selsa_faster_rcnn_r101_dc5_1x.py'])
def test_vid_fgfa_style_forward(cfg_fi... |
1783420a6968670bc7d0d9a4a32730e70cd8353bd0bcea60595f0ec71cf0c4c6 | Python | 7,595 | 250 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""Perform preprocessing and raw feature extraction."""
import argparse
import logging
import os
import librosa
import numpy as np
import resampy
import soundfile as sf
import yaml
fro... |
334fe1c943c833e5a9e13f058b1da5bcc949de8a2052d62fa2b3fb88811a25ad | Python | 7,599 | 197 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from ..builder import BACKBONES
from ..utils import InvertedResidual, make_divisible
@BACKBONES.register_module()... |
c730510588a054f43be41129f9378118d7b8434acee574589a873106d9f4d42b | Python | 7,600 | 266 | import json
import os
import random
from functools import cmp_to_key
from typing import Callable
import numpy as np
import torch
def getInferenceExperimentSpec(experiments, identifier):
for experiment in experiments:
if experiment["identifier"] == identifier:
return experiment
raise Runti... |
e67628db7be13e84e8511e45031e5292dfbaa020793ff396314c08421ab3ec74 | Python | 7,606 | 214 | # 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... |
b697727760c0ac3fd03d57beb26bb647832d7e5a4b9f4976136dc24fda6ae606 | Python | 7,607 | 201 | import argparse
import os
import time
import random
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import numpy as np
from utils import Logger, mkdir_p, AverageMeter
from dataloader_segments import Dataset_training, Dataset_testing
from torc... |
4ac21262c8968bc5dff98062f61970b3320a6d4caf568736590f66292fa1dc12 | Python | 7,611 | 182 | from __future__ import absolute_import, division, print_function, unicode_literals
import pandas as pd
from tqdm import tqdm
import numpy as np
import itertools
import rdkit
from rdkit import Chem
from rdkit.Chem import rdMolDescriptors
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Descriptors
fr... |
2298591994db60e8f31a1ee9e78208add22d7c5776c4a119258610bfd19984b6 | Python | 7,614 | 226 | import numpy as np
import pandas as pd
import os.path as path
import os
from simple_mlps.model_ibs.ibs import retrieve_brier_scores, make_struc_array
from sksurv.metrics import concordance_index_censored
import scipy.stats as statspkg
import statsmodels.api as sm
import itertools
DATA_DIR = "/data2/MRI_PET_DATA/predic... |
48468224c752c94edfde2b464bcfe2ba94d82697bae2c704e7eb707e35b8ce32 | Python | 7,618 | 318 | import getpass
import multiprocessing
from functools import partial
import os
import pathlib
import yaml
from itertools import repeat
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from pathlib import Path
import shutil
def in_container():
return "IN_CONTAINER... |
78e04bfa8a323382759076002024791b005da3855ef30c82494b794e3f44aeef | Python | 7,621 | 187 | import argparse
import logging
import os
import sys
import numpy as np
import torch
import wandb
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.data_preprocessing.cifar10.data_loader import load_partition_data_cifar10
from fedml_api.data_preprocessing.synthetic_1_1.data_l... |
abc79b28402a8ebecbf7c7748fb72d2e8e9a04687dab5397dcc01e642c67318e | Python | 7,624 | 217 | import os
import sys
import pandas as pd
# from shutil import rmtree
import numpy as np
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Geometry import Point3D
# from rdkit.Chem.Draw.IPythonConsole import drawMol3D
from ppqm import XtbCalculator
import psi4
import time
from datetime import datetime
... |
dfbd76712dc0d9852caa66d3be22c370785556789c87b5aa86c6377dc7d92e73 | Python | 7,637 | 223 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
from __future__ import absolute_import
from __future__ import with_statement
from __future__ import division
from __future__ import nested_scopes
from __future__ import generators
from __future__ import unicode_literals
from __future__ import print_function
"""
estimators.py: H... |
29e843b7192baffe4491dd37f55a64af990ae00b3ba2abe8c96448a510624d70 | Python | 7,638 | 191 | import jax
import jax.numpy as jnp
import numpy as np
from functools import partial
import haiku as hk
import utils
from transformer import SelfAttnTransformer, CrossAttnTransformer
from einshape import jax_einshape as einshape
import dataclasses
def pad_and_concat(demos, quest_cond, k_dim, v_dim, cond_len, qoi_len,... |
ce561c135eead4ba3893ddb2e9b021ce7c77848d2a444b7ae96fc0c8c5490999 | Python | 7,653 | 216 | import torch
import torch.nn as nn
from fedml_api.model.cv.darts.operations import FactorizedReduce, ReLUConvBN, OPS, Identity
from fedml_api.model.cv.darts.utils import drop_path
class Cell(nn.Module):
def __init__(self, genotype, C_prev_prev, C_prev, C, reduction, reduction_prev):
super(Cell, self).__... |
f2ca80cff63863e1034f32b728cfe66c5f9b8e8cccb14992651f27e52c006a79 | Python | 7,653 | 206 | """test_pooling_layers.py
This file is part of the test suite for keras2c
Implements tests for pooling 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_and_run
import tensorflo... |
fd03a1617cc567e0c51e35ff79eb3269045ad765b84f0504289554431ee5b677 | Python | 7,656 | 247 | import dataclasses
from typing import Optional
import haiku as hk
import jax
import jax.numpy as jnp
import numpy as np
import utils
def layer_norm(x: jnp.ndarray) -> jnp.ndarray:
'''add a LayerNorm layer and apply to x'''
ln = hk.LayerNorm(axis=-1, create_scale=True, create_offset=True)
return ln(x)
@datacl... |
550ee2d405391f1c7c513fd59bc48b503b36b60361a9011aa40c8de3e22e2224 | Python | 7,661 | 235 | # Matrix representation / parsimony.
from p4.tree import Tree
from p4.alignment import Alignment
from p4.p4exceptions import P4Error
import p4.func
from p4.nexussets import CharSet
from p4.node import Node
from p4.treepartitions import TreePartitions
"See also Alignment.mrpSlice()"
def mrp(trees, taxNames=None):
... |
2d8c0b40cac032be2c7e8df78ae54ab752900a7937c4834f230240f2213c425f | Python | 7,664 | 220 | # 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 typing import Callable, Optional, Tuple
import torch
from torch import Size
from torch.distributions import Dist... |
a25eb008d81a20621649da3eb65397ead17d69bb4ac0a5f69226b0c13a9b8477 | Python | 7,664 | 242 | #!/bin/python
import grubbs as grubbs
import mne
from mne.preprocessing import ICA
import numpy as np
import scipy.stats
from scipy import signal
from outliers import smirnov_grubbs as grubbs
from Olivia.Autoblink import Autoblink_code
import sys
import tempfile
from nagylab import emgdetect
from matplotlib import pypl... |
9ff4413a23412f7237e85850999f1a0fff896817d2c9d81790e403dd095ece1a | Python | 7,667 | 202 | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Dict, List, Optional, Union
import numpy as np
from mmpose.apis import inference_gesture_model, init_pose_model
from ...utils import Message
from ..node import Node
from ..registry import NODES
def _compute_area(bbox):
"""Compute the area of bou... |
892a024b09a2255cc05760ac92c2f91db302973bdf55fdce73911976eb9164cd | Python | 7,673 | 241 | # 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... |
b750614d5da9163c3afe380c5e171a7c53831a282d14562fbd078e837e09626e | Python | 7,690 | 171 | """CUDA contracts for the optional out-of-place geometry-gradient accumulator."""
import sys
import pytest
import torch
from aimnet.modules import aev_inference
pytestmark = pytest.mark.gpu
@pytest.fixture
def kernel_module():
if not torch.cuda.is_available():
pytest.skip("CUDA is required")
pytes... |
0589e0490eee86f714b62423220ca422608e366ca5e7a1f4f6ac3a0ddfc77388 | Python | 7,699 | 196 | from typing import Optional, Type
import jax
import jax.numpy as jnp
import numpy as np
from functools import partial, cache
import utils
from flax import linen as nn
import transformer_flax as transformer
from transformer_flax import translate_config
from einshape import jax_einshape as einshape
from dataclasses impor... |
6b86bd9cc363b627ec86af2d08643dd500d34fe7ba73f6a4f6c6d516e2b1ed15 | Python | 7,703 | 211 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch
from ..builder import DETECTORS, build_backbone, build_head, build_neck
from .base import BaseDetector
@DETECTORS.register_module()
class TwoStageDetector(BaseDetector):
"""Base class for two-stage detectors.
Two-stage detectors t... |
4a5663c3644c8ed270c28dda7eace25c75edadc11849770824fbc52046c0221d | Python | 7,706 | 188 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 8 17:33:44 2021
@author: fhu14
"""
#%% Imports, definitions
import os
import pickle
from typing import Dict, List
import numpy as np
from DataManager import total_feed_combinator
from .helpers import test_data_dir
#%% Code behind
def compare_feeds(reference_file: s... |
3f6fe7d7a6163f5b46e04c7fd879fdf76a8b4c5b6976ffa19f2f127809df0c72 | Python | 7,707 | 199 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import platform
import random
import warnings
from functools import partial
import numpy as np
from mmcv.parallel import collate
from mmcv.runner import get_dist_info
from mmcv.utils import TORCH_VERSION, Registry, build_from_cfg, digit_version
from torch.uti... |
015d48bfd08635293afdc28999444c342d3a91efa91950ba85c923851a78add3 | Python | 7,709 | 163 | """Tests for the adaptive neighbor-list buffer sizing."""
from __future__ import annotations
import numpy as np
import pytest
import torch
from aimnet.calculators.neighbors import AdaptiveNeighborList
def _true_max_neighbors(positions: torch.Tensor, cutoff: float) -> int:
"""Brute-force neighbor count, excludi... |
cdd08eca1b895d1d49062713facfe24ce360a159384af297a91a30825d9be868 | Python | 7,715 | 210 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 27 18:13:28 2020
@author: bariskuru & DanielM
"""
from neuron import h, gui # gui necessary for some parameters to h namespace
import numpy as np
import net_tunedrev
import os
import argparse
import scipy.stats as stats
from grid_poiss_input_gen i... |
c110163dd24e6606be602db2626b6f7c880891c2eccc05778eb78777c41c91ce | Python | 7,725 | 203 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdet.core import bbox2roi, multiclass_nms
from ..builder import DETECTORS, build_head
from ..roi_heads.mask_heads.fcn_mask_head import _do_paste_mask
from .two_stage import TwoStageDetector
@DETECTORS.register_module()
class TwoStagePanopticSegmentor... |
74138ad27eeb58b7d299c624aa2b69ca682a24a6ff1970d444bc6a4c30f043a4 | Python | 7,726 | 171 | #!/usr/bin/env python
"""
Nipype workflow for image preprocessing, with conformation and preparation before AI segmentation.
Defacing of native and final images. This also handles back-registration from
conformed-crop to T1 or SWI ('img1').
Required external input connections:
datagrabber.subje... |
d9d396405ede8c8540dbf2670efcf436a4ce66e9dce406ecd607658ae62e61de | Python | 7,729 | 212 | # 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 math import prod
from typing import List, Optional, Tuple, Union
import torch
from torch import Tensor, nn
from sbi.neural_nets.embedding_nets.full... |
721b4bb844ddc6e8d32bd7f662ef46c9b9712e1808002062fc52eee88a1e01e8 | Python | 7,734 | 214 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import mmcv
import numpy as np
import torch
import torch.distributed as dist
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (DistSamplerSeedHook, EpochBasedRunner, OptimizerHook,
get_di... |
3847c9df3f1fb26552ce8c9b1693ce4cc3bc0b01e1de5e465ba08b883cfe0c20 | Python | 7,742 | 180 | import logging
from pprint import pprint
import torch
from pybrid import utils, datasets, optim
from pybrid.models.hybrid import HybridModel
def setup(cfg):
cfg = utils.setup_experiment(cfg)
test_batch_size = (
cfg.optim.batch_size if cfg.optim.test_batch_size is None else cfg.optim.test_batch_size
... |
261f66d30985f2c4cc3dc3923ec9335c624d64a5d7bf2c155040822c418ea201 | Python | 7,751 | 202 | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... |
7777f0b265597b2e68050d12023067e473b487949558a117d2e361a33e4e91f1 | Python | 7,751 | 230 | # 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 typing import Tuple, Union
import torch
from torch import Tensor
from torch.distributions import Independent, MultivariateNormal, Uniform
from sbi... |
8018aeb8eab074ade8e5d035ad8138931899a4af2e8b34c9d76bd8110f7d0302 | Python | 7,751 | 185 | # 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/>
"""Base class for Approximate Bayesian Computation methods."""
import logging
import warnings
from typing import Callable, Dict, Optional, Union
import ... |
3f3fb94daa29584a3ce947aa7e71c739b9f9a23376c48001a46149ade07f4434 | Python | 7,753 | 218 | import cv2
import cc3d
import numpy as np
import tifffile as tiff
import matplotlib.pyplot as plt
from matplotlib import pyplot
from matplotlib.pyplot import MultipleLocator
import scipy
imgvolume = tiff.imread('E:\\Zhu\\ETreg\\code\\ETcoarse\\lables.tif')
for i in range(imgvolume.shape[0]):
imgtemp = imgvolume[i,... |
ca46ac58b6703fd0c903ee030ba774c7d47a9b1c816a9d4257248f36d2cf698c | Python | 7,753 | 205 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdet.utils import util_mixins
class AssignResult(util_mixins.NiceRepr):
"""Stores assignments between predicted and truth boxes.
Attributes:
num_gts (int): the number of truth boxes considered when computing this
assignme... |
d289508ba61dcc94c5819e6b18231cb213202da049bdd102017124e33fcd305b | Python | 7,757 | 155 | import torch
from torch import nn
from models.UNet import setup_unet
from models.perception_loss import vgg16_feat, perceptual_loss
from .base_model import BaseModel
from . import networks
from parse_config import ConfigParser
import parse_config
class Pix2PixModel(BaseModel):
""" This class implements the pix2p... |
761e2619cdf4cec82f95cd936394e1242839a4bf1be2f19e46c776c9c526a1c2 | Python | 7,758 | 182 | # Author: Akshara Balachandra
# Date: Saturday 21 Nov 2020
# Description:
import os
from typing import Dict, Tuple, NewType
import re
import multiprocessing as mp
import pandas as pd
import numpy as np
import json
from tqdm import tqdm
from process_parcellations.cat12reader import Cat12Reader
from icecream import ic
... |
d705751a8282d6cac1df3a43ed55c51d500b418ec46bbd50a3a0208bed59a02e | Python | 7,758 | 195 | import pickle
import random
import numpy as np
import re
import csv
from keras.models import Model, load_model
import matplotlib.pyplot as plt
from imblearn.metrics import classification_report_imbalanced
from sklearn.metrics import roc_curve, auc, precision_score, recall_score,f1_score
from keras import backe... |
f5da9bd0f98f3d6887b3a5d268c350091fe143eb9ebcb84f9ef5231e1d62aa89 | Python | 7,765 | 235 | import math
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
from fedml_api.model.cv.group_normalization import GroupNorm2d
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106c... |
136b4f000e9e51bf0bb7b16b1ff354ab1a5a1a41102f7c77c98fb848f5efe0db | Python | 7,770 | 229 | # 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... |
593c7b6a360cadb5d12fb1e7baf64bf9345ace8a4d19501c385c210da2967068 | Python | 7,774 | 230 | import argparse
import os
import pathlib
import random
import cv2
import numpy as np
import torch
import torchvision
import torchvision.transforms as T
from PIL import Image, ImageDraw
from torch import optim
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
from . import utils
from .dataset impo... |
f971072b5663dc52906bd6ea78cc7f67dad2d361a2deed714454deb387c95474 | Python | 7,777 | 218 |
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
from pprint import pprint
import jax
import jax.numpy as jnp
import jax.tree_util as tree
import numpy as np
from functools import partial
import haiku as hk
import optax
from absl import app, flags, logging
from collections import namedtuple
from tqdm i... |
ced0690af9f44ee8da3e11ab457e09f751661e0dae632547a9c766f9d7e3c301 | Python | 7,780 | 237 | import pytest
from pathlib import Path
from Bio import AlignIO
from clipkit.clipkit import execute
from clipkit.ecomp import read_ecomp
from clipkit.files import FileFormat
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS, DEFAULT_NT_GAP_CHARS
here = Path(__file__)
@pytest.ma... |
28ec8a52b12a53b5c374d2f9e7f24e4772947f9e8b2c9c1088a5419e6f1202cf | Python | 7,790 | 217 | import pandas as pd
import numpy as np
import sys
import math
import shelve
import logging
import pyabf
import matplotlib.pyplot as plt
import os
# sys.path.insert(1, '../utils/')
from utils.import_data import load_suite2p_outputs
from utils.calcium_traces import *
# initialisation
# csv_path = sys.argv[1]
# fishlab... |
66486e4e1d96c620279448493170abbda9f284e2875a4f6da2e97baf6a272758 | Python | 7,798 | 189 | import os, sys
from glob import glob
from os.path import join, isfile
import numpy as np
import pandas as pd
import h5py
import time
from datetime import datetime
from copy import deepcopy
from sklearn.metrics import balanced_accuracy_score, roc_auc_score, get_scorer, make_scorer
from joblib import Parallel, delayed... |
56058c5df4de7410efbe090bf04ef217a22d6a71456ad482b2f0eacd4b373015 | Python | 7,809 | 204 | import pandas as pd
import numpy as np
import os
import sys
import subprocess
from Bio import SeqIO
from multiprocess import Process
import subprocess
from Web_genome import download2
def filter_blast_report(path):
f1 = open(path, "r")
f = f1.readlines()
f2 = open(path+"_correct","w")
f2.... |
e2b1bcf94605d00f7110c6d2ad16a09098eed30a90bc0f1fcc5f00d78c34a8c3 | Python | 7,809 | 179 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..builder import BBOX_ASSIGNERS
from ..iou_calculators import build_iou_calculator
from .assign_result import AssignResult
from .base_assigner import BaseAssigner
@BBOX_ASSIGNERS.register_module()
class ATSSAssigner(BaseAssigner):
"""Assign a corr... |
2a9d709a2e26c799a1e1b8469b0ac275992767a3f3cb60a9d1c34fddea80e3e2 | Python | 7,811 | 238 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import numpy as np
from mmcv import Config
from xtcocotools.cocoeval import COCOeval
from mmpose.datasets.builder import DATASETS
from .bottom_up_coco import BottomUpCocoDataset
@DATASETS.register_module()
class BottomUpCocoWholeBodyDataset(BottomUpCoc... |
8bbe89454b03b7d2bc4d0aae4617f45d740e4e0d420f6024528e283e14d4f623 | Python | 7,815 | 275 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmpose.core.optimizers.layer_decay_optimizer_constructor import (
LayerDecayOptimizerConstructor, LearningRateDecayOptimizerConstructor)
base_lr = 1
decay_rate = 2
base_wd = 0.05
w... |
d5717cdfc4112c791339242a02ba611efde9c50ff0676fc95347bcaad7405f91 | Python | 7,821 | 232 | from typing import List, Tuple, Any
import pytest
import eagerpy as ep
import foolbox as fbn
from conftest import ModeAndDataAndDescription
L2 = fbn.types.L2
Linf = fbn.types.Linf
def test_ead_init_raises() -> None:
with pytest.raises(ValueError, match="invalid decision rule"):
fbn.attacks.EADAttack(bin... |
c5c171f06d23c734220c1e96a5cc9dcc5fbe28e03fce14f0f8280a9c75fe6e4a | Python | 7,824 | 191 | # Marcus Andersson - Percolator Project
# Script that tests the performances of percolator for different data input sizes. Produces a file containing data for graphs.
# psutil is imported in the case that the script should wait for other integration-test scripts to finish.
pathToOutputData = "@pathToOutputData@"
pathT... |
d326c6dbb759ace674bddf34acf262f5e55f7be3a284981bf0cbf222c49a019d | Python | 7,830 | 275 | import numpy as np
def modular_inv(a, p):
x, y, m = 1, 0, p
while a > 1:
q = a // m
t = m
m = np.mod(a, m)
a = t
t = y
y, x = x - np.int64(q) * np.int64(y), t
if x < 0:
x = np.mod(x, p)
return np.mod(x, p)
def divmod(_num, _den, _p):... |
570f6b20f5560b614ef87752d20bacd388b74cd76e345d2ceadbd80e23a47844 | Python | 7,836 | 214 | from __future__ import absolute_import
import os
import keras
import nengo
import numpy as np
class SoftLIF(keras.layers.Layer):
def __init__(self, sigma=1., amplitude=1., tau_rc=0.02, tau_ref=0.002,
**kwargs):
self.supports_masking = True
self.sigma = sigma
self.amplitud... |
ae1cfb414042226ba512149b1cacf529a6a624e00fddaa4ad7a555e5fafebb0f | Python | 7,841 | 237 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import xml.etree.ElementTree as ET
import mmcv
import numpy as np
from mmdet.core import voc_classes
label_ids = {name: i for i, name in enumerate(voc_classes())}
def parse_xml(args):
xml_path, img_path = args
tree = ET.p... |
59f3eb72d1016192056eda45328725f435920a86a31235ea85ecf49258a595f6 | Python | 7,849 | 153 | #!/usr/bin/env python
"""Add accessory image (flair) co-registration to cropped space (through ANTS),
and defacing of native and final images.
"""
import os
from nipype.pipeline.engine import Node, Workflow
from nipype.interfaces import ants
from nipype.interfaces.quickshear import Quickshear
from shivai.utils.... |
c98a0b9c05f53ac8bd9b68fc4b8974df28bb4c4ab962266925a9c6e8057f7bff | Python | 7,853 | 231 | ############################################
# imports
############################################
import csv
import time
import uuid
from pathlib import Path
from typing import TYPE_CHECKING, Any, Iterable
if TYPE_CHECKING:
from _typeshed import SupportsItems # only available to type checkers
import yaml
fro... |
6569418ee253f13ebe38ffc2e1de3e99d4c16f1cf9cf2248657a9bf516310a39 | Python | 7,857 | 183 | import torch
from absl import logging
import utils
import torch.optim as optim
import numpy as np
from tabulate import tabulate
from models_utils_pytorch import InputData, inputdata_transform
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
class Runner():
def __init__(self, data, model_conf... |
aa5caaa481d5ab7229c9309209ae0689378e30792120c51135898d1c93ee59af | Python | 7,858 | 189 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 23 12:29:15 2022
@author: baris
"""
import pickle
import numpy as np
import seaborn as sns
import pandas as pd
from phase_to_rate import grid_model
from phase_to_rate.figure_functions import (_make_cmap, _precession_spikes,
... |
d76e6a5ac58786b38ee21605ba792e2e9e72f04ef495d00791f7ff3e0564cf6d | Python | 7,858 | 222 | # Copyright (c) OpenMMLab. All rights reserved.
from typing import List, Tuple
from mmcv import Config
from mmpose.datasets.dataset_info import DatasetInfo
def get_eye_keypoint_ids(model_cfg: Config) -> Tuple[int, int]:
"""A helper function to get the keypoint indices of left and right eyes
from the model c... |
d8e2d808d447721029eff3a096a194d9004fde1aca062acfc4365296e33e1930 | Python | 7,860 | 215 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils import digit_version
from mmdet.models.losses import (BalancedL1Loss, CrossEntropyLoss, DiceLoss,
DistributionFocalLoss, FocalLoss,
GaussianFocalLoss,
... |
6397d63fe6ec23b9a68cb5a89f3e600af42f060f5bf1a5f780ef52de6f27c2d3 | Python | 7,861 | 201 | import torch
import torch.distributed as dist
from torch.optim.optimizer import Optimizer, required
from fedml_api.standalone.fednova.comm_helpers import communicate
"""
FedNova Optimizer implementation cited from https://github.com/JYWa/FedNova/tree/master
"""
class FedNova(Optimizer):
r"""Implements federated n... |
2dae2d1d14518d6d94aa696b1f67b1172e7b8f6eb0f2c1034f0717b5a7af1a55 | Python | 7,865 | 225 | #bamToGFF_turbo.py
#20130716
#script to grab reads from a bam that align to a .gff file
#uses the bamliquidator super fast uber thingy written by Xin Zhou
import sys
from ROSE_utils import *
from collections import defaultdict
import os
import string
import subprocess
def mapBamToGFF(bamFi... |
589c821e021ef3c2920e470555474af65ff49efd6d63fe0eed1b9976fa6ec52b | Python | 7,866 | 163 | """Figure 5. Show upscaling behavior for multiple network types.
Baseline performance is computed here, network performance is loaded from training runs as described in the README.
"""
from scripts.decoding_functions.decoding import sfa_decoding, test_generalization, kmeans_decoding, linear_decodability
import pickle... |
dc4c1878486d3eb9c5f3044a943750aa304b7017a0c6d467e37558f56cb7a866 | Python | 7,867 | 183 | from statistics.mlp_output_wrappers import load_roiabbr_to_roiname_map, map_neuromorph_nm_to_lobe
from statistics.clustered_mlp_output_wrappers import load_any_long
from statistics.utilities import parcorr, jaccard_sim
from statistics.dataframe_validation import SwarmPlotSchema, pa, DataFrame
from typing import Tuple, ... |
78497122fea465c705b036f5503fe91b08225bac1cc2db16f789f24a8b8dbd1f | Python | 7,878 | 188 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 23 12:29:15 2022
@author: baris
"""
import pickle
import numpy as np
import seaborn as sns
import pandas as pd
from phase_to_rate import grid_model
from phase_to_rate.figure_functions import (_make_cmap, _precession_spikes,
... |
2c1f74ef956a6565914726d12eabbb2ab2efc1dacb78cf3dbcb992bcb824715d | Python | 7,880 | 232 | """check_model.py
This file is part of keras2c
Copyright 2020 Rory Conlin
Licensed under MIT License
https://github.com/f0uriest/keras2c
Checks a model before conversion to flag unsupported features
"""
# imports
import numpy as np
from keras2c.io_parsing import layer_type, flatten
from keras2c.weights2c import Weigh... |
d2712a7673b5e55242495989f8b7108859dc0bcda2ebea53324ddeb51f1253f1 | Python | 7,884 | 191 | #!/usr/bin/env python3
import numpy as np
from time import sleep
from flystim.stim_server import launch_stim_server
from flystim.screen import Screen
from flystim.trajectory import Trajectory
def main():
#####################################################
# part 1: User defined parameters
############... |
79d97a98ddbb4c2624878238ba567ffc7ebc7ca2c7c4a5be4d790b8676d424d2 | Python | 7,910 | 188 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 23 12:29:15 2022
@author: baris
"""
import pickle
import numpy as np
import seaborn as sns
import pandas as pd
from phase_to_rate import grid_model
from phase_to_rate.figure_functions import (_make_cmap, _precession_spikes,
... |
f464c9957ad5232db80a09427e8a9fa1278065716c3d6090f04b33c9c3a29d19 | Python | 7,913 | 172 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 7 19:00:06 2021
@author: fhu14
Alternative version of the pairwise linear model that evaluates on the full
set of xeval values rather than using the zero adjustment optimization
"""
#%% Imports, definitions
from MasterConstants import Model, RawData
from typing import L... |
5c67aa2044e2344cff6d55c83c6185ba8188e698f4ffb5f25afe842a4c5a23ea | Python | 7,915 | 220 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDataset
@DATASETS.regist... |
3536479f671eb57b512cd026296eb761f6001749919efac03e03f5e437aad2fd | Python | 7,922 | 221 | # Copyright (C) 2024-2025 ETH Zurich, Niels Maeder and other DASH contributors.
from collections.abc import Callable, Sequence
import numpy as np
import pytest
from rdkit import Chem
from serenityff.charge.tree.dash_tree import DASHTree
from serenityff.charge.tree.tree_factory import Forest
from tests._testfiles imp... |
90aa701bf52815f5605c5509d156a1002189ec438ce3cf702e46edc7ecd84b66 | Python | 7,923 | 213 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .utils import weight_reduce_loss
def _expand_onehot_labels(labels, label_weights, label_channels):
bin_labels = labels.new_full((labels.size(0), label_channels), 0)... |
947d743aab7fed5022e5daf1effcc3d36aa962776947bc01b9920fbb69bff603 | Python | 7,931 | 223 | # Copyright (C) 2022-2025 ETH Zurich, Niels Maeder and other DASH contributors.
from typing import Any, Optional, Union
import numpy as np
import torch
from torch_geometric.data import Data
from torch_geometric.typing import OptTensor
class CustomData(Data):
"""
Data Class holding the pyorch geometric molec... |
5398d0739b18b9b8a3a55d5e29f67f6899a8a01d47f9421d068211584bac55d6 | Python | 7,937 | 221 | # type: ignore # Warp kernel annotations (wp.array(dtype=...)) are not valid static types; as in conv_sv_2d_sp_wp.py
"""Full pairwise Coulomb energy rows without an N x N pair tensor (Warp).
Reference: ``LRCoulomb.coul_simple`` (``aimnet.modules.lr``) on the all-pairs neighbor matrix with
``subtract_sr=False``::
... |
178b7b9c575198687ed82c0b99e94cc2cc5b22e3bd7929df45c15324d230bcd9 | Python | 7,940 | 201 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 21 12:31:20 2020
@author: baris
"""
inp_len = n_bin*n_grid
lr = 8e-2
rate_code_sim = np.zeros((sample_size, 2*inp_len, n_sampleset))
rate_code_diff = np.zeros((sample_size, 2*inp_len, n_sampleset))
phase_code_sim = np.zeros((sample_size, 2*inp_len... |
455e2cc5a8db52ee90796bb41e5735a83049507b89ba5118c2dd106236dbc29c | Python | 7,949 | 251 | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdet.core import bbox2roi
from mmdet.models.roi_heads.bbox_heads import BBoxHead
from .utils import _dummy_bbox_sampling
def test_bbox_head_loss():
"""Tests bbox head loss when truth is empty and non-e... |
4db5df079edb6d3c5ea95bdb776ceb691314099e8b9a1bec6c24e750cd9f8fe5 | Python | 7,961 | 219 | import yaml
import argparse
import numpy as np
import torch
from os.path import dirname, join, exists
from pytorch_lightning.utilities import rank_zero_warn
# fmt: off
# Atomic masses are based on:
#
# Meija, J., Coplen, T., Berglund, M., et al. (2016). Atomic weights of
# the elements 2013 (IUPAC Technical Report... |
30b285e7f4f2530478e8c42977bec4473c9cbe25dd77dcc32bd1a333c74d6902 | Python | 7,969 | 211 | import pandas as pd
import numpy as np
from rdkit import Chem
from tqdm import tqdm
from serenityff.charge.tree.dash_tree import DASHTree
df_props_file = "./props_all.h5"
sdf_file = "./sdf_qmugs500_mbis_collect.sdf"
tree_path = "./dashProps_tree/"
print(
f"Starting prop script\n df_props_file: {df_props_file}\n s... |
d19ba69839d8a2b162f2f5c927d9370f0352b537b379830b12d13d3a449ae56e | Python | 7,969 | 158 | import torch
from models.perception_loss import vgg16_feat, perceptual_loss
from . import networks
from .base_model import BaseModel
class Pix2PixMemoryganModel(BaseModel):
""" This class implements the pix2pix model, for learning a mapping from input images to output images given paired data.
The model tra... |
69fe03362220874bf5919420646572a06737a30db329a18ad39f2df0a02189e3 | Python | 7,970 | 197 | import numpy as np
from scipy.stats import percentileofscore
#https://github.com/mateuszbuda/ml-stat-util
def score_ci(
y_true,
y_pred,
score_fun,
n_bootstraps=2000,
confidence_level=0.95,
seed=None,
reject_one_class_samples=True,
):
"""
Compute confidence interval for given score ... |
553620b00be437d971c909e750ec1636fb5f60aeb95f2c24c2aa3c638a457b44 | Python | 7,973 | 186 | ############################################
# Imports
############################################
import os
from joblib import Parallel, delayed
from joblib_progress import joblib_progress
from oligo_designer_toolsuite._exceptions import ConfigurationError, DatabaseError
from oligo_designer_toolsuite.database impo... |
5519e38325367b0e6921430f258394a611ba1ecec6353d814c62719fc254d970 | Python | 7,980 | 222 | import os
import numpy as np
from os.path import join, exists
from sklearn import metrics
from config_path import PLOTS_PATH, TEST_RESULTS_PATH
from matplotlib import pyplot as plt
from sklearn.metrics import confusion_matrix
from paper_analysis_revision2.plot_utils import plot_auc_all, plot_auc_bootstrap, plot_prc_all... |
a0e14a74d5395067c8ad64d6ecc83f5a388faa1ab2dad849b7e0a0f03e8d0b86 | Python | 7,980 | 240 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import mmcv
import numpy as np
import torch
from mmcv.ops import RoIPool
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint
from mmdet.core import get_classes
from mmdet.datasets import replace_ImageToTensor
from mmdet.dat... |
f5b87c4cad670d5f2d963985abca79e1342cf712893a111528af384862f68a15 | Python | 7,984 | 164 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 7 18:33:29 2021
@author: fhu14
"""
#%% Imports, definitions
from typing import List, Dict, Union
from Spline import get_dftb_vals, spline_linear_model
import numpy as np
from MasterConstants import Model, Bcond
Array = np.ndarray
import torch
Tensor = torch.Tensor
impor... |
7c20105e6420edb187a83bbf0b3401a5a22c310395d8d48e2734a10cdb73cc3f | Python | 7,990 | 225 |
# Implementations of the sparse coding algorithm from [Olshausen & Field, *Nature* 1996].
# Parts of the code were from the user [takyamamoto](https://github.com/takyamamoto/SparseCoding-OlshausenField-Model)
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
from tqdm.notebook import tqdm
... |
6b9977008ae636aefb7ff1efaa2b9ad3279b4a2c2d5ef4c4a53606768d33737f | Python | 7,993 | 251 | """Utilities for file download and caching."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from abc import abstractmethod
from contextlib import closing
import errno
import functools
import gc
import hashlib
import multiprocessing.pool
import os
import r... |
637f769bc43df941621ca08a0ea5148de1c2952a83dff15360ddc3c54e0c22ed | Python | 7,998 | 208 | # Copyright (c) OpenMMLab. All rights reserved.
import json
import warnings
from mmcv.runner import DefaultOptimizerConstructor, get_dist_info
from mmpose.utils import get_root_logger
from .builder import OPTIMIZER_BUILDERS
def get_layer_id_for_convnext(var_name, max_layer_id):
"""Get the layer id to set the di... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.