sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
10dcb30fa0d0739d276ff68b2c113187f0b84cd2f6621bf0c6648ee6a40e99d5 | Python | 11,235 | 265 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.ops import nms_match
from ..builder import BBOX_SAMPLERS
from ..transforms import bbox2roi
from .base_sampler import BaseSampler
from .sampling_result import SamplingResult
@BBOX_SAMPLERS.register_module()
class ScoreHLRSampler(BaseSampler):
... |
bce33b2c37ecb9b1bec8ac803be45874559f4e2876eeae38be561fc852f7c2b4 | Python | 11,244 | 255 | import bibtexparser as bp
from click.testing import CliRunner
import pathlib
import tempfile
import zipfile
from ..click_commands import citations, provenance, supplement
from .test_parse import DATA_DIR, TEST_DATA
from .testing_utilities import CustomAssertions
class ReplayTests(CustomAssertions):
def test_prov... |
2f75c664f76031e60d8acfb77f128b2747e44195c53f14385f12c47466e1687e | Python | 11,245 | 320 | # 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 warnings
import pytest
import torch
import sbi.inference
from sbi import utils
from sbi.inference import FMPE, NPE, VectorFieldPosterior, infer
f... |
d2b62f06c15bcdcb0388caf71029c10a46e91aaae99aa282f1261af7dbb2a465 | Python | 11,264 | 274 | #!/usr/bin/env python
import unittest
import hashlib
from os import path
from picrust2.util import read_fasta, TemporaryDirectory
from picrust2.default import (default_ref_dir_bac, default_fasta_bac,
default_tree_bac, default_hmm_bac,
default_model_bac, d... |
abb4e327a8ef44123c5ccb9510df053659908f05378089df53b356d9f0ac2caa | Python | 11,270 | 309 | # Copyright (c) OpenMMLab. All rights reserved.
import matplotlib.pyplot as plt
import mmcv
import numpy as np
import pycocotools.mask as mask_util
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon
from ..utils import mask2ndarray
EPS = 1e-2
def color_val_matplotlib(color):
... |
e4093c426650375b8567a3b579174755811abe28d40cc7502ea387711a20b57a | Python | 11,271 | 287 | # Copyright 2019 MaterialEyes
# (see accompanying license files for details).
"""Definition of the ExsclaimTool classes.
This module defines the central objects in the EXSCLAIM!
package. All the model classes are independent of each
other, but they expose the same interface, so they are
interchangeable.
"""
import ... |
895b70b3d12144d712d061a33bc7745bbc434e5aca44a73ef9b8bcb4c68babe8 | Python | 11,278 | 325 | import numpy as np
import torch as th
import scanpy as sc
import scvelo as scv
import anndata as ad
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics.pairwise import cosine_similarity
from scipy.stats import spearmanr, pearsonr, sem
from latentvelo.utils import paired_cosine_similarity
from skle... |
216ef3552eb3ffef32ac1d1d5dd6ca13588c6a6e9d4b11d4e69ed0a837d62432 | Python | 11,282 | 360 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.stats import spearmanr, mannwhitneyu
from statsmodels.stats import multitest
from statistics.clustered_mlp_output_wrappers import load_shap_with_parcellations
from statistics.mlp_output_wrappers import name_to_lobe_m... |
e5636dee9c1c9ed78409b4f4b54287cc25404ceeb229d264f9dae15add5d67ac | Python | 11,284 | 266 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.ops import batched_nms
from ..builder import HEADS
from .anchor_head import AnchorHead
@HEADS.register_module()
class RPNHead(AnchorHead):
"""R... |
bb2c02a560ebecdc4ce060d5799c6220fc4061c3b7e837519210013be9b25a91 | Python | 11,296 | 372 | from jax.config import config
import os
config.update('jax_enable_x64', True)
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
import sys
import numpy as np
import jax
import jax.numpy as jnp
import numpy as np
from functools import partial
import plot
from einshape import jax_einshape as einshape
import math
from... |
923a6bd9c90e49c5102525851482c48eb4f71509e53800b091146335c18ab63c | Python | 11,306 | 272 | import nengo
import nengo.spa as spa
import numpy as np
import importlib
import voja2_rule
importlib.reload(voja2_rule)
import bcm2_rule
importlib.reload(bcm2_rule)
from nengo.utils.builder import default_n_eval_points
import scipy
import scipy.special
import scipy.sparse
class Mem_Voja2_Pes_Hop_TwoLayers(nengo.Net... |
01f255bfd310d29584bc11f5fa8c182e7e93d5480e782380c68e0922646cbfaa | Python | 11,320 | 301 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict
import json_tricks as json
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.datasets.builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDow... |
85082c8fab1daa86a13ae472641ad488574ef97aac8552362ff039416897ad28 | Python | 11,323 | 261 | # -*- coding: utf-8 -*-
"""
Base
=====
This module contains arrow extraction classes
author: Damian Wilary
email: dmw51@cam.ac.uk
"""
import abc
import copy
import logging
from itertools import product
from typing import List, Tuple, Union
import cv2
import numpy as np
import torch
from matplotlib.patches import Recta... |
a2aba7c12be5e30244029b72077dd34554919eaf62752559a9c6e43e64d7ff2f | Python | 11,326 | 313 | import numpy as np
import scipy as sp
import scipy.signal
# use get_noise_fft
def noise_estimator(Y,range_ff=[0.25,0.5],method='logmexp'):
dims = Y.shape
if len(dims)>2:
V_hat = Y.reshape((np.prod(dims[:2]),dims[2]),order='F')
else:
V_hat = Y.copy()
sns = []
for i in range(V_hat.sh... |
db9e0006cc2746a02627f98fc8c7af7434e10822ba004c080451fa75b0430113 | Python | 11,328 | 304 | import re
from typing import Optional, List, Tuple
import torch
from torch.autograd import grad
from torch import nn, Tensor
from torch_scatter import scatter
from pytorch_lightning.utilities import rank_zero_warn
from torchmdnet.models import output_modules
from torchmdnet.models.utils import AccumulatedNormalization
... |
f4c2c4e5224962430364763bfcde85a38e9d5a6c5a3e147c9c993256bcd05405 | Python | 11,332 | 311 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import mmcv
import numpy as np
from mmcv.image import imwrite
from mmcv.utils.misc import deprecated_api_warning
from mmcv.visualization.image import imshow
from mmpose.core import imshow_bboxes, imshow_keypoints
from .. import builder
from ..builder imp... |
ba41f5fbd1d54cbe365902d432acaf41517ad300e1f5f84831cbc74e179a7289 | Python | 11,337 | 238 | import numpy as np
import os
import sys
import ntpath
import time
from . import util, html
from subprocess import Popen, PIPE
if sys.version_info[0] == 2:
VisdomExceptionBase = Exception
else:
VisdomExceptionBase = ConnectionError
def save_images(webpage, visuals, image_path, aspect_ratio=1.0, width=256):
... |
fe05a3faebc2e2359c5020490066a9b5386f532a75ca6283b0249a5811b03c58 | Python | 11,338 | 237 | import warnings
import numpy as np
import plotly.graph_objects as go
import pytest
from sklearn.linear_model import LinearRegression, LogisticRegression
from doubleml.double_ml_framework import concat
from doubleml.irm.irm import DoubleMLIRM
@pytest.fixture(scope="module", params=[1, 3])
def n_rep(request):
ret... |
656e7cb2c7f0278ca1b8c8304b6435a6dac2cc3ad1924800927dc304ca6f6b24 | Python | 11,345 | 236 | import pickle as pkl
from .dataset import Dataset
from .generator import Generator
from .model import RepulsiveModel
from .options import Options
from .util import Zs_from_opts, count_n_heavy_atoms
def compute_gammas(dset: dict, opts: dict, return_gammas: bool = False):
r"""Precomputation of gammas
Args:
... |
2ccbf329ee6226c22d65ae8d12cb3f164e7475bd49e1c84653633b7d47b1b548 | Python | 11,354 | 411 | import numpy as np
def emp_variogram(x,D,nh,h_bounds=0):
# calculate the empirical variogram
n = x.size
triu = np.triu_indices(n, k=1) # upper triangular inds
b=3
diff_ij = np.subtract.outer(x, x)
v = 0.5 * np.square(diff_ij)[triu]
u=D[triu]
if h_bounds==0:
h = np.linspace(u.m... |
fd12dc12e2d3302a4627774a017ecc6e8c5e131e42444fb00248b38ad372e24e | Python | 11,358 | 340 | import glob
from pathlib import Path
import mne
import numpy as np
import torch
from scipy.signal import resample_poly
from sklearn.preprocessing import RobustScaler
from anysleep_no_hydra import AnySleep
def load_edf(input_file: str, channels_to_include, resample_rate):
"""
Load and preprocess an EDF file ... |
75008599ac321c4974a5db636d69b8adf605b84afbfd49fdcefb93bbf30394d9 | Python | 11,364 | 255 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch
import torch.nn.functional as F
from ..builder import BBOX_ASSIGNERS
from ..iou_calculators import bbox_overlaps
from .assign_result import AssignResult
from .base_assigner import BaseAssigner
@BBOX_ASSIGNERS.register_module()
class SimOTA... |
5c56775a3d82cdd85fce9063fb6992dc4f23112a4a9f3020acb63be4e9e47889 | Python | 11,365 | 257 | """Shared primitive dispatch and public reusable-neighbor API contracts."""
from types import SimpleNamespace
import pytest
import torch
from aimnet import nbops, ops
from aimnet.calculators.neighbor_buffers import ReusableNeighborMatrix
from aimnet.modules.lr import DFTD3, LRCoulomb
def _dense():
data = {
... |
52e994d40b64fa0dc4bbf9dd70c40ff77ddffbffd90309276332a08c2215a7f8 | Python | 11,382 | 290 | import torch
import torch.nn as nn
import numpy as np
import time
import math
from matplotlib import pyplot
torch.manual_seed(0)
np.random.seed(0)
# S is the source sequence length
# T is the target sequence length
# N is the batch size
# E is the feature number
#src = torch.rand((10, 32, 512)) # (S,N,E)
#tgt = tor... |
45ab5c7293547e58ee9262c8ee88b2e482ae7951a011d274ee73f89329488457 | Python | 11,407 | 285 | import os, sys
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
# add the FedML root directory to the python path
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.model.cv.xception impor... |
508c5da020e64afd2e047bdfcc56656ae5da16c9187d9020ca066af3eedd7dd3 | Python | 11,410 | 256 | import argparse
import logging
import os
import socket
import sys
import numpy as np
import psutil
import setproctitle
import torch
import wandb
from mpi4py import MPI
# add the FedML root directory to the python path
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.data_pre... |
a0a976ff5b3b30ae26180e7fa679b45542c292695b131a79241161f4cd1a5767 | Python | 11,431 | 354 | # -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""Dataset modules based on kaldi-style scp files."""
import logging
from multiprocessing import Manager
import kaldiio
import numpy as np
from torch.utils.data import Dataset
from parallel_wavegan.utils im... |
e5c2ff0a8df4d623b610a3f9436ab7184ecb287233988815b7b0aea42bf1128f | Python | 11,454 | 352 | #!/usr/bin/env python
# Copyright (c) OpenMMLab. All rights reserved.
# This tool is used to update model-index.yml which is required by MIM, and
# will be automatically called as a pre-commit hook. The updating will be
# triggered if any change of model information (.md files in configs/) has been
# detected before a... |
b4916485ee1a2909a8f1280597004fb8f6071373a38f3e5260b063851647b73b | Python | 11,459 | 320 | # 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
from torchmdnet.models.model import load_model
import warnings
# dict of preset transforms
tranforms = {
... |
b29b3b5c58f35567dccc196cde0b25d4d078b535d0e39d8450a4e8447c0f89ec | Python | 11,463 | 361 | # 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
from torch import allclose, device, exp, eye, ones, tensor, zeros
from torch.distributions import Normal, Uniform
from torch.nn import L1Los... |
3e7f942b1c9fcfeba6676623443e52983a906a0fe13387d4786cb8e14bef8c03 | Python | 11,464 | 348 | '''
Author: ----
Date: 2022-06-14 21:19:30
LastEditors: GhMa
LastEditTime: 2022-10-02 19:25:19
'''
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
from torch.utils.tensorboard import SummaryWriter
import os
import uuid
import argparse
... |
890e5452079316788f529037324f94729fdd13d7edb1368f848c95267f9690eb | Python | 11,465 | 367 | # -*- coding: utf-8 -*-
"""Utilities"""
__author__ = "Sean Benson"
__copyright__ = "MIT"
import numpy as np
from numpy.lib import stride_tricks
from skimage.util.shape import view_as_windows
import torch
from torchvision import transforms
import matplotlib.pylab as pylab
import PIL
import cv2
def image_search(inlis... |
82ff31aa29db6271be21b9fbe3789b8228dde51bcd1f3bf93ad3a1effbe6af57 | Python | 11,482 | 121 | #########################################################################
# Driver for experiments. Example commands are in experiments.md
#########################################################################
import argparse
import torch
import numpy as np
from bayes_design.decode import decode_order_dict, decode... |
02dfec38b3dc3500598085b1b96691052662cefce01482a5c95ed27cfe5d9d3a | Python | 11,488 | 294 | """First-/higher-order contracts of shared per-pass dense convolutions."""
from types import MethodType
import pytest
import torch
from aimnet.models.aimnet2 import AIMNet2
from aimnet.modules import aev_inference
from aimnet.modules.aev import ConvSV
from aimnet.modules.core import AtomicSum, Output
@pytest.mark.... |
137901572230dab9428a8da99e6fd2926db1349ba1dea2792ba4860d8725b765 | Python | 11,490 | 306 | import torch
import torch.nn as nn
import torch.nn.functional as F
from fedml_api.model.cv.darts.genotypes import PRIMITIVES, Genotype
from fedml_api.model.cv.darts.operations import OPS, FactorizedReduce, ReLUConvBN
from fedml_api.model.cv.darts.utils import count_parameters_in_MB
class MixedOp(nn.Module):
def... |
75540627c0a9e9189a1a53faa6c62d9999952cfa2cc817b31808e5c6576601cb | Python | 11,503 | 267 | #!/usr/bin/env python
import unittest
from os import path
import pandas as pd
import hashlib
import gzip
from picrust2.default import default_tables_bac, default_tables_arc
from picrust2.wrap_hsp import (castor_hsp_workflow,
castor_nsti)
# Read in expected output files.
test_dir_path = ... |
3f927419ab3a3347ce77a5676118a5b0e53afce345d59729a7f6a06883b2b8ac | Python | 11,506 | 306 | """test_core_layers.py
This file is part of the test suite for keras2c
Implements tests for core layers
"""
#!/usr/bin/env python3
import unittest
import os
from tensorflow import keras
from keras2c import keras2c_main
import subprocess
import time
__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Con... |
20fc40e958014c8b30e3f9372a7ea8ce878fda7f4b9ed8a146813a6d0400d15d | Python | 11,522 | 295 | import pandas as pd
from A_config import a10_config
import os
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import pearsonr
import seaborn as sns
import glasbey
import math
"""
Compare seasonal cumulation of obs and SF
"""
def get_seas_Obs_S... |
adfd282705af0376f9d203e2c5972aafca0b4241200ec81b9819afb98822460b | Python | 11,536 | 344 | """Command to train a model."""
import datetime
import logging
import os
import sys
from pathlib import Path
import numpy as np
import torch
from daart.cli.types import config_file, output_dir
from daart.eval import plot_training_curves
from daart.io import export_hparams, load_config
from daart.train import Trainer... |
007f35fdfd6534833a070753368031208deb7576fadbe646baa3476f98358f5f | Python | 11,549 | 329 | # coding: utf-8
import difflib
import filecmp
import os
import pickle
from functools import lru_cache
from inspect import cleandoc, getfullargspec
from pathlib import Path
import cloudpickle
import joblib
import numpy as np
import pytest
import lightgbm as lgb
SERIALIZERS = ["pickle", "joblib", "cloudpickle"]
@lru... |
9ed73ca2dc33ce8aca246d815781ad3f8ecc62dbc7e0b4b92c52b4a076a78398 | Python | 11,552 | 336 | # 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)
from typing import Optional, Tuple
import torch
from torch import Tensor, nn
from torchmdnet.models.utils import (
... |
4f820eef3bf4fc5577c9e21b6dbaf65d748524ee144201e0a1d40c7c7d1ab262 | Python | 11,554 | 308 | # 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
from torch.testing import assert_close
import pytest
from os.path import dirname, join
from torchmdnet.cal... |
e0a57980f28af9b2dc1a72e35742d94d788ea2169bd86706c5a9e6da26828286 | Python | 11,566 | 399 | """Abstract base class for Double Machine Learning estimators."""
from abc import ABC, abstractmethod
from typing import Any, Optional
import numpy as np
import pandas as pd
from typing_extensions import Self
from .data.base_data import DoubleMLBaseData
from .double_ml_framework import DoubleMLFramework
class Doub... |
9e3c7c2a387202631010130ec8da0ca99719e66b253a774755a9cac2be4d79a3 | Python | 11,584 | 315 | # -*- coding: utf-8 -*-
"""
Created on Fri May 26 15:50:58 2023
@author: oliver
"""
import numpy as np
import os
import shelve
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import scipy.stats
#==============================================================================
# helper function... |
60f6990ad7d93288d47edbf813941f2ed43304adacd32fb1cc79651a5575104f | Python | 11,592 | 252 | import os
import torch
from collections import OrderedDict
from abc import ABC, abstractmethod
from . import networks
class BaseModel(ABC):
"""This class is an abstract base class (ABC) for models.
To create a subclass, you need to implement the following five functions:
-- <__init__>: ... |
d1fee860a9271f3625d6def4504b107ca5b79e0bf1616143f474fe5e6e870447 | Python | 11,595 | 373 | # Copyright (c) OpenMMLab. All rights reserved.
import importlib
import os
import os.path as osp
import sys
import time
from contextlib import contextmanager
from typing import List, Optional, Tuple
from urllib.parse import urlparse
from urllib.request import urlopen
import cv2
import numpy as np
from torch.hub import... |
51f3c77240175b82dbe03f9cbb5adccb5f74d9e84088f08edad170e74495253b | Python | 11,598 | 265 | import argparse
import logging
import math
from copy import deepcopy
from pathlib import Path
import torch
import torch.nn as nn
from models.common import Conv, Bottleneck, SPP, DWConv, Focus, BottleneckCSP, Concat
from models.experimental import MixConv2d, CrossConv, C3
from utils.general import check_anchor_order, ... |
a402b32712ca25a886d757bd21a86a5d770de3a914eaa082c8b760f4190d63eb | Python | 11,610 | 280 | # 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 warnings
from typing import Optional, Tuple, Union
import numpy as np
import torch
from sklearn.model_selection import KFold
from sklearn.neighbor... |
666c940a1e9d3a772cb99e456cfe66daa3276b75b0c375ebf7ff7e7683384a60 | Python | 11,612 | 323 | #130428
#ROSE_geneMapper.py
#main method wrapped script to take the enhancer region table output of ROSE_Main and map genes to it
#will create two outputs a gene mapped region table where each row is an enhancer
#and a gene table where each row is a gene
#does this by default for super-enhancers only
import sys
i... |
d8d26f7519a3c5db9199e4f53c59f6fbd95b43471e0e4fd2de1d2b93d2917460 | Python | 11,615 | 350 | # 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 numpy as np
import pytest
import torch
from torch import eye, ones, zeros
from sbi.inference.posteriors.mcmc_p... |
06f82c338e975b4130a28c73c33d529ace5d917ac09a1ad6780585e2655171a1 | Python | 11,618 | 299 | import torch
import torch.nn as nn
from collections import defaultdict
from .yolo_layer import YOLOLayer, YOLOimgLayer
def add_conv(in_ch, out_ch, ksize, stride):
"""
Add a conv2d / batchnorm / leaky ReLU block.
Args:
in_ch (int): number of input channels of the convolution layer.
out_ch (... |
34188b8a3c1af7cf99f6ec7334925dc9822cd065a71ac4209201b718433bd86a | Python | 11,638 | 329 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import warnings
from collections import OrderedDict, defaultdict
import json_tricks as json
import numpy as np
from mmcv import Config, deprecated_api_warning
from xtcocotools.cocoeval import COCOeval
from mmpose.core.post_processin... |
3152b20d900c83cd2f278a5f625585aed7af6c3747547788bb3593aa8afb8f61 | Python | 11,649 | 372 | # -*- coding: utf-8 -*-
"""Utilities"""
__author__ = "Sean Benson"
__copyright__ = "MIT"
import numpy as np
from numpy.lib import stride_tricks
from skimage.util.shape import view_as_windows
import torch
from torchvision import transforms
import matplotlib.pylab as pylab
import PIL
import cv2
def image_search(inlis... |
3bbd9c506fba5dd0eb17f7408e1a9989a384e5ad284545d2b8b71db5415e0bd4 | Python | 11,651 | 283 | from typing import Dict, Union
import torch
import torch.nn as nn
class InpaintingHead(nn.Module):
def __init__(self, d: int, num_classes: int, device: Union[str, torch.device] = None, dtype: torch.dtype = None, boot: bool = False) -> None:
"""
Initializes the head module for the inpaiting upstre... |
b1bfeac74e850f3fadbe268aac090944ccab72dd23d649213832ddb3685737df | Python | 11,659 | 314 | from statistics import mean
import numpy as np
from scipy.stats import norm
import math
def find_plane_equation(plane):
"""
Finds the plane equation of a plane
:param plane: the plane to find the equation of
:type plane: :any:`numpy.ndarray`
:returns: the normal vector of the plane an... |
fb4dc009e9ae75adba0a969170eb72e4ab168630b5835ff91cb5fe4a14ed647c | Python | 11,659 | 327 | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.runner import Sequential
from ..builder import BACKBONES
from .resnet import Bottleneck as _Bottleneck
from .resnet impor... |
adb80d06f93d45fbca4d7a366997174b48aa9e44c86a622e31d4a90380a36ae9 | Python | 11,662 | 264 | # ----------------------------------------------------------------------- #
# Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
# #
# Software Name: Fast Autonomous Scanning Toolkit (FAST) #
# By: Argonne Na... |
398719affbee9933726acb8a8bf1035bbfec25abb836be0283cbede4bb0d2a38 | Python | 11,665 | 476 | from typing import Tuple
import numpy as np
EPSILON = 1e-10
def _error(
y_true: np.ndarray,
y_pred: np.ndarray,
) -> np.ndarray:
"""Simple error"""
return y_true - y_pred
def _percentage_error(
y_true: np.ndarray,
y_pred: np.ndarray,
) -> np.ndarray:
"""Percentage error
Note: resu... |
ca814683fb4933ea83e021c23e6a052b023f3b87e3776f80ce1d4f6a6b078f3d | Python | 11,670 | 341 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""Normalize feature files and dump them."""
import argparse
import logging
import os
import numpy as np
import yaml
from sklearn.preprocessing import StandardScaler
from tqdm import t... |
9d1c206f3d29b8ad8dcc8247f929ccfe177d1e2bbef14697311d351f1cbf258f | Python | 11,690 | 340 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmpose.core.post_processing import (get_warp_matrix, transform_preds,
warp_affine_joints)
def split_ae_outputs(outputs, num_joints, with_heatmaps, with_ae,
select_output_... |
a40f5f29b205eb37301d302768fa7a4e2f0ba8498011e5023ad8ddd7ee5386ae | Python | 11,691 | 300 | import logging
import numpy as np
import torch
import torch.utils.data as data
import torchvision.transforms as transforms
from torch.utils.data.distributed import DistributedSampler
from .datasets import ImageNet
from .datasets import ImageNet_truncated
from .datasets_hdf5 import ImageNet_hdf5
from .datasets_hdf5 i... |
525d317b98d2cdefa323bfd3b6c583baea017e2f5f0888bd68382e0c508069ac | Python | 11,693 | 316 | import logging
import os
import re
import json
import nibabel as nib
import numpy as np
import pandas as pd
from subprocess import run
import datetime
import zipfile
import matplotlib.pyplot as plt
import abc
import warnings
from datetime import time
from nilearn.plotting import plot_img
from icecream import ic
from pr... |
a97851a616812550d6708c7579d45f957965be05a3790987389b3d09b61de09d | Python | 11,708 | 304 | """ PyTorch backend """
import json
import os
class ModelFactory:
""" PyTorch backend model factory """
def open(self, model):
metadata = {}
metadata_files = [
("pytorch-metadata.json", ""),
("onnx-metadata.json", "onnx::")
]
path = os.path.dirname(__fi... |
258513b04d387f5fe20a21fe115e992c6dba223abf903b7d8abc5a2378c64fc0 | Python | 11,709 | 269 | import argparse
import typing
import os
import abc
import pandas as pd
import models.abstract
from models.abstract import ModelClassMetaData, ReportOptions, EvaluateResults, FitResults
# Import bez importu :)
if False:
import tensorflow.keras as keras
class KerasModelMeta(models.abstract.AbstractModelMeta):
... |
b23e761147c89394d61e606af35902f6f70e5f9e45df62e2c8f636c579a42398 | Python | 11,723 | 303 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 21 10:58:23 2021
@author: Anandita
"""
'''
This file generates data for a fixed d and a range of values for sigma and N
for Gaussian tuning curves with uniformly spaced centers and circular boundary
conditions. In this case it is easier and faster to find d dimen... |
9fb92dab0d7458a5ba9c382864a7ae7eb6bb7a94842f4f89906a51bbf1b914ad | Python | 11,732 | 272 | # 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 os
import h5py
import torch
import math
import logging
import numpy as np
from tqdm import tqdm
from os.path imp... |
7bba8cd0675ddbf6cb7e769176312098c6fd3150bdddaf700ad9148edac44910 | Python | 11,744 | 280 | #!usr/bin/env python
#coding:utf-8
"""
@author: Haidong Zhang
@contact: haidong_zhang14@yahoo.com
@time: 2021/1/15 9:34
@project: MalariaDetection
@description: https://blog.keras.io/building-autoencoders-in-keras.html
"""
from keras.layers import * #For adding convolutional layer
from keras.layers impor... |
b73a84a48158b10d22fd6c50836d0fcd3475f261435e243e3916dbb8e7fb1c9b | Python | 11,762 | 294 | import math, logging, sys, os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
# add the FedML root directory to the python path
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.model.cv.batchnorm_utils import Synchr... |
79a0de938a4bdc28ceb2c52327b7eaeff4fbd22494aaf4c86fce291cec589d57 | Python | 11,764 | 279 | from phase_to_rate.neural_coding import load_spikes, rate_n_phase
from phase_to_rate.perceptron import run_perceptron
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import os
dirname = os.path.dirname(__file__)
results_dir = os.path.join(dirname, 'data')
# parameters
phas... |
a3801c0bb73e0969a2907be7f4a420acc1b52bc45377cb59555dfe765a791b7d | Python | 11,767 | 278 | """CPU-only contracts for the specialized CUDA-graph inference engines.
Graph replay bypasses Python module dispatch and embeds some scalar constants. A
successful comparison at one geometry cannot validate an arbitrary ``forward``
or hook. Accept only the stock module implementation, and fingerprint its
parameters, b... |
9edc88464201e8d64ff08ce1d93dd64e9bd14fdb8767ac37f4e4eee7715d929b | Python | 11,776 | 328 | from collections import defaultdict
import torch
import torch.nn as nn
from .yolo_layer import YOLOimgLayer, YOLOLayer
def add_conv(in_ch, out_ch, ksize, stride):
"""
Add a conv2d / batchnorm / leaky ReLU block.
Args:
in_ch (int): number of input channels of the convolution layer.
out_ch... |
9fb7f60d2fa38b3deea4e6baa19b374376c7fff10cba978afce7c094dfdc3f02 | Python | 11,778 | 269 | import logging
import numpy as np
import torch
import torch.utils.data as data
import torchvision.transforms as transforms
from .datasets import CIFAR100_truncated
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# generate the non-IID distribution for all methods
def read_data_dist... |
9d4a0fe68b256016bc5ce4604df11646cb077f8c9d9af1e5ef7131b785a6c86b | Python | 11,780 | 269 | import logging
import numpy as np
import torch
import torch.utils.data as data
import torchvision.transforms as transforms
from .datasets import CIFAR10_truncated
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# generate the non-IID distribution for all methods
def read_data_distr... |
9962e7031f8b1e1aee299f378235c3f00a93c96d9b9a602694ffb892b8b412de | Python | 11,781 | 345 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import warnings
from functools import partial
import numpy as np
import onnx
import torch
from mmcv import Config, DictAction
from mmdet.core.export import build_model_from_cfg, preprocess_example_input
from mmdet.core.export.model_... |
62e6ba182877d12fc7bc7d72d45592e13299f7ebdb99c12c679e6a002cfbf4af | Python | 11,782 | 283 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 1 11:46:36 2021
@author: baris
"""
from neural_coding import load_spikes, rate_n_phase
from perceptron import run_perceptron
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# parameters
phase_bin = 360... |
f273559a82ad7befda48cfbd701f37ff18a44707c276a8b2154e15bca43d31ef | Python | 11,788 | 246 | import copy
import logging
import random
import numpy as np
import wandb
import torch
from fedml_api.standalone.fedopt.client import Client
from fedml_api.standalone.fedopt.optrepo import OptRepo
class FedOptAPI(object):
def __init__(self, dataset, device, args, model_trainer):
self.device = device
... |
2cdc5b9ca72c3e48be04c2ba58c0fd876f7d29c7fbadb85c29d4b582e70e2b0d | Python | 11,803 | 258 | import argparse
import logging
import os
import random
import socket
import sys
import traceback
from mpi4py import MPI
import numpy as np
import psutil
import setproctitle
import torch
import wandb
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.data_preprocessing.Federat... |
3fefb414b111754e40a2f2b2f08673764c9c011dabd9c4d483b26afee28af060 | Python | 11,803 | 332 | """ Python Server implementation """
import errno
import http.server
import importlib
import importlib.metadata
import json
import logging
import os
import random
import re
import socket
import socketserver
import threading
import time
import urllib.parse
import webbrowser
__version__ = "0.0.0"
logger = logging.getL... |
7fd2135ad3031db5f6dc45d90346fbeedb1ae375692783b4c22dd4a5792ad5bb | Python | 11,813 | 307 | # ------------------------------------------------------------------------------
# Adapted from https://github.com/akanazawa/hmr
# Original licence: Copyright (c) 2018 akanazawa, under the MIT License.
# ------------------------------------------------------------------------------
from abc import abstractmethod
impo... |
7007fb5b51bb0e6856d57cca75ed7b94d2cf4a0af97acc9e1d7942f16fa74174 | Python | 11,818 | 259 | import argparse
import logging
import os
import random
import socket
import sys
import numpy as np
import psutil
import setproctitle
import torch
import wandb
# add the FedML root directory to the python path
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../")))
from fedml_api.distributed.fedav... |
4c950649ff14d6651f36d035a0cec8a3eeb317ec9a83935f37cac7400b3f457c | Python | 11,829 | 299 | import math
import torch
from torch import Tensor
from aimnet import nbops
def lazy_calc_dij(data: dict[str, Tensor], suffix: str) -> dict[str, Tensor]:
"""Lazily calculate distances for a given suffix.
Computes and caches d_ij{suffix} in data dict if not present.
For nb_mode=0 (no neighbor list), reus... |
d956642582b8d897477c666b7c7878b47b719ab29acc7e55b7a4bb5190b9c513 | Python | 11,834 | 287 | from elasticsearch import Elasticsearch, RequestsHttpConnection, serializer, compat, exceptions, helpers, TransportError
from datetime import timedelta, datetime
import utils
import logging
import hashlib
_es_host = '10.200.102.23'
_es_index = 'mimic'
_doc_type = 'eprdoc'
_concept_type = 'ctx_concept'
_patient_type = ... |
eaa35ae17c05d0d57d2415e9b2554e9e10bed55e3b85c9a31c99767b804bff55 | Python | 11,839 | 318 | from functools import wraps, partial
import time
import haiku as hk
import optax
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import io
import tensorflow as tf
import jax.tree_util as tree
import os
import json
import pytz
from datetime import datetime, timedelta
# see https://matplotlib.org/stab... |
f7c89d6c0d32f9f4c16a7616ea7c262956b9e4560634e72d81a84ef9d941a3d1 | Python | 11,853 | 317 | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import sys
import time
import warnings
from contextlib import nullcontext
from threading import Thread
from typing import Dict, List, Optional, Tuple, Union
import cv2
from .nodes import NODES
from .utils import (BufferManager, EventManager, FrameMessage,... |
e83ee0b81907796352e9418cb3522c1e3c32450b95c714e57e54bb64893c6d0d | Python | 11,854 | 301 | import numpy as np
import pandas as pd
import math
import matplotlib.pyplot as plt
from scipy.integrate import simps
import traceback
from pylab import arange, plot, sin, ginput, show
import os
# Manual segmentation of bouts into syllabus - eg. motor components which can be exhibited in the same discrete event
def... |
f83cf2f58f4390ee3068683548b0b75a661efa62d705887a9483997ca0609a2a | Python | 11,871 | 271 | """Shared AEV/ConvSV kernels: graph support is not required for dispatch."""
import pytest
import torch
from aimnet import nbops
from aimnet.modules.aev import AEVSV, ConvSV
from aimnet.modules.aev_inference import _FirstOrderOnly
def _data(coord, *, padded=False):
numbers = torch.ones(coord.shape[:2], dtype=to... |
3137d1814ba629a0217734caa1dd7a17527d5de6c4f12ca251b1b398e5b1e582 | Python | 11,876 | 336 | import os
import shutil
import glob
import collections
import random
import pickle
import logging
from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def transform_list_to_tensor(model_params_list):
for k in model_params_list.keys():
... |
5eb4257c31a5380cc8aae55b9aa69a64507ad85d5c621d23818fd00b110da922 | Python | 11,880 | 246 | 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 AsyndganModel(BaseModel):
""" This class implements the pix2... |
89ca15292f93c6b99063ba0c8de9d6974c6ef27f3f555d1adc42d5691a2fda92 | Python | 11,884 | 259 | # 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 Dict, Optional, Sequence, Tuple, Union
import torch
from torch import Tensor
from torch.distributions import Distribution
from torch.u... |
423b5b08d7415200fe6f5a8d9aca4b03cebea86aa9fac054788ab5b57ca37dcc | Python | 11,914 | 330 | # -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash_table
import plotly.express as px
from dash.dependencies import Input, Output
import os
from zipfile import ZipFile
import urllib.parse
from flask import Flask, ... |
487279534b9c52bdfbe8e3db03d02039b1e3addf0c36a91a7042ba95ac17229f | Python | 11,930 | 339 | # 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 h5py
import numpy as np
import os
import torch as pt
from torch_geometric.data import Data, download_url, extrac... |
4e012d1f0c4440e9714d361526f71b809e6d355ea1538eec4a8feba1997e08a1 | Python | 11,933 | 296 | import os
import json
import torch
from torchvision import transforms
import numpy as np
from PIL import Image
from utils.utils import imresize
from utils.constants import IMAGENET_MEAN, \
IMAGENET_STD, \
IMG_SIZES, \
IMG_MAX_SIZE, \
... |
a7ef630410a00e8153727c88341bb4c8e8dd2680c754daea89d9d3cb4d629084 | Python | 11,937 | 341 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmpose.models.backbones import ViPNAS_ResNet
from mmpose.models.backbones.vipnas_resnet import (ViPNAS_Bottleneck,
V... |
d5544a9fcc1ab8a11de9a315b00562363263fa5af59b171b43bb46a09756d02a | Python | 11,945 | 268 | # Import packages:
import os, sys, random, struct, shutil, mmcv, scipy, mmcv, skimage, imageio
import cv2 as cv
import numpy as np
from scipy import ndimage
from skimage import img_as_ubyte
import skimage.io as io
from PIL import Image
from mmcv.runner import load_checkpoint
from mmdet.models import build_detector
... |
2afb58e0cbd829181e95d941201252e2c51832ce9b9adf1fb5338122fac4779c | Python | 11,950 | 279 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 4 13:39:19 2021
@author: fhu14
This module is used for taking in the settings file and performing the
necessary corrections on the different blocks of the file. This includes
correction of dictionary keys and values for the torch tensor data type and
device settings. ... |
2871fcd668d196c3cfc528dec2c7ac2b26b07dcd98631dae626623b35f9dcca1 | Python | 11,951 | 333 | # Copyright (c) 2020 ReDNA Labs Co., Ltd.
# 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 restriction, including without limitation the rights
# to use, copy, modify, merge, publish,... |
7b2c86e75b1e5890de038231ed53197b6bc57cafb430b1487b34edc688a97273 | Python | 11,969 | 281 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 9 18:34:07 2021
@author: fhu14
"""
#%% Imports, definitions
from typing import List, Dict
import random
from DFTBLayer import DFTBList, assemble_ops_for_charges, update_charges
import os, pickle
from SKF import main, write_skfs
import torch
from MasterConstants import at... |
266ed355ce2bf1b84fa41a8ca5617360aa7bcfcbeceddf7a27d42e221ee0c626 | Python | 12,011 | 298 | # 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 io
import pickle
import pytest
import torch
from torch.distributions import MultivariateNormal
from sbi import utils as utils
from sbi.inference ... |
0c34e7f1a247a08827603cb67dbacaef88e9d43776fd7c69849d7c054d34aa84 | Python | 12,014 | 278 | #!/usr/bin/env python3
"""
benchmark.py -- score an SV caller's output against the simulator truth set.
Matches caller breakend-pairs to truth.bedpe within a position tolerance
(orientation-agnostic) and reports recall by SV type and size bin, plus overall
precision. Accepts svaba `bps.txt[.gz]` or a VCF (symbolic <DE... |
270d8fd428f15edcf4979ef3acf250047a8af0be30b7e09964ce60339d154d51 | Python | 12,075 | 297 | from tabulate import tabulate
import itertools
from scipy import stats
from typing import Dict
import pandas as pd
import numpy as np
from statistics.utilities import *
from statistics.clustered_mlp_output_wrappers import *
from statistics.aggregate_utilities import aggregate_statistic_by_region, \
aggregate_stati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.