sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
1bd945fee84bdfa84fad348e1abb29dec33705aa2918598659c5adaea45122a6 | Python | 17,452 | 468 | #!/usr/bin/python
"""
Model architecture definition
Multiple inputs: https://www.pyimagesearch.com/2019/02/04/keras-multiple-inputs-and-mixed-data/
Multiple outputs: https://github.com/rahul-pande/faces-mtl/blob/master/faces_mtl_age_gender.ipynb
"""
import sys, os
from deeplearning.architecture_features import *
... |
a3a969dcb9a8cbc09184af04b609eab5ec13ebeb1ece1b91166d59947a3c062e | Python | 17,459 | 425 | import torch
import torch.nn as nn
import torch.nn.functional as F
from contextlib import contextmanager
from lib.model_zoo.common.get_model import get_model, register
# from taming.modules.vqvae.quantize import VectorQuantizer2 as VectorQuantizer
from .diffusion_modules import Encoder, Decoder
from .distributions im... |
c9135654f936bf5be8e3b56d3519c2e36e246e71ed69388c7091e1e97294c32d | Python | 17,460 | 479 | import requests
import sys
import argparse
import json
import numpy as np
import os
import os.path
import re
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import matplotlib.colors as colors
import bone
import cStringIO
import base64
acolor = ["#00CC00", "#D8A03D","#EC008C",
'cya... |
a167bbd441dd9555e386086f176fc500c3b55a5a5c3e9d6e2c81bfc2cc9016a4 | Python | 17,485 | 523 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmpose.models import AEHigherResolutionHead, AESimpleHead, DEKRHead
def test_ae_simple_head():
"""test bottom up AE simple head."""
with pytest.raises(TypeError):
# extra
_ = AESimpleHead(
... |
94f4a0fc42b2aaa7a5f87db5fd7d36c1aac2ad8d141a52f1d8dd8fe0c8f6fb0f | Python | 17,514 | 564 | """Signal processing utilities, filters, and data post-processing routines.
Every filter comes in form of a pair:
1) filter class
2) filter commodity function
The commodity functions internally create a filter class and invoke the
corresponding ``process`` method. Often, however, usage requires to apply a
... |
28babe3a926b96011d4cc65f5e04e0356ec468d4d5f0b025590001f2b2ed5598 | Python | 17,522 | 339 | import torch
from models.perception_loss import vgg16_feat, perceptual_loss
from util.util import grayimg
from . import networks
from .base_model import BaseModel
import numpy as np
class Dadgan3chConsistencyModel(BaseModel):
""" This class implements the pix2pix model, for learning a mapping from input images to... |
bdf10f99e06c64eacda1c6f6c1b729e86132432ee3e05b89af77b84101b230ff | Python | 17,524 | 422 | # ----------------------------------------------------------------------- #
# Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
# #
# Software Name: Fast Autonomous Scanning Toolkit (FAST) #
# By: Argonne Na... |
1cae608286a0de57c8a524b845a50e2bc898bb4e7700aeb7ebc405578bca0c5c | Python | 17,535 | 442 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import numpy.random as npr
import copy
from functools import partial
from contextlib import contextmanager
from lib.model_zoo.common.get_model import get_model, register
from lib.log_service import print_log
version = '0'
symbol = 'v... |
63804c32dcf9033c106f7c4e358fa664a3f82fa5c6e40e92acc3f3d0b0446a23 | Python | 17,551 | 353 | import os
import torch
import torchvision
from torch import nn
from models.UNet import setup_unet
from models.perception_loss import vgg16_feat, perceptual_loss
from util.util import grayimg
from .base_model import BaseModel
from . import networks
from parse_config import ConfigParser
import parse_config
class Dadga... |
dddd3e1cbd1f9fdc2c032c2feac778f3f563c65b71109ad3cbfb0ca4315b35f0 | Python | 17,559 | 464 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import glob
import json
import os.path as osp
import pickle
import tempfile
import warnings
from collections import OrderedDict
import mmcv
import numpy as np
from mmcv import Config, deprecated_api_warning
from mmpose.core.camera import SimpleCamera
from mm... |
a8165af58fe0a88e300cdebabf6ef05f3db11f7de919da9c5da566763db5a155 | Python | 17,593 | 493 | # 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
from torch import eye, zeros
from torch.distributions import MultivariateNormal
from sbi.inference import MNL... |
cb1fbee9d9c7e56d4398a6b7b673dd064aff02a3aa066620d58fda9843149b8b | Python | 17,602 | 486 | # 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 inspect
import warnings
from dataclasses import FrozenInstanceError, fields
from typing import get_args
import pytest
import torch
import zuko
fro... |
c4eeb19841febee2d165106d8fc3abaad4c9d5cf13852de513515b2b6d9f78f4 | Python | 17,608 | 474 | import matplotlib
matplotlib.use('agg')
import os
import sys
import argparse
import h5py
import random
import numpy as np
import matplotlib.pyplot as plt
from skimage.transform import resize
import torch
import torch.utils.data as data
import yaml
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../"... |
37f1cbeac58eb7ee2a39176d40b4c0380437e22adb06ba4c7ef45f4a3e607e53 | Python | 17,674 | 399 | import logging
import torch
from typing import List, Tuple, Union
from collections import defaultdict
from rdkit import Chem
from ..data import get_atom_features, get_atom_features_dmpnn, get_atom_features_chemi_net
from ..data import get_atom_features_deep_chem_stable, get_atom_features_duvenaud
from .chemprop_rdkit... |
992e8d1ba8188a48541bd87f959c4d8c906e3b592951dab2681a74e119157a4b | Python | 17,693 | 491 | import os
import nibabel as nib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from nilearn import plotting
from typing import Dict
from tqdm import tqdm
from statistics.mlp_output_wrappers import name_to_lobe_map
from statistics.shap_viz.utils import load_input, load_rid_and_cluster, cmap_tra... |
31d23076ae52a89f786659820a1dd32983dff1dadc11a58bdde5e8e25f46669e | Python | 17,694 | 441 | ############################################
# imports
############################################
import os
import shutil
import unittest
from Bio.Seq import Seq
from Bio.SeqUtils import MeltingTemp as mt
from oligo_designer_toolsuite.database import OligoDatabase
from oligo_designer_toolsuite.oligo_property_filte... |
cbf10877e1b28b368b3f6651c044e7a0fa19921359e34ac2bd0aa5843ac17d46 | Python | 17,700 | 437 | """
network training functions
"""
import numpy as np
import tensorflow as tf
import sys
sys.path.append("../../python/")
from lib.simu import *
from scipy.signal import convolve
# def DCloss_mag(y_pred,y,x):
# mask = tf.math.greater(x,0)
# return tf.math.reduce_mean(tf.math.square(tf.math.multiply(y - y_pred,m... |
8b88f3dd7e9bc4ffd050e832a525b29dc5fd25827470a0513f9ccb5ada3cdc97 | Python | 17,703 | 352 | import matplotlib
matplotlib.use('agg')
# import copy
import logging
import time
# import torch
import wandb
import numpy as np
# from torch import nn
import matplotlib.pyplot as plt
from .utils import transform_list_to_tensor, Saver, EvaluationMetricsKeeper
class FedMedGanAggregator(object):
def __init__(self, ... |
cf582fa61bf809e1e4b7f8c5b1829fdbe44ac7c62059b1a47c0f06caa04efb60 | Python | 17,776 | 477 | import matplotlib
matplotlib.use('agg')
import os
import sys
import argparse
import h5py
import random
import numpy as np
import matplotlib.pyplot as plt
from skimage.transform import resize
import torch
import torch.utils.data as data
import yaml
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../../"... |
a19970fc31b7776bcb7d8d07575eb0ad0a11daacef45e862b18913c027c668dc | Python | 17,800 | 391 | import re
import torch
from torch import nn
import numpy as np
import os
import subprocess
import torch
from transformers import XLNetTokenizer, XLNetLMHeadModel
from .protein_mpnn.protein_mpnn_utils import ProteinMPNN
import pickle as pkl
from pathlib import Path
from tr_rosetta_pytorch import trRosettaNetwork
from t... |
473fc0bde1688ed45ecd68f70dcff353bd3efd57cd92cd70562a75a2439c10a6 | Python | 17,885 | 493 | # -*- coding: utf-8 -*-
import math
import numbers
import numpy as np
import collections
from operator import itemgetter
try:
import matplotlib.pyplot as plt
except:
pass
from Rotations import rotation_matrix_atom, rotation_matrix_bond, \
get_axis_rotation_matrix
from Elements import ELEMENTS
def to_car... |
51b761454db2f6e00a1fe9fb6d3c0d6c70da44aa27ee53426d09a6852ba3b592 | Python | 17,907 | 496 | # -*- coding: utf-8 -*-
import collections
import math
import numbers
from operator import itemgetter
import numpy as np
try:
import matplotlib.pyplot as plt
except:
pass
from Elements import ELEMENTS
from Rotations import (get_axis_rotation_matrix, rotation_matrix_atom,
rotation_mat... |
aabf4a85f2805bc12fe46140c73045555e402e5c9846cd96cc8bd3afc4d497dc | Python | 17,959 | 523 | # Copyright 2013 Graham McVicker and Bryce van de Geijn
#
# 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
#
# Unless required by applicable la... |
ca1dc93641f2c52b548d46dbc3dc3bd80a7ea9970d7617cb2867e73b1824361f | Python | 17,963 | 487 | import json
import os
import pathlib
import random
import warnings
import cv2
import numpy as np
import torch
import torchvision
import torchvision.transforms as T
from PIL import Image
from torchvision import transforms
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
import exsclaim.utilities.... |
3183ee6b376bb332193e63f2b8c94f2c51294af96a72bd908736d9732ae05fb3 | Python | 17,971 | 498 | #mapEnhancerFromFactor.py
'''
PROGRAM TO STITCH TOGETHER REGIONS TO FORM ENHANCERS, MAP READ DENSITY TO STITCHED REGIONS,
AND RANK ENHANCERS BY READ DENSITY TO DISCOVER SUPER-ENHANCERS
APRIL 11, 2013
VERSION 0.1
CONTACT: youngcomputation@wi.mit.edu
'''
import sys
import ROSE_utils
import time
import os
from stri... |
c74dfc98e32d477e46ed8e8ffe088af70e312b6ada96beaf0bd93c61b395acec | Python | 17,998 | 283 | # 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 sys
import os
import yaml
import argparse
import logging
import torch
import lightning.pytorch as pl
from lightn... |
1b4b97c321ac6c604a64c6f562aee0c8726b1f87883ed3180c22e7ad7dd9a3bd | Python | 18,004 | 311 | import time
import os
import sys
import glob
import json
from pathlib import Path
import subprocess
from A_config import a10_config
from C_model_setting import c100_save_model_specs
from B_preprocess import b100_load
from D_modelling import d090_model_wrapper
from F_post_processsing import F100_analyze_hindcast_output
... |
8d9b75109d4351b9770aacd25c0889577e67e8a5429f95e5563b852e8c43510a | Python | 18,005 | 478 | """Helper functions for model training."""
import copy
import os
import numpy as np
import pandas as pd
import torch
from torch import optim
from tqdm import tqdm
from typing import List, Optional, Union
from typeguard import typechecked
from daart.io import export_hparams
from daart.io import make_dir_if_not_exists
... |
66936d9cb8d7d382e182df6f90d798401ef4102c4f6d556d96d66bb29da0a413 | Python | 18,016 | 423 | # 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 math
from typing import Callable, Dict, Literal, Optional, Tuple, Union
import torch
from torch import Tensor
from sbi.inference.posteriors.base_... |
f2a03f45aea08f929858ff23304caae9a5f6a3174169bb329547de832626d0d9 | Python | 18,025 | 412 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import bias_init_with_prob, normal_init
from mmcv.ops import batched_nms
from mmcv.runner import force_fp32
from mmdet.core import multi_apply
from mmdet.models import HEADS, build_loss
from mmdet.models.utils import gauss... |
d5f1c5bcd55fc39004d71c5aa155e775f9f20c2cec0cd23194dfe5d3cdeee280 | Python | 18,035 | 450 | # Network Models
# Created: 5/21/2021
# Status: OK
# Consider merge into 1 main file
import torch
import torch.nn as nn
import copy
import sys
import matplotlib.pyplot as plt
class _CNN_Pre(nn.Module):
# The Model that will be used for pre-trained model
def __init__(self, drop_rate, fil_num=64, in_channels=1, ... |
6bb5779dca35fac173f4dd9fcc9a72c14ecc2d20fd066446869484efca65fd01 | Python | 18,116 | 368 | import torch
import tensorflow as tf
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
tf.config.set_visible_devices([], device_type='GPU')
from pprint import pprint
import jax.tree_util as tree
import numpy as np
import pytz
from datetime import datetime
import utils
from absl import app, flags, logging
... |
563223ac76916938d10c6db747f41b756c1645937965afaba1168a34c39ed075 | Python | 18,142 | 417 | ############################################
# Imports
############################################
import os
import subprocess
import pandas as pd
from oligo_designer_toolsuite._exceptions import ConfigurationError, DatabaseError
from oligo_designer_toolsuite.database import OligoDatabase
from oligo_designer_toolsu... |
a8ce1789ccaf620e99561842166aae1900e0ca24521a024bef37cc7387e41dd0 | Python | 18,164 | 482 | """Helper functions for model training."""
import os
import numpy as np
import pandas as pd
import torch
from tqdm import tqdm
from typing import Optional, Union
from typeguard import typechecked
from daart.io import make_dir_if_not_exists
# to ignore imports for sphix-autoapidoc
__all__ = ['Logger', 'Trainer']
cl... |
74d30d766913d4d4a4d07a7b396222bdf8b9973ed81b2c9a2e5cc55afed9fa5c | Python | 18,207 | 513 | # -*- coding: utf-8 -*-
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""Parallel WaveGAN Modules."""
import logging
import math
import numpy as np
import torch
from parallel_wavegan import models
from parallel_wavegan.layers import Conv1d, Conv1d1x1
from parallel_wavegan.lay... |
3d98365b8d56677c7bb3e96f3d8ef897cf2bb43e193b9ab39e2481b3460d536e | Python | 18,234 | 489 | # -*- coding: utf-8 -*-
import collections
import difflib
import itertools
import numpy as np
from spacy import load
from spacy.matcher import Matcher
from .captions import interpret as interpret
from .captions import lists
from .captions import regex as regex
from .utilities import files
def load_models(models_pat... |
6bf79a499319a48dd9be0f69f31798424548f222e5d9ac4b3c01fffcb4f2eff8 | Python | 18,297 | 553 | """Warp kernel for brute-force neighbor list computation.
Uses triangular indexing: 1 thread per unique pair (i, j) where i > j.
Supports triclinic PBC, batching, self-loops, and transpose pairs.
Compile-time specialization via wp.static() eliminates runtime branches
for use_periodic, include_transpose, and loop. Sp... |
d7c702831c00aac6a7d64233ef57474794ce75ba2040e431f7d751ed4217564a | Python | 18,309 | 496 | import sys
import os
import numpy as np
import tables
import chromosome
import argparse
import gzip
import util
# TODO: change output dir--make command line arg?
OUTPUT_DIR = "."
SNP_UNDEF = -1
class SNP(object):
def __init__(self, chrom, pos, name, ref_allele, alt_allele):
self.chrom = chrom
... |
ea63dc16327816ebd3dc2129fd083737bf5c66486b678cc5a709d576fcc8ed4c | Python | 18,325 | 429 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 26 09:58:05 2021
@author: tungbioinfo
"""
import pandas as pd
import numpy as np
pd.options.mode.chained_assignment = None
pd.set_option("display.max_columns", 60)
import warnings
warnings.simplefilter("ignore")
import matplotlib.pyplot as plt
... |
e76a2897434104063c2c1d601a758d96d78d2c11a446dcf54d95792d0027710a | Python | 18,328 | 518 | # 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 dataclasses import asdict
from typing import Union
import pytest
import torch
from pyro.distributions import InverseGamma
from torch import Tensor
f... |
0696aac09c464db8113e56acf08475bc64a3b4b40a51459208e90d540bc89903 | Python | 18,386 | 315 | import numpy as np
import matplotlib.pyplot as plt
import mysrc.constants as cst
# -----------------------------------------------------------------------
def computingMinMaxPerSamplePerBand(Xt, D):
Xt_shape = Xt.shape
if D == 1:
min_per_sample = np.reshape(np.amin(Xt, axis=1), (Xt_shape[0], 1, Xt_shap... |
d4a00195536c34eb16276bc9eb790f96df7178b6c05e4190a8651660755f4525 | Python | 18,393 | 500 | import os
from PyQt5 import QtOpenGL, QtWidgets
import time
import sys
import signal
import moderngl
import numpy as np
import pandas as pd
import platform
import qimage2ndarray
from skimage.transform import downscale_local_mean
from flystim import stimuli
from flystim.trajectory import make_as_trajectory, return_for... |
8fc150f9db498b043cf5443067731e789b776b89502bc0a7c1b13ca9a302569b | Python | 18,411 | 419 | """Regression tests for CUDA graph ownership, invalidation and public API contracts.
These compare against the unchanged regular calculator, not another copy of the
graph engine. In particular, correctness must survive returning to an *old*
layout after callers mutate their tensors, and changes invisible at the origin... |
e9e046802822ef3518ed61695eff63bdce30070659340a08892e510718e6eaa7 | Python | 18,415 | 713 | # -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
import powerlaw
print(powerlaw.__version__)
# <codecell>
%pylab inline
# <markdowncell>
# # Set up
# <codecell>
import pylab
pylab.rcParams['xtick.major.pad']='8'
pylab.rcParams['ytick.major.pad']='8'
#pylab.rcParams['font.sans-serif']='Arial'
fr... |
ea769e19a1c62f86c1972803318f02490403b52584191b5ef455c881b0cc3860 | Python | 18,427 | 418 | # code from gmum/MLinPL2019_cheminfo_workshops and gmum/geo-gcn
import os
import logging
import numpy as np
import pandas as pd
import torch
from torch_geometric.data import Data
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import MolFromSmiles
from typing import Optional, List, Union
def loa... |
92ce623a57ad74d1528a50621a245f851ad8779bc2d647c605682759694fd40d | Python | 18,440 | 520 |
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains t... |
e78ea2d83449443ee50a5da64788757312640e1ff88e0515d492e2e92d0cd4c5 | Python | 18,453 | 556 | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import numpy as np
import pytest
import torch
from mmpose.models.detectors import PoseWarper, TopDown
def test_vipnas_forward():
# model settings
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channe... |
889f9bd2c9dbfb40d6c840c3645e596436775868f5c64eceaaaa78e04491bd2c | Python | 18,464 | 513 | # Copyright (c) OpenMMLab. All rights reserved.
import copy as cp
from collections import OrderedDict
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import (ConvModule, MaxPool2d, constant_init, kaiming_init,
normal_init)
from mmcv.runner.checkpoint import load_state_dict
fr... |
dbb21ef137489da51c517e904077f38c5aac7fb3d211d50194aac2d9668dd68a | Python | 18,472 | 488 | from typing import Optional, Tuple
import torch
from torch import Tensor, nn
from torch_geometric.nn import MessagePassing
from torch_scatter import scatter
from torchmdnet.models.utils import (
NeighborEmbedding,
CosineCutoff,
Distance,
rbf_class_mapping,
act_class_mapping,
)
from torchmdnet.models... |
53a1bc392cb3e7450af30d455bee72b1966de5e38dba4344e584cab0be7f5002 | Python | 18,486 | 426 | import pandas as pd
import numpy as np
import sys
import os
from copy import deepcopy
import cv2 as cv
import matplotlib
matplotlib.use('agg')
# plt = matplotlib.pyplot
import matplotlib.pyplot as plt
from tqdm import tqdm
from tdt import read_block
from GUI_and_data_processing.Custom_TDT_file_reader import... |
7e2fd0ab87ac9eb7c6d2ac1d85090061e31deeec728227f992fa4635abd7efcc | Python | 18,488 | 426 | from os.path import join
import h5py
import numpy as np
import pandas as pd
from datetime import datetime
import statsmodels.api as sm
from joblib import Parallel, delayed
from functools import partial
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import balanced_accuracy_score, accuracy_score... |
13e848f3d2b13b76924acddd842c9e2e2c0fc992594fcedbd70598a29af3f21b | Python | 18,511 | 429 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 9 16:41:52 2021
@author: baris
"""
from neural_coding import load_spikes, rate_n_phase
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import pickle
from scipy.stats import pearsonr, spearmanr
import c... |
c8bd1a5ff971af6ea137780125aaae26342cecaa7d547017283e4f3a28bfba36 | Python | 18,516 | 100 | #! /usr/bin/env libtbx.python
__author__ = "Grzegorz Chojnowski"
__date__ = "22 Oct 2021"
import os,sys,re
input_em="""
-0.46161793258715766,-0.596846144797356,0.17686225735831296,-0.40350073752686016,-0.8804748387935094,-1.3212588813610593,0.9809916130799197,0.7602863327549769,0.3104790855477903,-0.0078818555938508... |
ec6c81d0a90948e2bc5465c6a7a766ae079003f038d09a5b7203adadfc1319db | Python | 18,545 | 486 | import torch
from torch.optim import AdamW, Adam
from torch.optim.lr_scheduler import ReduceLROnPlateau, CosineAnnealingLR, CyclicLR
from torch.nn.functional import (
mse_loss,
l1_loss,
binary_cross_entropy_with_logits as bcn_loss,
)
from pytorch_lightning import LightningModule
from torchmdnet.models.model... |
cac5a264260786c8e58ff27740d4c2342ccd8f21f40345efa3b7edeb6d5f9846 | Python | 18,560 | 511 | import torch
import numpy as np
from torchmd.integrator import kinetic_energy, Integrator
from torchmd.systems import System
def test_kinetic_energy_single_replica():
"""Test kinetic_energy with a single replica"""
# Create test data: 3 atoms, 1 replica
masses = torch.tensor([[1.0], [2.0], [3.0]], dtype=t... |
ffd886f7c2fad52aa39430ef7fd699990474a60e021b5816aa5c8a9cca7dbf9d | Python | 18,560 | 446 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 8 12:36:15 2021
@author: fhu14
TODO: Fix this test function!
"""
#%% Imports, definitions
import math
import pickle
from collections import OrderedDict
import numpy as np
import pytest
import scipy
from Auorg_1_1 import ParDict
from DFTBLayer import DFTBList, create_b... |
10cc763049f76c799ad9cf8e08da1214e11ccefb8750c82a930d3835ae18f803 | Python | 18,562 | 363 | import torch
from models.perception_loss import vgg16_feat, perceptual_loss
from util.util import grayimg
from . import networks
from .base_model import BaseModel
import numpy as np
# Include 3db MRI + 1db CT
class Modalitybank3chModel(BaseModel):
""" This class implements the pix2pix model, for learning a mappin... |
b40c52ef589aeea0276f7c260abe2ba5f50c2e6f84280992453c86d5ee749d7e | Python | 18,604 | 501 | # Import
import configparser
import importlib
import importlib.util
import os
import pathlib
import sys
from kivy.uix.button import Button
from kivy.uix.dropdown import DropDown
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.scree... |
6cc99ad297461306f0917dcffff3051a581af6c4c28525676fb84192ca5485fa | Python | 18,608 | 508 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 21:00:26 2021
@author: baris
"""
import seaborn as sns, numpy as np
import matplotlib.pyplot as plt
from grid_short_traj import grid_maker, grid_population, draw_traj
from scipy import interpolate
from skimage.measure import profile_line
from ele... |
cd4504cf2fc20055d495e0680cc5d2d7ba79cb17a68171fc315e49c36aa9736e | Python | 18,627 | 459 | import sys
import numpy as np
import gzip
import pysam
import operator
import util
NUCLEOTIDES = {b'A', b'C', b'T', b'G'}
SNP_UNDEF = -1
# codes for CIGAR string
BAM_CMATCH = 0 # M - match/mismatch to ref M
BAM_CINS = 1 # I - insertion in read relative to ref
BAM_CDEL = 2 # D - deletion in re... |
714c0bb38b059ee74de6eb6c2b8709255a3105dec401b2a37cef1b01062ba3c6 | Python | 18,632 | 428 | """
Step 2 pattern separation analysis with Pearson's R.
Load the raw data, extract phase and rate code and calculate
Pearson's R between pairs of input and output patterns.
The results are stored in a .csv file. These results are necessary
to reproduce Figures 1 & 2.
"""
from neural_coding import load_spikes, rate_n... |
5bbcc4a2059fa5547934ca7bc29d9719ac0747c6ba37ebc2fed84b3b6a790f23 | Python | 18,659 | 551 | # Copyright (C) 2022-2025 ETH Zurich, Niels Maeder and other DASH contributors.
import contextlib
import os
from typing import Callable, List, Optional, OrderedDict, Sequence, Tuple, Union
from warnings import warn
from tqdm import tqdm
try:
from typing import Literal
except ImportError:
from typing_extensi... |
973d2463c110ac518e1a86773258bebcc5e27b20912ced08630568c216a04d03 | Python | 18,705 | 465 | import utils
from os.path import isfile, join
from os import listdir
import re
import sqldbutils as dutil
from study_analyzer import StudyAnalyzer, StudyConcept
def populate_concept_level_performance(complete_validation_file, c_map_file):
if isfile(c_map_file):
return utils.load_json_data(c_map_file)
l... |
e76ff7fc2ada2325042c6feb660ddfeb7547348574881d244853758d467538aa | Python | 18,713 | 344 | import pathlib
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
import textwrap
from A_config import a10_config
from E_viz import e100_eval_figs
from D_modelling import d090_model_wrapper, d140_modelStats
from D_modelling import d140_modelStats
from F_post_processsing import F... |
f90829b82597c98ceecd49298316dc20de516999db29f13a263261b883d7f0cf | Python | 18,713 | 472 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 1 10:53:37 2021
@author: baris
"""
import seaborn as sns, numpy as np
import matplotlib.pyplot as plt
import glob
import pandas as pd
from scipy.stats import pearsonr, spearmanr
import glob
import numpy as np
'''PUT RESULTS FROM DIFF SEEDS T... |
7ce333661d9726252f21a6e1547b9feb0dc9f214b6fcd12cc328bb780d75dbe1 | Python | 18,723 | 419 | import torch
import numpy as np
from tqdm import tqdm
from functools import partial
from .diffusion_utils import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
from .ddim import DDIMSampler
class DDIMSampler_VD(DDIMSampler):
@torch.no_grad()
def sample(self,
steps,
... |
c58e6755288874e9137f9466814723634609bed6fcc451ff54dd1fef82393262 | Python | 18,723 | 553 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import sep.helpers.utils as utils
from speechbrain.lobes.models.transformer.Conformer import ConformerEncoder
from speechbrain.nnet.attention import RelPosEncXL
from sep.training.base_network import BaseNetwork
def rescale_conv(c... |
5b18a58e469f3294ee7630597d513fcee921f96ac882935cffcd634734a12d4d | Python | 18,739 | 453 | import lifelines
import torch
from torch import nn
import torch.optim as optim
import numpy as np
import time
from pycox.models import CoxPH
from pycox.evaluation import EvalSurv
import torchtuples as tt
import lightning as pl
def onePair(x0, x1):
c = np.log(2.)
m = nn.LogSigmoid()
return 1 + m(x1-x0) / c... |
0cf597083fb0c5d22f883cb5c9b5ec78ab195be55c971873a28d1df116f94af2 | Python | 18,743 | 393 | # Copyright (c) OpenMMLab. All rights reserved.
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa
import os
import warnings
import numpy as np
import torch
import torch.nn.functional as F
from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
from mmdet.c... |
502c75fa8b66a61c180b07864e9545b4422861cd84306f0d35db822ba750389e | Python | 18,752 | 433 | # Plotting utils
import glob
import math
import os
import random
from copy import copy
from pathlib import Path
import cv2
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import torch
import yaml
from PIL import Image, ImageDraw, ImageFon... |
cac34292edfc156f5ce1bd5d04607ea2db43173e92d9536ea3e46d12e2f44bef | Python | 18,752 | 450 | import os
import pickle
import copy
import json
from collections import defaultdict
import numpy as np
import random
import torch
from rdkit import Chem
import networkx as nx
import imp
import h5py
from tqdm import tqdm
import hashlib
import torch as pt
from glob import glob
import pandas as pd
import ase.units as unit... |
0b1c54e2fc306c4aa67a082c50a95da92ef1a4fba29ab10bac627697287503ee | Python | 18,767 | 557 | # ------------------------------------------------------------------------------
# Adapted from https://github.com/princeton-vl/pose-ae-train/
# Original licence: Copyright (c) 2017, umich-vl, under BSD 3-Clause License.
# ------------------------------------------------------------------------------
import numpy as n... |
c352e519a1eed14d7f30ff43ee5cccb629c84eec3f8c4cfd9a7cd34a5de80fd0 | Python | 18,804 | 400 | import string
import sys
class GeneticCode:
"""A container for NCBI translation tables.
See the ncbi translation tables, which this week are at
http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi?mode=c
(If they move, poke around the 'taxonomy browser' area.)
This week we have
- **1**... |
29195595a3079efe6a94dfb23c9ff008df507c0c8bf2312fe5b3e32150411ca4 | Python | 18,806 | 560 | # -*- coding: utf-8 -*-
"""
Reaction
=======
This module contains classes for representing reaction elements.
author: Damian Wilary
email: dmw51@cam.ac.uk
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import ... |
6464fc34b665c3b9bb4fef9ef3bbcd5f937a8cd2dae1fd0ec24bd8c76f25268c | Python | 18,806 | 392 | from jax.config import config
import tensorflow as tf
import os
from utils import load_json
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
tf.config.set_visible_devices([], device_type='GPU')
from pprint import pprint
import jax
import jax.numpy as jnp
import jax.tree_util as tree
import numpy as np
from functo... |
b9e0f26b7b34f94a88620a56a0e418534cdd893b2cd2c3795c21c3c096ec6d20 | Python | 18,815 | 394 | import argparse
import logging
import os
import random
import socket
import sys
import yaml
import traceback
from mpi4py import MPI
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.getcw... |
8d4f57e470c48158733dae704469ef59bf8e65c0639d7dccab0d19d2aaff011b | Python | 18,832 | 407 | #!/usr/bin/env python
"""
Standalone workflow that must be installed in the synthseg.sif image.
As it is standalone and thus does not import functions or class from shivai,
any change made in shivai must be manually re-implemented here too.
"""
import argparse
import os
import json
import yaml
import shutil
from nipyp... |
e9fc172f5f8d6db45ed2b086f90a82467af36932e46e19db460448d3c58059c6 | Python | 18,873 | 534 | # -*- coding: utf-8 -*-
# Copyright 2020 Tomoki Hayashi
# MIT License (https://opensource.org/licenses/MIT)
"""MelGAN Modules."""
import logging
import numpy as np
import torch
from parallel_wavegan.layers import CausalConv1d, CausalConvTranspose1d, ResidualStack
from parallel_wavegan.utils import read_hdf5
cla... |
34449337410c5e43bd2a0fb12434b081e2f714d0cdfa0b08b65cd7af614fb3ca | Python | 18,891 | 490 | import os
import ast
import math
import time
import shutil
import urllib.request
import requests
import itertools
import numpy as np
import json
import random
import time
import logging
import pathlib
from .utilities import paths
from bs4 import BeautifulSoup
class JournalFamily():
"""
Base class to represe... |
55e8d44f15e9a6fa835f5bdf0e1dacd235fd31e0733c47028fa89a78c6c4206c | Python | 18,906 | 437 | import numpy as np
import torch
import math
from torchmetrics import Metric
from typing import Tuple
class Accuracy(Metric):
def __init__(self, class_dim: int = -1, ignore_index: int = -1, preds_one_hot: bool = True, dist_sync_on_step=False) -> None:
"""
Initializes accuracy metric with ignore-in... |
bca0280560558ac8f0a8e89b5907d3541236e2042c6126e26475512dce29fb77 | Python | 18,946 | 460 | # 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 abc import ABC, abstractmethod
from dataclasses import dataclass, replace
from typing import (
Any,
Callable,
Dict,
Literal,
Opti... |
fbfab89b5d0c5f6ca2406b17e1efbbf77c406c7801336f9fada7d111aebff92c | Python | 18,967 | 371 | from os import walk
from os.path import abspath, join
import os
import pandas as pd
from os.path import join
from config_path import BASE_PATH
# base_dir= './gcp_results/updated_labels'
# base_dir= './updated_labels'
base_dir = join(BASE_PATH, '_gcp_revision')
# base_dir= '.'
'''
Task {progression| response} -> class... |
99544c6c01d03e71926658763916b436865db46d2e922440e5be65da5ff9063a | Python | 18,968 | 385 | import os
import torch
import torchvision
from torch import nn
from models.UNet import setup_unet
from models.perception_loss import vgg16_feat, perceptual_loss
from util.util import grayimg
from .base_model import BaseModel
from . import networks
from parse_config import ConfigParser
import parse_config
class Dadga... |
e3b3ac9205f81451295617cd722d11524516bb4640785cb581ad6b8dc0a22829 | Python | 18,989 | 547 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmpose.models import (DeepposeRegressionHead, TopdownHeatmapMSMUHead,
TopdownHeatmapMultiStageHead,
TopdownHeatmapSimpleHead, ViPNASHeatmapSimpleHead)
def test_vipn... |
7afbf7eb97a575f50adb790fd5c13a7936f01a494c17aa882b3e2ee4df255c3c | Python | 19,008 | 368 | import torch
from models.perception_loss import vgg16_feat, perceptual_loss
from util.util import grayimg
from . import networks
from .base_model import BaseModel
import numpy as np
# Include 4db MRI + 1db CT
class Modalitybank5chModel(BaseModel):
""" This class implements the pix2pix model, for learning a mappin... |
51ff3e2203e2baf1901f0cd0cc1fa5ec60bf48a040a8f3ad3377d7149cad3fd6 | Python | 19,046 | 382 | import argparse
import logging
import os
import random
import socket
import sys
import numpy as np
import psutil
import setproctitle
import torch
import wandb
from torch.nn.parallel import DistributedDataParallel
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), "../../")))
from fedml_api.centralized.centr... |
2dc593f4e11b33b9c96d0d679655705e1e4fa72a56c8a10bd3ea9b8d59553852 | Python | 19,047 | 476 | import numpy as np
import pandas as pd
from Bio import SeqIO
from tensorflow.keras import backend as K
import subprocess
import time
import ray
import glob
import os
@ray.remote
def suffixerator(name):
subprocess.run(f'gt suffixerator -db {name} -suf yes -lcp yes', shell=True, check=True)
name = na... |
7c012ab258a595239772c6a3706287e0196409668e29e734c7e32ad1a8c96922 | Python | 19,067 | 428 | import os
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from scipy.stats import linregress
import numpy as np
import seaborn as sns
import shelve
plt.style.use('seaborn-poster')
# Initialise
summary_csv = pd.read_csv('./data_summary_BH.csv')
data_path = './'
save_path = './'
... |
82b9efa8aace55377943ab5fd520730f64a9dde3deaf91659e6d55284d7488cc | Python | 19,068 | 344 | #import pandas as pd
import sys
import numpy as np
import os
import json
import sys
from datetime import datetime
class read_ope:
def __init__(self, full_path_config):
# Get the path
path = os.path.dirname(full_path_config)
# Get the base name and extension
base_name = os.path.basename(full_path_con... |
dba0b20f7eaa4da72f5f9f11335709aab4bb569d2a488a5d81d7966c2ceb3c73 | Python | 19,076 | 318 | #!/usr/bin/env python
import argparse
from importlib.metadata import version
import sys
import time
from picrust2.default import (default_ref_dir_bac, default_ref_dir_arc, default_tables_bac,
default_tables_arc, default_regroup_map, default_pathway_map)
from picrust2.util import restricte... |
a9bd338bcd25e733b528ff0b886d4d7d36c3876900fbe03b1324b64fc31a9da2 | Python | 19,086 | 488 | # 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 Any, Dict, List, Literal, Optional, Tuple, Union
import torch
from torch import Tensor, nn
from torch.distributions im... |
b53bf462ebeadb1e667407c6e891c9449a7117d2a538fc844c172511b6bbc494 | Python | 19,128 | 501 | # 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 Tuple
import pytest
import torch
from torch import Tensor
from torch.distributions import Gamma, I... |
adf77d8ae25b1ec9a9ec27c537e7b8063801f7b1c048434ed400c7516f16b4c9 | Python | 19,145 | 425 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import (bias_init_with_prob, build_activation_layer,
build_norm_layer)
from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention
from mmcv.runner import auto_fp16, force_fp32
from mmdet.core imp... |
176076cc082979e759881ce9e3aa533e3bf41aaeb685f45d9c1a8676c0cb098f | Python | 19,172 | 490 | # 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 math import sqrt
from typing import Callable, Optional, Tuple, Union
import numpy as np
import torch
from torch import Tensor, nn
fr... |
4044fb545252074d61de0c553d3f2df4530304f64d8277fa702589d7506adfbd | Python | 19,178 | 554 | """
Lobar segmentation from a SynthSeg parc
1001 ctx-lh-bankssts Temporal
1002 ctx-lh-caudalanteriorcingulate Frontal (Limbic) #
1003 ctx-lh-caudalmiddlefrontal Frontal
1005 ctx-lh-cuneus Occipital
1006 ctx-lh-entorhinal Tempor... |
01fec4890986440701f356cb6f94f4a2b3731408f94d5e68c94ccd55aa504dca | Python | 19,261 | 497 | # 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 time
from copy import deepcopy
from datetime import datetime
from pathlib import Path
from typing import Any, Callable, Optional, Tuple, Union
from... |
d093aedff16a489afa40aadd82fa01128a82bc37dd7dbedd7e2ee51c3bb94528 | Python | 19,280 | 424 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmdet.core import bbox2result, bbox2roi, bbox_xyxy_to_cxcywh
from mmdet.core.bbox.samplers import PseudoSampler
from ..builder import HEADS
from .cascade_roi_head import CascadeRoIHead
@HEADS.register_module()
class SparseRoIHead(Ca... |
dbd49516984ab662b20323f1d0260e92c7942496c7e91f0c58bcec4bad6fbe2a | Python | 19,324 | 470 | # -*- coding: utf-8 -*-
"""
Created on Mon May 30 16:23:37 2022
@author: fhu14
"""
'''
Performs a series of tests on the datsets before performing the
precomputation on them. These tests are hard-coded and based on
expectations about the different datasets
'''
#%% Imports, definitions
import pickle
import os
import n... |
7be26198ba1987283898031f785ca78cb0d72ff4f429c185f882fc644a493d91 | Python | 19,337 | 433 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmcv.runner import force_fp32
from mmdet.core import (anchor_inside_flags, images_to_levels, multi_apply,
unmap)
from ..builder import HEADS
from ..losses.accuracy import accuracy
from ..losses.utils import wei... |
b9c88affa531dd0b8ccb9c62e5b048c8f5bd72020269b7b336538b81016ebf07 | Python | 19,341 | 112 | #! /usr/bin/env libtbx.python
__author__ = "Grzegorz Chojnowski"
__date__ = "14 Dec 2021"
import os,sys,re
from optparse import OptionParser, SUPPRESS_HELP
import numpy as np
import h5py
import tensorflow as tf
print(tf.__version__)
import onnx
from onnx_tf.backend import prepare
#import keras
from tensorflow ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.