sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e1ab1f0aa0045d462d69b7aefc207d74c9bfa15bef750391d369110fbaf1689c | Python | 9,070 | 284 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
from unittest.mock import MagicMock
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_face_300W_dataset():
dataset =... |
52aaca3cd5589c5678bed103d374fc5ac3d1f1a4e2934ca17799d99821336305 | Python | 9,085 | 239 | from __future__ import division
import torch
import cv2
import numpy as np
def label2yolobox(labels, info_img, maxsize, lrflip):
"""
Transform coco labels to yolo box labels
Args:
labels (numpy.ndarray): label data whose shape is :math:`(N, 5)`.
Each label consists of [class, x1, y1, x... |
e0dde3b46e97dd0c73c8b0763ba74a9dfca6abb7f14c83b42ce58c8dfef2b80c | Python | 9,088 | 243 | """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 tensorflow.keras as keras
from keras2c import keras2c_main
import subprocess
import time
import os
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
_... |
b8d3db4dc51329b2f804d9621d4a66d85b8312ecba857adc41bd0870db18dad9 | Python | 9,094 | 265 | from typing import Optional, Any, Tuple, Union
import numpy as np
import eagerpy as ep
from ..devutils import atleast_kd
from ..models import Model
from ..criteria import TargetedMisclassification
from ..distances import linf
from .base import FixedEpsilonAttack
from .base import T
from .base import get_channel_ax... |
47b1048e49c00306198c4da8af3543e3dcd5f8cecde984d11c7432363bd31f7f | Python | 9,105 | 224 | # 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 Any, Callable, Tuple, Union
import pyro.distributions
import torch
import torch.distributions.constraints as constraints
from pyro imp... |
70dd50f2d1d30ac95a061ceb2e95a72537f944ef9c08c63bf8c17f445748c4f6 | Python | 9,105 | 323 | import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp
import cv2
from scipy.signal import savgol_filter
from tqdm import tqdm
from matplotlib import pyplot as plt
import pandas as pd
import os
def unnormalize_j1_j2(j1, j2):
J = j1 * (75 - 20) + 20
Jp = j2 * (10 + 30) - 30
return... |
faa3504a8d8ca9e162390909c17e9120e4bcae19f7c8c6d1f5088f4f19214fb3 | Python | 9,114 | 248 | from __future__ import division
import cv2
import numpy as np
import torch
def label2yolobox(labels, info_img, maxsize, lrflip):
"""
Transform coco labels to yolo box labels
Args:
labels (numpy.ndarray): label data whose shape is :math:`(N, 5)`.
Each label consists of [class, x1, y1, ... |
4e51ae6d8a8e295e3df57156bc1c6ffe2712b33ce1ba2d2f8262ab4daf5ae267 | Python | 9,126 | 245 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import torch
import torch.nn as nn
from mmcv.cnn import (ConvModule, build_activation_layer, build_conv_layer,
build_norm_layer, constant_init, normal_init)
from mmpose.models.builder import build_loss
from ..backbones.resnet import Bas... |
1a3692de4a42b11ff109e3be2b2f37be799cf967549d2883f81bf488b41e2a5c | Python | 9,129 | 244 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import numpy as np
import torch
from ..builder import POSENETS
from .top_down import TopDown
try:
from mmcv.runner import auto_fp16
except ImportError:
warnings.warn('auto_fp16 from mmpose will be deprecated from v0.15.0'
'Plea... |
8488584fc7e89ec8b7722ca63fbf4ea1a28d62432505523f8089ea8cc456c52b | Python | 9,129 | 271 | import p4.func
from p4.var import var
import sys
import p4.pf as pf
class NodeBranchPart(object):
def __init__(self):
self.rMatrixNum = -1
self.gdasrvNum = -1
#self.bigP = None
class NodeBranch(object):
def __init__(self):
self.len = 0.1
# self.textDrawSymbol = '-' ... |
ea11ee25d1e3092645d16f8c4a4d2eb6c039896a2ab7aa76cf40c778ef48d22e | Python | 9,133 | 234 | import numpy as np
import random
from copy import deepcopy
def randomInit(
size: int,
bounds: tuple or list or np.ndarray = None) -> np.ndarray:
""" Random value initialization of particle positions and speed """
# default initialization to the range [0, 1]
bounds = (0, 1) if bou... |
4374a21e9715db3dd15b2fc1abf145595b103c95b4b607f8ddf826917131c222 | Python | 9,137 | 249 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import (build_conv_layer, build_upsample_layer, constant_init,
normal_init)
from mmpose.models.builder import build_loss
from ..backbones.resnet import BasicBlock
from ..builder import HEADS
@HEADS.... |
dce1b32da98a0e13b7eab71191737edea453231df9b53ee0b09fdd177349c120 | Python | 9,141 | 251 | from typing import Union, Tuple, Any, Optional
from typing_extensions import Literal
import math
import eagerpy as ep
from ..models import Model
from ..criteria import Misclassification, TargetedMisclassification
from ..distances import l1
from ..devutils import atleast_kd, flatten
from .base import Minimization... |
661408c0c5aa1c032206322bf39645fc942a169e4614bfdb4d0cb54a1069a4b7 | Python | 9,150 | 212 | #!/usr/bin/python3
'''
This pipeline is for processing and detection of domains with a neural network architecture
@author: Johan Sebastian Piña Duran
'''
import sys
import os
import time
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from optparse import OptionParser
import numpy as np
import tensorflo... |
d0fc5b53f204897f28043fd60c3bdc2c2da3ef5c56ba8f31feafdfb1f478950b | Python | 9,163 | 253 | import time
from logging import getLogger
import numpy as np
import torch
from hydra.utils import instantiate
from torch import nn
from base.config import Config
from base.evaluation.base_evaluator import BaseEvaluator
from base.model.base_model import BaseModel
from base.results.base_result_tracker import BaseResult... |
c93f120264757aaac6123e2d9eb0994f2fb5f610b4506f0e851b6682e3d74a37 | Python | 9,185 | 234 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dis... |
bbacef1c3abe7c0a9bbc817067a5bb56f7eb16df330953d07a4bd37ebe644999 | Python | 9,187 | 237 | # 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
from nflows.nn import nets
from torch import Tensor, nn, relu
from sbi.neural_... |
a38be72876f6ee0f8eabf6c2981c7834dbc00f9f6899042ea0e85716e865bddf | Python | 9,189 | 241 | import csv
from collections import deque
from itertools import islice
import numpy as np
import os
# base function library
# system-specific constants
NUM_DATAVALS_PER_ARENA = 4
NUM_ARENAS = 16
NUM_DATAFRAME_VALUES = 64
MAX_CAPDAC_VALUE = 4095
CH1_INTERNAL_DATAVAL_INDEX = 0
CH2_INTERNAL_DATAVAL_INDEX = 1
... |
9797d2ab2cac5ffc040222342dbe0c62a880029989d916a51e061e94efba679e | Python | 9,191 | 201 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_scatter import scatter_add
from torch_sparse import coalesce
from torch_geometric.data import Data
from torch_geometric.utils import to_dense_adj, dense_to_sparse
from confgf import utils, layers
class DistanceScoreMatch... |
38fed389a2ada700fc0ebd72175908ac35c332342e2e46acbdaee6d79c9de7cb | Python | 9,192 | 223 | # Model validation metrics
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import torch
from . import general
def fitness(x):
# Model fitness as a weighted combination of metrics
w = [0.0, 0.0, 0.1, 0.9] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:,... |
f4c898d0c698d3bfbdbedd28cb1fa2a18729be9f59a3f855cc07696b4df16826 | Python | 9,199 | 226 | import torch
import torch.nn as nn
import numpy as np
from functools import partial
from lib.model_zoo.common.get_model import register
version = '0'
symbol = 'clip'
class AbstractEncoder(nn.Module):
def __init__(self):
super().__init__()
def encode(self, *args, **kwargs):
raise NotImplemente... |
765b5873b0b774d9868ab75d09729304c70d12866ed905f183c3a5711292deb6 | Python | 9,203 | 265 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import warnings
from abc import ABCMeta, abstractmethod
import json_tricks as json
import numpy as np
from torch.utils.data import Dataset
from xtcocotools.coco import COCO
from mmpose.datasets import DatasetInfo
from mmpose.datasets.pipelines import Compose... |
06158b54b9bc525a6efa0193541404f4d30b3af2a22cdb1fe1023543b4d95ba4 | Python | 9,204 | 298 |
import h5py
import numpy as np
import os
from PIL import Image
# from skimage.metrics import structural_similarity as ssim
from skimage.transform import resize
from skimage.metrics import mean_squared_error, normalized_root_mse
from calculate_similarity_resnet import ResnetSimilarity
res = ResnetSimilarity()
# Dim... |
745ecb004ad16dcf7fdaf4eb36569dbe2044c858a35928c8a4346a6ca7c5cd14 | Python | 9,209 | 201 | import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.layers import LSTM, Dense, Dropout, Activation, SimpleRNN, Bidirectional, Flatten, BatchNormalization, AvgPool1D
from tensorflow.keras.layers import Conv2D, MaxPool2D,Reshape
import numpy as np
def Model_amp():
# left model: Conv + cha... |
22cb63f1777f653978ac06cb1ab63bef2eeccaa56615efbff5591d1bcca41b41 | Python | 9,224 | 257 | import torch
import torch.nn as nn
import torch.nn.functional as F
'''
Refer to
https://github.com/leaderj1001/MobileNetV3-Pytorch.git
'''
def get_model_parameters(model):
total_parameters = 0
for layer in list(model.parameters()):
layer_parameter = 1
for l in list(layer.size()):
... |
d31ffce01d2e2828eeabedb230f34af4e6d50bc7fbd41bd7875cf14f8e8a608b | Python | 9,224 | 182 | from torch import optim, nn, utils
import numpy as np
class CRNN(nn.Module):
def __init__(self,
configuration=None,
input_channels=3,
output_classes=22,
convolution_layers=4,
cnn_kernel_size=(3,3),
in_channels=No... |
05d2967947fc734d640a7cee094cf871c5c62be123fe1bbe6a7ffabea75814dd | Python | 9,226 | 214 | ############################################
# imports
############################################
from typing import Any
from oligo_designer_toolsuite.database import OligoDatabase
from oligo_designer_toolsuite.oligo_efficiency_filter import BaseScorer
from oligo_designer_toolsuite.oligo_property_calculator._proper... |
36e54d3f81aecd0499e5a88cd97e2984246c7c78b283349eaa106fefe5f1234d | Python | 9,228 | 272 | import os
import os.path as osp
import numpy as np
import numpy.random as npr
import torch
import torch.distributed as dist
import torchvision
import copy
import itertools
from ... import sync
from ...cfg_holder import cfg_unique_holder as cfguh
from ...log_service import print_log
import torch.distribu... |
6dd8a921d49542db23bf342a63d578e9a5e4bdd76327c6d60bcab6e451fbaeed | Python | 9,231 | 220 | """
Torch dataset object for synthetically rendered
spatial data
"""
import json
import random
from typing import Tuple
from pathlib import Path
import torch
import numpy as np
import os
from sep.training.base_dataset import BaseDataset
import sep.helpers.utils as utils
from sep.helpers.pink_noise import *
from sep.... |
d7d2455b9b77291aa601b071ff61d17ede6923e2b0ab823acd8f81a061df8078 | Python | 9,241 | 181 | #!/usr/bin/python
# This script will create voxel-based structural connectivity matrices for a given subject using the MITTENS analytic tractography pipeline
# This script was used to analyze the subjects that were scanned here at the University of Pennsylvania
## PREREQUISITES:
# Before running the script you need ... |
9ec985c0ea401e3d06a427086b557fa1d6b9628ed2abed1f5d6ef2efdf8eedce | Python | 9,256 | 201 | """Packed input preparation and CUDA replay of the canonical AIMNet computation.
Neighbor construction uses public reusable nvalchemi buffers. Only actual consumers
own long-range lists; streaming Coulomb itself needs no all-pairs matrix. D3 retains
exactly the reference neighbor policy, including its coordination-num... |
42eb297f72ebf0c270b19236fda65c76009455e82b77e7a481ed74d35316ca23 | Python | 9,258 | 247 | # -*- coding: utf-8 -*-
from pyriemann.classification import MDM
from pyriemann.tangentspace import TangentSpace
from pyriemann.estimation import Covariances
import time
from sklearn.pipeline import make_pipeline
from sklearn.tree import DecisionTreeClassifier
from sklearn.linear_model import LogisticRegression, SGDCla... |
b516ece6600841f6ecca7bad18e9e322a382b566b7ab3dba301e5ca728bb1e80 | Python | 9,275 | 218 | 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... |
b721af54dedcc6e08ff8b28884726d8a15349095d6ee4ebec3d2486dab8a92bf | Python | 9,278 | 228 | import utils
import json
import re
from elasticsearch import Elasticsearch
from semquery import SemEHRES
from os.path import isfile, join
from os import listdir
class AnonymiseRule(object):
def __init__(self, rule_file):
self._rules = utils.load_json_data(rule_file)
@staticmethod
def rul_extract... |
355d76d2f53e9b518cfd629314b864633180767e45241470aefafbd2d0ae0683 | Python | 9,280 | 229 | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
from mmcv.utils.misc import deprecated_api_warning
from mmpose.core import imshow_keypoints, imshow_keypoints_3d
from ..builder import POSENETS
from .top_down import TopDown
@POSENETS.register_module()
class Interhand3D(TopDown):
"""T... |
129d5646ec729d1e08bbac8b26ea855694c3cd2015682e51045214e71021172b | Python | 9,281 | 232 | from concurrent.futures.thread import ThreadPoolExecutor
from logging import getLogger
import numpy as np
from base.results.sleep_stage_tracker import SleepStageResultTracker, add_f1_to_results
from base.utils import calc_mode, choice
logger = getLogger(__name__)
class USleepNChannelsSSResultTracker(SleepStageResu... |
a9bbc3bfc6e960efd3bf0c8837c5d8f3e8d9a37e5fd0b47805ec5dbaa2422652 | Python | 9,283 | 294 | from mmcv import Config
from mmpose.datasets import build_dataset
from mmpose.models import build_posenet
from mmpose.apis import train_model
import mmcv
import json
import os.path as osp
from collections import OrderedDict
import tempfile
import numpy as np
from mmpose.core.evaluation.top_down_eval import (keypoint... |
589d4fedf9b32c2f83e3b9049fcd7ae65fe7f197335aac83aadeda473b1d2071 | Python | 9,284 | 266 | from typing import Optional, Tuple
from torch import Tensor, nn
from torch_geometric.nn import MessagePassing
from torchmdnet.models.utils import (
NeighborEmbedding,
CosineCutoff,
Distance,
rbf_class_mapping,
act_class_mapping,
)
class TorchMD_GN(nn.Module):
r"""The TorchMD Graph Network arch... |
2e91a252d1b259e555bb9d3a9f0068c7d2be6e40b511fcd2eb78e1f26abc64eb | Python | 9,289 | 192 | ############################################
# imports
############################################
from oligo_designer_toolsuite._exceptions import ConfigurationError
from oligo_designer_toolsuite.oligo_property_calculator import calc_detect_oligo, calc_padlock_arms
from oligo_designer_toolsuite.oligo_property_filter... |
8281fab13afc495f9ca0e4f3c72314949e48c31761b911a22b90fc503e0dceb8 | Python | 9,292 | 239 | import jax
import jax.numpy as jnp
import numpy as np
import matplotlib.pyplot as plt
import utils
import tensorflow as tf
import os
def plot_pred(equation, prompt, mask, query, ground_truth, pred, to_tfboard = True):
'''
plot the figure
@param
equation: string
prompt: 2D array, [len(prompt), prompt_dim... |
dc8c66868e0a1d7b6ed403d00e1668fa79b489dbd1a65b68ebc1bb16dc03452a | Python | 9,296 | 296 | """Evaluation functions for the daart package."""
import itertools
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.metrics import recall_score, precision_score
from typeguard import typechecked
from typing import List, Optional, Union
from daart.io import make... |
f2a187e94b77653068c89300105aa415be21d93a0990004c56ed9c65dc92cd60 | Python | 9,296 | 260 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 21:38:51 2020
@author: ravinderjit
"""
import json
import numpy as np
import scipy.stats as spst
import matplotlib.pyplot as plt
from scipy.io import loadmat
import matplotlib.colors as mcolors
import os
#import pickle
#fig_path = '/home/ravin... |
c26b29edd77020e36e04acc890f1c64bfc2a4c48ad9ecb0b5bbfe6814c6f0d05 | Python | 9,302 | 279 | from argparse import Namespace
import pytest
from clipkit.args_processing import process_args
from clipkit.helpers import SeqType
from clipkit.exceptions import StopCodonValidationError
from clipkit.modes import AmbiguityHandling, StopCodonMode, TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS, DEFAULT_N... |
a82ec5efc3292b67e2dc601490509fcf6630c9d071cc199112abdf89eb4edce6 | Python | 9,311 | 232 | """
Reference:
Perslev, M., et al. (2021). U-Sleep: resilient high-frequency sleep staging.
npj Digital Medicine, 4(1), 72.
"""
from logging import getLogger
import numpy as np
import torch
from base.config import Config
from base.data.base_dataset import BaseDataset
logger = getLogger(__name__)
class Usl... |
e9fa38b158f8bf73f9da51309f0e402034576ebd232d1c5ae8e2e0b26ca75de1 | Python | 9,314 | 212 | # training surv-based network with pretrained model
# Created: 5/21/2021
# Status: OK
# Consider merge into 1 main file
# CUBLAS_WORKSPACE_CONFIG=:4096:8 python transfer_main.py
# import torch.nn as nn
import sys
import torch
import numpy as np
import pandas as pd
sys.path.insert(1, '../plot/')
from networks import CN... |
12c4a8a39c923056d03628d7e4bc1c25b8ba0ccd123af8e0a262ed02ca4e9ae8 | Python | 9,321 | 275 | from typing import Tuple, Any
import numpy as np
import math
from eagerpy import astensor, Tensor
from eagerpy.tensor import TensorFlowTensor, PyTorchTensor
def rotate_and_shift(
inputs: Tensor,
translation: Tuple[float, float] = (0.0, 0.0),
rotation: float = 0.0,
) -> Any:
rotation = rotation * math.... |
dede84504264c82d6926c3577e61bc58940982861287c74fb658dfdfc0b5f75d | Python | 9,325 | 297 | # -*- coding: utf-8 -*-
#
# p4 documentation build configuration file, created by
# sphinx-quickstart on Sun Jul 12 07:16:21 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All co... |
6a49c96902395de4db766fdc4f7a2c01417e7889fd4e45857153c56f3e4d0be0 | Python | 9,326 | 222 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 18 12:01:35 2018
@author: roshan
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from collections import Counter
import seaborn as sns
from copy import deepcopy
def plotGraph(df, cat, plt_type='bar',
dropn... |
47994c173299d378957fd518bc79dc4b3fdab0f69ca9559943df07a0dcf94da1 | Python | 9,330 | 256 | # 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 torch
import numpy as np
from torchmdnet.models.utils import OptimizedDistance
from torch import nn
fr... |
fec35592a74da94d44f6cb6e270d33321ed58cc73414276c116fa5966735406e | Python | 9,332 | 233 | import json
import pandas as pd
import math
import sys
import os
import logging
import numpy as np
import matplotlib.pyplot as plt
sys.path.insert(1, '../utils/')
import functions_ZZ_extraction as fct
from import_data import *
# Initialisation
summary_file_path = sys.argv[1]
fishlabel = str(sys.argv[2])
trial = str... |
131cda5856de7fdc80af306f87d1ec57786b746b9324763f3b24b49de0007dae | Python | 9,348 | 230 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 30 16:21:33 2021
@author: fhu14
Module handling the implementation of the Lennard-Jones dispersion
correction.
The form for the total energy is now defined as follows:
E_tot = E_elec + E_rep + E_ref + E_disp
Where the electronic energy (E_elec) comes from the ... |
24c57dc92d4824bd3ef4ea63ce77450490011706886c080ec529ce7b7c61103c | Python | 9,350 | 250 | import os
import math
import torch
import torch.nn as nn
import numpy as np
from einops import repeat
def make_beta_schedule(schedule, n_timestep, linear_start=1e-4, linear_end=2e-2, cosine_s=8e-3):
if schedule == "linear":
betas = (
torch.linspace(linear_start ** 0.5, linear_end ** 0.5, n_... |
b588f9e396182e3ea2038ba7e97c9acb4aa4efbe2544ac76c2439e5493b4f344 | Python | 9,350 | 263 | import numpy as np
from scipy.special import erf
from .Exceptions import ConvergenceFailure
from scipy.optimize import fmin_powell
def get_smearing_function(scheme_name):
"""
This function returns the requested smearing function.
Parameters:
- scheme_name (string): The name of the desired smearing ... |
5b7d8cb80036922e602c16d442e3f1b989213b3e20b092be6c3ece6f2a71843f | Python | 9,375 | 281 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models import build_loss
def test_rle_loss():
# test RLELoss without target weight(default None)
loss_cfg = dict(type='RLELoss')
loss = build_loss(loss_cfg)
fake_pred = torch.zeros((1, 3, 4))
fake_label = torc... |
91285257cf87f64225f16f2e6c4e3b2eb1c7bf9e000a7b7fd1ff923f04f34b9b | Python | 9,386 | 287 | # 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 threading
import pytest
import torch
from torch.distributions import MultivariateNormal
from tqdm.auto import tqdm
from sbi.inference.posteriors ... |
1ac83cf5517a1e0853b7ac61da31403425a8e3933e9b230877abb54b61592f76 | Python | 9,389 | 247 | import os
import math
import torch
import torch.nn as nn
import numpy as np
from einops import repeat
def make_beta_schedule(schedule, n_timestep, linear_start=1e-4, linear_end=2e-2, cosine_s=8e-3):
if schedule == "linear":
betas = (
torch.linspace(linear_start ** 0.5, linear_end ** 0.5, n_... |
648aa74155c871a5ba6f09241a2bc613750b7e6089e8f3532a9621052788b29c | Python | 9,390 | 278 | """Validate PLR scalar return types and reset behavior."""
import numpy as np
import pandas as pd
import pytest
from sklearn.linear_model import LinearRegression
from doubleml.plm.datasets import make_plr_CCDDHNR2018
from doubleml.plm.plr_scalar import PLR
N_OBS = 200
N_FOLDS = 3
N_REP = 2
N_REP_BOOT = 314
np.rando... |
76cc8ec3da0da1c7b593675e3ebbe0d6a2e57757153dc903a4c49339df5f9920 | Python | 9,401 | 306 | # Source:
# https://github.com/githubharald/CTCDecoder/blob/master/src/BeamSearch.py
from __future__ import division, print_function
import pathlib
from .lm import LanguageModel
class BeamEntry:
"information about one single beam at specific time-step"
def __init__(self):
self.prTotal = 0 # blank... |
913b1ced06cd5b13fc96a563b0e7055cbc2297d6239d3162ec7f0a7ef295dbc4 | Python | 9,402 | 312 | import torch
from torch import nn
from itertools import starmap
import yaml
from yaml.loader import SafeLoader
import torchvision
dims = '../config/models_dims.yaml'
params = '../config/params.yaml'
with open(dims) as f:
config = yaml.load(f, Loader=SafeLoader)
# batch norm and dropout parameter... |
59e61ca5e2ccc0a32f6d886c009889e68aa0642c9569a7ff170fdc9c843a1bf4 | Python | 9,404 | 174 | from typing import Sequence, Union, Optional, Iterable, List, Dict
import neo
import numpy as np
import numpy.typing as npt
import quantities as pq
from pydapsys.file import File
from pydapsys.page import DataPage, WaveformPage, TextPage, PageType
from pydapsys.toc.entry import Stream, StreamType
from pydapsys.util.f... |
0352514db50e9847cbfaaf85c31c905c1fc1548ced076659c0631c48464277b1 | Python | 9,406 | 196 | import argparse
import pickle
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from parse_hparam_search import get_task_data
# Evaluation script for random-search-based hyperparameter optimization.
# DEFINE PARSER
parser = argparse.ArgumentParser(description='Selbstaufsicht... |
8f49ab2fd82b373f09bb510114bb06d9854822df90e2f2c6c6408443063fc43c | Python | 9,406 | 220 | 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... |
b4a134488b6d52afa323345c91ec54341b619a8940e432f3cdbb565d5409a397 | Python | 9,431 | 237 | """
Created on Mon Jan 17 10:09:58 2022
@author: daniel
"""
import shelve
import os
from tempotron.main import Tempotron
from phase_to_rate import information_measure
import numpy as np
import matplotlib.pyplot as plt
import sqlite3
import sys
import multiprocessing
import argparse
import uuid
import statsmodels.api ... |
28d3e8c61ec492582c5b6cdd53644837625d8d3b5c487b53b2e2aed0be460487 | Python | 9,438 | 223 | """Shared dense radial-vector AEV basis in one kernel each way (Triton).
Used by ``aimnet.modules.aev`` through its explicit inference-kernel dispatch,
independently of whether the calculator uses eager execution or CUDA graphs.
Reference math (``AEVSV`` with ``ops.calc_distances`` and ``ops.exp_expand``; dense mode,... |
263091691e1050bc91edbc62aaffac45be955004502b970310792ee28a35309f | Python | 9,439 | 255 | import os
import p4.func
import pickle
import math
import numpy
import glob
from p4.p4exceptions import P4Error
class McmcCheckPointReader(object):
"""Read in and display mcmc_checkPoint files.
Three options--
To read in a specific checkpoint file, specify the file name by
fName=whatever
To re... |
ca25a3dbd1674da07355020532cff4e1255ab224b34b50ec22462499c554746c | Python | 9,449 | 168 | #!/usr/bin/env python
"""
melt_somatic_vcf.py
Melts / merges somatic vcf files coming from the IAP.
Supported somatic callers: Freebayes, Mutect, Strelka and Varscan.
"""
import sys
import argparse
from itertools import izip_longest
import re
def melt_somatic_vcf(vcf_file, remove_filtered, tumor_sample):
try:
... |
751850f1e0907e9a0b24bd36447a9ea834c347d7b011e52bd2b9d9aa9f7c7814 | Python | 9,451 | 280 | import os
import os.path as osp
import numpy as np
import numpy.random as npr
import torch
import torch.distributed as dist
import torchvision
import copy
import itertools
from ... import sync
from ...cfg_holder import cfg_unique_holder as cfguh
from ...log_service import print_log
import torch.distribu... |
6d77d40ef34ff367b1205d067a3bb1c0846962673fda71dfe1162d2fd237e0c5 | Python | 9,468 | 237 | import hashlib
import os
import urllib
import warnings
from typing import Any, Union, List
from pkg_resources import packaging
import torch
from PIL import Image
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
from tqdm import tqdm
from .model import build_model
# from .simple_toke... |
9d5206eed84dded79dc7308eed803a27019fba528c77631813c976e8a773621d | Python | 9,469 | 263 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 23 15:05:14 2020
@author: baris
"""
import seaborn as sns, numpy as np
import matplotlib.pyplot as plt
import os
# from rate_n_phase_code_gra import phase_code, overall_spike_ct
from rate_n_phase_code_gra import phase_code, overall_spike_ct
import ... |
b94a9b62216a663e2923138b42c9439ccfa7b94cc8ca95729e2548c80afe785f | Python | 9,472 | 285 | """
Standalone AnySleep model implementation without Hydra dependencies.
This file provides a self-contained implementation of the AnySleep
model that can be used independently of the Hydra configuration system. It is
intended for:
- Quick experimentation without setting up the full training pipeline
- Integration int... |
783e17ef54b574b5d90c71f45f6ddb8c4eb4089b7e3f17db966f0ad0bb7b20ba | Python | 9,473 | 222 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdet.core import anchor_inside_flags
from ..builder import BBOX_ASSIGNERS
from .assign_result import AssignResult
from .base_assigner import BaseAssigner
def calc_region(bbox, ratio, stride, featmap_size=None):
"""Calculate region of the box defi... |
8047eb3357995f89f770547a3b4ce3e201a4ddea6995be0fc67c442412d61cc3 | Python | 9,482 | 170 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 7 19:12:34 2021
@author: fhu14
"""
#%% Imports, definitions
from .base_classes import LossModel, ModelPenalty
from .external_funcs import compute_mod_vals_derivs, generate_concavity_dict, generate_third_deriv_dict
from typing import List, Dict
import numpy as np
import t... |
c9444fff0c214beb5e8c121ed3eb64290de7f5d82dd6113cf9448e72f1433765 | Python | 9,495 | 244 | ############################################
# imports
############################################
import os
import shutil
import unittest
from Bio.SeqUtils import MeltingTemp as mt
from pandas import Series
from scipy.sparse import csr_matrix
from oligo_designer_toolsuite.database import OligoDatabase
from oligo_d... |
a6a98c2dc0fc6fbfe39b0fb7c5df6a4920dc66083f6d6d0a4dbc6b7595ed92c6 | Python | 9,502 | 278 | # This script demonstrates how to do batched minimization of molecules with AceFF torchmd-net models
# It uses TorchMD for the minimizer and integrator
# you can install it with:
# pip install torchmd
import matplotlib.pyplot as plt
from rdkit import Chem
from rdkit.Chem import rdDistGeom
from torchmdnet.models.model ... |
1c139553495e56eb64a26df0313c29d735dfde1b0b4266fa816276757bd06066 | Python | 9,509 | 228 | # coding=utf-8
# Copyright 2018 The Open AI Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... |
dd873eb523c84a9b2274443dceed9cf9c9655921e0199ff013dd37e62cb6761b | Python | 9,509 | 217 | """
General Data Loader and General Dataset
General purpose data loader and dataset.
## GPL License
## Author: Qi Chang<qc58@cs.rutgers.edu>
"""
import h5py
import math
import numpy as np
from skimage.util import view_as_windows
from torch.utils import data
from torch.utils.data import DataLoader
from torch.utils.data.... |
c97710cfe737b61c89b6b5bb707adfb65a2785ff1dd83600bad0eac6599ad50f | Python | 9,513 | 212 | import logging
import time
import torch
import wandb
from torch import nn
class FedNASAggregator(object):
def __init__(self, train_global, test_global, all_train_data_num, client_num, model, device, args):
self.train_global = train_global
self.test_global = test_global
self.all_train_dat... |
5ab89316bb5481f1a01caa78576b60aae270954c5d5b9346bc8b12c3c3d558ed | Python | 9,519 | 284 | import pytest
import torch
from mmdet.models.dense_heads import (DecoupledSOLOHead,
DecoupledSOLOLightHead, SOLOHead)
def test_solo_head_loss():
"""Tests solo head loss when truth is empty and non-empty."""
s = 256
img_metas = [{
'img_shape': (s, s, 3),
... |
f794356705b9850c8054c9775c4e3f131a802b1081a699e3cb12f78c53fa37c4 | Python | 9,528 | 174 | import jax
import jax.numpy as jnp
import numpy as np
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
import jax.tree_util as tree
import matplotlib.pyplot as plt
import models_gpt2_icon as mod... |
5d1adb4ff0f174d52b93268be665bcb8c438e2623069319f9116056122e29d1a | Python | 9,531 | 250 | '''
* 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... |
39968bfd731f78f1759f0d52f6b2ad46bbdae1a558a99147a0055a41d31f3117 | Python | 9,536 | 240 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 23 13:27:14 2022
@author: baris
"""
from phase_to_rate import grid_model
from neo.core import AnalogSignal
import quantities as pq
from elephant import spike_train_generation as stg
from scipy import ndimage
from matplotlib.colors import LinearSegm... |
45d9eb862c2f26ea7571e5037d4f4785e5b1ec10c23cbcfa85ba4d52562e654c | Python | 9,560 | 290 |
#set seed to reduce randomness
from numpy.random import seed
seed(1)
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['axes.prop_cycle'] = matplotlib.cycler(color=["#F4511E", "#FB8C00", "#FFB300", "#FDD835", "#C0CA33", "#7CB342", "#43A047", "#00897B", "#00ACC1","#3949AB"])
moddata = data... |
995088ac579e9f8bed4656f0e58748b64f27ca8df3dc23be8c9bd428c9828b6c | Python | 9,562 | 224 | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule, constant_init, normal_init, trunc_normal_init
from mmcv.runner import BaseModule
from ..builder import NECKS
from ..utils import TCFormerDynamicBlock, token2map, token_int... |
389fdd0ed7640ba6b680bc5281838b8ec84c9fd9805f9dd4757ad74075a60b83 | Python | 9,563 | 219 | import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.layers import LSTM, Dense, Dropout, Activation, SimpleRNN, Bidirectional, Flatten, \
BatchNormalization, AvgPool1D
from tensorflow.keras.layers import Conv2D, MaxPool2D, Reshape
import numpy as np
def Model_acp():
# left model... |
40ff5ed1b359b77a6bda153e6f93c3662a020887594e9c1018b36c8755a8973d | Python | 9,600 | 204 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 7 19:02:00 2021
@author: fhu14
"""
#%% Imports, definitions
from MasterConstants import Model, RawData
from typing import List, Dict
import numpy as np
Array = np.ndarray
from Spline import JoinedSplineModel, get_dftb_vals
import torch
Tensor = torch.Tensor
#%% Code beh... |
498e4348f1e9383bcd6d0c954a03e81dac8de8647b12f6085b71e8fb07116c08 | Python | 9,603 | 261 | import argparse
import os
import matplotlib.pyplot as plt
import mmcv
import numpy as np
from matplotlib.ticker import MultipleLocator
from mmcv import Config, DictAction
from mmcv.ops import nms
from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps
from mmdet.datasets import build_dataset
def parse_args():... |
b536c0fa168e902e1eb6ede011e11c1bf75e6dc7f1a3163cfc2366b334727eb0 | Python | 9,638 | 260 | import utils
import re
import json
import joblib as jl
from study_analyzer import StudyAnalyzer, StudyConcept, load_ruler, load_study_settings
from os.path import isfile, join
import logging
from concept_mapping import get_concepts_names, get_umls
from concept_mapping import icd10_wildcard_queries, get_umls_client_inst... |
c2c1a008e349c9fb1e068e338a3cc81bcac0465842f1f4e5ef00fe9167a0e54d | Python | 9,654 | 204 | import random
import numpy as np
import torch
from torchvision.utils import make_grid
from base import BaseTrainer
from utils import inf_loop, MetricTracker
class Trainer(BaseTrainer):
"""
Trainer class
"""
def __init__(self, model, criterion, metric_ftns, optimizer, config, data_loader,
... |
6895a370f7d9aae71dc50d3010f157ba85ab1dc31cb2ae4f86e9dffe1fcdd0e4 | Python | 9,663 | 286 | import pickle
import numpy as np
from math import pi, cos, sin
from scipy.spatial.distance import pdist, squareform
import csv
import os
import pandas as pd
def load_fasta(dir):
"""
Load peptide sequences and labels from ACPXXX.txt
:param dir:
directory of ACPXXX.txt
:return:
... |
73d58a9aa830f0a837966db1e7ac585e42acc6c72d27d4114d156e19dc8206d6 | Python | 9,671 | 266 | import itertools
import re
from typing import Union
import networkx as nx
import numpy as np
import pandas as pd
"""
Original file from https://github.com/marakeby/pnet_prostate_paper/blob/master/data/pathways/reactome.py
Modified to fit our repo.
"""
class Network:
"""
A class for building and analyzing a ... |
bce26acd3ae9b747857f6290b865aea148d59172ff96d74c9f70788040c65366 | Python | 9,675 | 213 | # 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, Union
import torch
from torch import Tensor, nn, ones
from torch.distributions import Distribution
from torc... |
4150dcb50840b52020f517e85046cea2e76be609b5942f4a4a727a9a05e9581a | Python | 9,676 | 245 | import statistics
def mean(list):
try:
mean = statistics.mean(list)
except statistics.StatisticsError:
mean = 0
return(mean)
def stdev(list):
try:
stdev = statistics.stdev(list)
except statistics.StatisticsError:
stdev = 0
return(stdev)
def depth_search(depth_f... |
2c16bd90337596a6b098299f14264648a2d20c8d7c71b07b9c46f497a2c278af | Python | 9,678 | 261 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from .builder import IOU_CALCULATORS
def cast_tensor_type(x, scale=1., dtype=None):
if dtype == 'fp16':
# scale is for preventing overflows
x = (x / scale).half()
return x
def fp16_clamp(x, min=None, max=None):
if not x.is_cud... |
41a41826ca233086a4547045a0ed606adedfebbd99770d00c270b0acf45cb044 | Python | 9,687 | 263 | """
The main training script for training on synthetic data
"""
import torch
import torch.utils.data
import torch.nn as nn
import torch.optim as optim
import speechbrain.nnet.schedulers as schedulers
import argparse
import importlib
import json
import os, glob
import re
import multiprocessing
import time
import sep... |
93fe22edbdcded501798ee9d2bed5c25e99ebce4c5d6c111b33c96b53f718f5b | Python | 9,691 | 316 | #program annotate a merged erds results with merged cnvnator results
import os
import sys
import re
import getopt
import functions
#file names
input_file_name = ""
output_file_name = ""
sample_id = ""
annot_file_name = ""
i_map = {}
alt_id = {}
#% overlap cutoff
overlap_cutoff = 0
overlap_type = "one... |
b94f330ec0c9584a1d3cd1fc0be9731e34ed32f38e0d29640a8598b8d8afafd2 | Python | 9,696 | 251 | # 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 cross_entropy(pred,
label,
weight=None,
reduction='mean',
a... |
4be5f39ad34ca55eb8ca7ae120fd8c898487eed74c5ab67b615ab6c83dd037cf | Python | 9,711 | 301 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
import logging
import numpy as np
import pytest
import torch
from test_parallel_wavegan import (
make_discriminator_args,
make_mutli_reso_stft_loss_args,
make_residual_discr... |
c8733d81d783bda194c2be23415edc64cd1ad5bcb77f9f1c80616ac85f379e3f | Python | 9,712 | 281 | # ------------------------------------------------------------------------------
# Adapted from https://github.com/HRNet/HigherHRNet-Human-Pose-Estimation
# Original licence: Copyright (c) Microsoft, under the MIT License.
# ------------------------------------------------------------------------------
import torch
im... |
6049957f2181b776ae4d4c006cad58020138ff40760938aca8995ffbb0afdce3 | Python | 9,716 | 221 | ############################################
# imports
############################################
import inspect
import os
from pathlib import Path
import yaml
from oligo_designer_toolsuite._exceptions import ConfigurationError
from oligo_designer_toolsuite.pipelines._utils import base_log_parameters, base_parser
... |
03218ca13f44063584f02907c86dce8a6cdfd1eed0059aa664c8c2019294c2d6 | Python | 9,718 | 276 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import math
import os
import os.path as osp
import random
import socket
from datetime import datetime
import mmcv
DEFAULT_TEST_ARGS = dict(
gpus=1,
gpus_per_node=1,
cpus_per_task=5,
)
DEFAULT_TRAIN_ARGS = dict(
gpus=8,
gpus_per_node=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.