sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
73673497bfb8c02d29348ddc27078c868bef906aadce8bb4a1c16258045639b1 | Python | 5,248 | 161 | #!/usr/bin/env python3
"""
Test script to verify that the transformer model can be serialized and deserialized properly.
"""
import tempfile
import os
import numpy as np
import keras
from ml4h.models.transformer_blocks_embedding import build_embedding_transformer
def test_model_serialization():
"""Test that the m... |
c2af0c410f5dcfea5baa9f90a2d466354e1e792979810bb83f63487da14dce69 | Python | 5,248 | 159 | import numpy as np
from scipy.stats import sem, pointbiserialr, pearsonr, spearmanr
def pad_vector_to_same_length(a, b):
# compute the padding size
length_diff = np.abs(len(a) - len(b))
pad = np.zeros(length_diff, )
# pad the shorter vector
if len(a) > len(b):
b = np.concatenate([b, pad])
... |
eeea6942ec2cb5c0995462092d39652e71c2b3f2c115e54adeefdf711cc42f53 | Python | 5,249 | 107 | import os
import numpy as np
import matplotlib.pyplot as plt
project_root = "/ccb/cybertron/khchao/splam-analysis-results/"
# albation_study_root=f'{project_root}results/albation_study/MODEL/subset_10000/'
albation_study_root=f'{project_root}train/src/MODEL/'
output_dir = f'{albation_study_root}img/'
os.makedirs(outpu... |
b34ed71c1ea25c673a4c00fb3ae6f4e60e9813afdb4734f4d79b3dc8f743e391 | Python | 5,252 | 144 | import os
import pickle
import numpy as np
import pandas as pd
from importlib import reload
import torch
from functools import partial
from sklearn.decomposition import PCA
from matplotlib import pyplot as plt
from datetime import datetime
from cave_vae_models import *
import shutil
from functools import partial
... |
b7b637baa96884f0b619a29608ddba4db53cd18af48dc9920e29f12537dbd5f5 | Python | 5,252 | 141 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import os
from typing import TYPE_CHECKING, Any, ClassVar
import numpy as np
import pandas as pd
from ... |
b93c663f631142dcae24be933d84e5de6b63323e8e4a466eda0740578e8e3287 | Python | 5,253 | 163 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
0206c466561c6093bb9fd6e867e858515b40c09dc8e68c52e3a7abdd9fad2ee0 | Python | 5,255 | 184 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
from enum import Enum
import torch
import torch.nn as nn
## The following part is from xformers, copi... |
17646427def77dcd44218042788d1ef66f5383448d4e1a0d1148b82262968f60 | Python | 5,256 | 159 | #
# Combine several multi-class (i.e., not binary) segmentations (obtained manually by expert raters) into a reference
# segmentation using the STAPLE algorithm.
#
# Note: since the segmentations are multi-class (i.e., not binary), we need to binaries them. We do this for each
# spinal level separately.
#
# Example:
# ... |
75b1f034b79184ba4245df28c39760f33ea4d0e6148fe11163676d0f55656796 | Python | 5,256 | 140 | from ..utils import (
OptionalDependencyNotAvailable,
is_flax_available,
is_k_diffusion_available,
is_librosa_available,
is_note_seq_available,
is_onnx_available,
is_torch_available,
is_transformers_available,
)
try:
if not is_torch_available():
raise OptionalDependencyNotA... |
56f0966bdfb14b89ad0609715c2a016cc3295677cd6f434c0873746ab4ff320d | Python | 5,263 | 149 | import asyncio
import copy
import logging
import os
import subprocess
import sys
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from ray._common.utils import (
try_to_create_directory,
)
from ray._private.runtime_env.context import RuntimeEnvContext
from ray._private.runtime_env.plugin imp... |
7edd95266fecc03c0513755ebc1c95f96899f33471e5590eb8ce096636c2888f | Python | 5,263 | 142 | from collections import namedtuple
import numpy as np
from typing import List, Dict, Tuple
from abc import ABC
CellIDIndexPair = namedtuple('CellIDIndexPair', ['cell_id', 'cell_type_key', 'idx_pos'])
from dataclasses import dataclass
class HasCellOrdering(ABC):
def get_reference_cell_order(self, cell_type: ... |
7d2b6e304fb3a96ab7c20566e58f5bba4057288e8ac113c4f1be65d47dc08f73 | Python | 5,265 | 143 | import numpy as np
import pandas as pd
def compactness(ad, low_dim_embedding="X_pca", SEACells_label="SEACell"):
"""Compute compactness of each metacell.
Compactness is defined is the average variance of diffusion components across cells that constitute a metcell.
:param ad: (Anndata) Anndata object
... |
183778c8bb4664102688e00d302c17d1c305c227c120b88ac5ab16bc554c1182 | Python | 5,266 | 131 | """Proactive code transformer for LLM-generated code.
Extracted from ``analysis_executor.py`` during Phase 4 decomposition.
``ProactiveCodeTransformer`` applies regex-based fixups to agent-generated
code *before* sandbox execution — preventing common errors such as
matplotlib GUI hangs, in-place assignment bugs, and f... |
4fd4586dcaced8457ae7ac5959adcdba63e363c7f032984df87100419ef5b0e1 | Python | 5,267 | 123 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
3acd4ae3c56a07ee79e4b2f77e901a2a89ec632035cb6288af46848406c38b2d | Python | 5,268 | 159 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
9ad0c9d3ffe0a6d2bbe664450957d27fbdb408cc927d41f3a37fca012412ce13 | Python | 5,268 | 133 | import logging
import os
import tempfile
import time
import uuid
from typing import TYPE_CHECKING, Iterable, Optional
import pyarrow.parquet as pq
if TYPE_CHECKING:
import pyarrow as pa
import ray
from ray.data._internal.datasource import bigquery_datasource
from ray.data._internal.execution.interfaces import Ta... |
c75a8bb14ac0644e21602e8ad8c1816619f13b4f11ff2b54511edcbd1734e558 | Python | 5,273 | 147 | #
# Copyright (c) 2021, NVIDIA CORPORATION.
#
# 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 law or agreed ... |
83f53cf756bb80b4a2904a73573ad14ca4e9c26802b75f0e98ee079d570a597a | Python | 5,274 | 120 | import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BartForConditionalGeneration, BartConfig
from transformers import BartTokenizer, modeling_bart
from rouge import Rouge
def tokenize_data(hps, data):
tokenizer = BartTokenizer.from_pretrained(hps.model_dir)
# tokenizer.... |
d6a45f6d96fb8f61d00860346fed3fada5f129a87d1c709d3ab78f554eb3bc97 | Python | 5,274 | 131 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
0ee39d579c97eb4ebbeb09afa514e378b917bd08bc0950de8aabe5739679d028 | Python | 5,277 | 138 | import flammkuchen as fl
import numpy as np
from scipy import io
from pathlib import Path
from skimage import io as skio
from ast import literal_eval
from scipy.stats import mode
def load_into_f5(path):
path = Path(path)
try:
traces = io.loadmat(str(path / 'traces3d.mat'))['traces_z']
roi_stac... |
4e7d453d1c0dc5cd1344c8beff0847d935965a4320515b4e1b424179b12ec760 | Python | 5,277 | 111 | #!/usr/bin/env python
# coding: utf-8
# author: Maruthi Mutnuri (maruthi2008@gmail.com)
# loading libraries
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
from sklearn.lin... |
ae35cb00c14c573238e2e35ccc499bf2e3dea9a749466c6cf788d2e79078ff99 | Python | 5,277 | 142 | #!/usr/bin/env python
import sys
import os
from sv_utils import common
import contextlib
import io
from typing import Text, List, TextIO, Optional, Iterator, FrozenSet
src_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
def _kebab_to_snake(kebab_str: str) -> str:
"""
Allow passing comman... |
c7fcc24be240048905b2e4dd0ebed1342b7a8b8a4798ddf125a625717bdff7eb | Python | 5,277 | 149 | #!/usr/bin/env python3
# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright ... |
6c53eb0ebfbf48bc55032ea4fd62214e8e599bc7b275c626f0f50a60df1d748a | Python | 5,278 | 154 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
7d11e6faeb4d55768eaca151741d2b6d5ef449214bbb30d68f1df3ea02036552 | Python | 5,282 | 149 | import logging
from dataclasses import dataclass
from typing import List, Dict, Optional
from transformers import PreTrainedTokenizer, is_torch_available
import pdb
from tqdm import tqdm
logger = logging.getLogger(__name__)
@dataclass
class InputFeatures:
"""
A single set of features of data.
Property name... |
1a7184b489d3673110fc45934a4fa28e09e5ba4854a20d011def36ea98619648 | Python | 5,285 | 141 | from itertools import product
from pathlib import Path
import pytest
import torch
from torch import nn
import sinabs.layers as sl
from sinabs import hooks
from sinabs.layers import IAFSqueeze
TEST_DIR = Path(__file__).resolve().parent
INPUT_RESULT_DIR = TEST_DIR / "inputs_and_results" / "hooks"
MODEL_DIR = TEST_DIR ... |
6e13d40299b19fb686989bc7566b31f55641659bb84722037e1be922006d3260 | Python | 5,286 | 126 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
8e8b567a1a7467d12acf4edf8475793de53c4bd26417b945873d1cf66a3f2e37 | Python | 5,286 | 169 | import abc
import os
import re
import subprocess
import sys
from typing import List, Optional, Tuple
# Regex pattern to match CUDA copyright header with any version
_CUDA_COPYRIGHT_PATTERN = r"""==========
== CUDA ==
==========
CUDA Version \d+\.\d+(?:\.\d+)?
Container image Copyright \(c\) 2016-2023, NVIDIA CORPORA... |
a328cd52a297071ba629c268126363cce98c7de44732d5188407b90d1b25e562 | Python | 5,292 | 168 | import os
import contextlib
from ..._registry import register_function
@contextlib.contextmanager
def _patch_categorical_setstate():
"""Temporarily patch ``Categorical.__setstate__`` to tolerate old pickle formats.
Older pandas versions serialised ``Categorical`` as a ``(dtype, codes)``
tuple. Newer pa... |
b9f73c854e37dd97b9bf2464ea2bb6ef2c21d7105de0f4728757c14d8e8a61d8 | Python | 5,295 | 190 | """ENCODE cCRE (candidate cis-Regulatory Elements) API client.
Updated to use the ENCODE Portal search API which returns JSON when
`Accept: application/json` and `format=json` are provided.
"""
from typing import Dict, List, Optional, Any
from .base import BaseAPIClient
class CCREClient(BaseAPIClient):
"""Clien... |
920d8a3ca23d1b37e469371eacf7404b0c88afdf2140735720039a4f18f0ad04 | Python | 5,296 | 142 | import tensorflow as tf
from models.deep_learning.deep_learning_models import DLRegressor
from utils.constants import is_spline
class InceptionTimeRegressor(DLRegressor):
"""
This is a class implementing a single InceptionTime model for time series regression.
The code is adapted from https://github.com/h... |
bbb7f717a59aa532a002a7d1070c6135516760b7b8cf3662232dbdead7a40610 | Python | 5,297 | 153 | from dataclasses import dataclass, replace
from typing import List, Optional, Tuple
import pyarrow as pa
from pyarrow.fs import FileSystem
from typing_extensions import override
from ray.data._internal.datasource_v2.common.file_scanner import FileScanner
from ray.data._internal.datasource_v2.interfaces.pushdown impor... |
f11028db93fc291e0e227b9a61e7872eccd3195c3110c57862993244b3e6bc95 | Python | 5,297 | 142 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
0f0cb5a8575eab4f1b4e4cf984c42329a3ebe830480f54a87759cd9282f23101 | Python | 5,298 | 165 | import copy
import logging
import os.path as osp
import warnings
from typing import Any, List, Union
import numpy as np
from mmengine.dataset import BaseDataset, force_full_init
from mmengine.logging import print_log
from lqit.registry import DATASETS
@DATASETS.register_module()
class DatasetWithGTImageWrapper:
... |
745258d5ed57b13788b90bf4e619514789d4b21a1df53d626c5b967f4bd684a2 | Python | 5,298 | 125 | import scipy.io as sio
import os
import numpy as np
import h5py
import sys
# from skimage import filters
from scipy.ndimage import gaussian_filter
import time
import multiprocessing as mp
sys.path.insert(1, '../SUNS2') # the path containing "suns" folder
from suns.PreProcessing.preprocessing_functions import preproces... |
4c485ee83bb19ed774924383fb594c91020b5b84586efba78d2e2233da1f87f6 | Python | 5,299 | 129 | os
import pickle
import pandas as pd
import numpy as np
import nibabel as nib
import pcntoolkit as ptk
from pcntoolkit.dataio.fileio import load as ptkload
from pcntoolkit.dataio.fileio import save as ptksave
from pcntoolkit.dataio.fileio import save_nifti, load_nifti
from pcntoolkit.normative import predict, evaluat... |
edbb009bb09b3b54941735769a4b72acff594e1c65de76d5880d0fa3c5683f3d | Python | 5,300 | 136 | """Imputation dispatcher for ``ov.protein``.
Wraps the full :mod:`pyimputelcmd` imputer suite (MinDet / MinProb /
QRILC / ZERO / MLE / KNN / SVD / MAR / MAR-MNAR) plus the two
commonest non-LCMD fallbacks (``half_min`` and ``min``). The single
:func:`impute` function takes ``method=...`` and writes the imputed
matrix ... |
60e47016e42e805555111eef2756b10f3a542134e164ad20a71896eb422aa866 | Python | 5,303 | 170 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Tests for the high level simulator devices functionality."""
from sys import version_info
from unittest import SkipTest
from aihwkit.exceptions import Config... |
cb63a605bd9e6899fa1ed3360e8a360c8a973ae1e9b359910383f8f79757cf04 | Python | 5,304 | 188 | ################################################################################
# -- Default set of parameters
################################################################################
import numpy as np; import pylab as pl; import time, sys, os
import matplotlib
## the number of cores to be used for simulati... |
73881abfbb437ecfd96ed9f2c22c88095f698d20abfa3f1a115650ac03503dc7 | Python | 5,305 | 199 | """
implementing "two independent networks" in https://github.com/synsense/sinabs/issues/181
TODO: This is not working yet
"""
import torch
import torch.nn as nn
from sinabs.activation.surrogate_gradient_fn import PeriodicExponential
from sinabs.layers import IAFSqueeze, Merge, SumPool2d
class SNN(nn.Module):
d... |
fef87c3a038b2a1073862039a9132597b6a6e8cb4ac3eb6ef1d4d0efb5923494 | Python | 5,305 | 221 | import os
import sys
import shutil
import argparse
from datetime import datetime
import json
import pprint
import sys
context = {
"network": {
"dimensions": 3,
"image_channels": 4,
"label_channels": 1,
"seg_output_channels": 4,
"img_output_channels": 1,
"layer_count": 5,
"layer_channels... |
c758e13b17b1da86d6ba441f35aac591378e3980a524461cc1f7cb6d0e444f77 | Python | 5,306 | 130 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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 law or agreed... |
0c47065bc072d51fd842fafe7fc813acfecb5100a28f6a664dbd763b781ad497 | Python | 5,307 | 129 | import os
import pickle
import pandas as pd
import numpy as np
import nibabel as nib
import pcntoolkit as ptk
from pcntoolkit.dataio.fileio import load as ptkload
from pcntoolkit.dataio.fileio import save as ptksave
from pcntoolkit.dataio.fileio import save_nifti, load_nifti
from pcntoolkit.normative import predict, e... |
4d95eed2debd9da13da1c59aa3b1ec66b895ddddd9db5a3f0c3361570ae52abc | Python | 5,307 | 161 | """
Minimal working example for mouse syllables.
0) Define directories and parameters.
1) Tune segmenting parameters.
2) Segment.
2.5) Clean segmenting decisions. (optional)
3) Tune preprocessing parameters.
4) Preprocess.
5) Train a generative model on these syllables.
6) Plot.
7) The world is your oyster.
"""
fro... |
00f33c6fe80ca773ef33994fce38f5beb21b58c00eee395b3211c2b0c228a06a | Python | 5,308 | 149 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import copy
import DataSet
from Config import class_number
class Transformer(nn.Module):
def __init__(self,
vocab_size = len(DataSet.getTEXT().vocab), # 词典的大小
seq_len = 256,
n... |
7e20069952d6d70111dbfab39e5f56fc5ea928c2d91c2acfc253f05cbb411333 | Python | 5,308 | 142 | import sys
from itertools import groupby
import numpy as np
factorDict ={
"A":[-0.59,-1.30,-0.73,1.57,-0.15],
"C":[-1.34,0.47,-0.86,-1.02,-0.26],
"D":[1.05,0.30,-3.66,-0.26,-3.24],
"E":[1.36,-1.45,1.48,0.11,-0.84],
"F":[-1.01,-0.59,1.89,-0.40,0.41],
"G":[-0.38,1.65,1.33,1.05,2.06],
"H":[0.34,-0.42,-1.67,-1.47,-0.08],
... |
0222c26453eac46c274660ea7c5c0c416d377cbaac900369251eab56b2d8d98c | Python | 5,309 | 130 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
18ce98920092c46e354ac070ffa283f92657fc8a717addc69fb6b1f025368769 | Python | 5,309 | 199 | from docutils import nodes
from sphinx.util.docutils import SphinxDirective
from sphinx.transforms import SphinxTransform
from docutils.nodes import Node
# BASE_NUM = 2775 # black circles, white numbers
BASE_NUM = 2459 # white circle, black numbers
class CalloutIncludePostTransform(SphinxTransform):
"""Code b... |
5c4db86dbfd6d339d13e67568f972256e6e658ff22b69d91bf4bca00d5027519 | Python | 5,309 | 145 | import logging
import os
import re
from typing import List, Optional, Tuple
from ray._private.accelerators.accelerator import AcceleratorManager
from ray._private.ray_constants import env_bool
logger = logging.getLogger(__name__)
CUDA_VISIBLE_DEVICES_ENV_VAR = "CUDA_VISIBLE_DEVICES"
NOSET_CUDA_VISIBLE_DEVICES_ENV_VA... |
2db82ce3b37bb9591601b3a745b580802a4976fd4d2ce61ff51760cb1cccb846 | Python | 5,310 | 147 | import torch
from networks.attention_gan import Generator, Discriminator
from modules.module_unet import GAN as UnetGan
from utils.reggan.transformer import Transformer_2D
from utils.reggan.reg import Reg
class GAN(UnetGan):
def __init__(self, config):
super().__init__(config)
self.R_A = self.defi... |
b0a04f26f1301ff72d1ca02eb2992f115bd3cca0e271c4deb99109a443b7fa33 | Python | 5,310 | 161 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 13 17:56:31 2023
@author: hansav
"""
import os
import numpy as np
from pcntoolkit.util.utils import calibration_descriptives
from pcntoolkit.dataio.fileio import load_nifti, save_nifti
from pcntoolkit.dataio.fileio import load as ptkload
from pcnto... |
7ee2e816cd85dc8064a7401b5fb026d6309b62b746e539ec90307f13e25cc765 | Python | 5,311 | 132 | ####################################################################################################
# Copyright (c) 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is free softw... |
cf9449ed1dd10c5eea992a7d4742274a537ed2d02cf5709157b8ba3dfac56d42 | Python | 5,311 | 164 | import os
import pandas as pd
from pyfaidx import Fasta
from progress.bar import Bar
'''Get the length of chromosomes'''
def get_chrom_size(path):
chrs = {}
with open(path, 'r') as file:
# read the file line by line
for line in file:
if line.startswith('#'):
conti... |
05cdc9c18f54723c45040423bd6959d324e434625298ace67b31066961c9405f | Python | 5,314 | 155 | from typing import Tuple
import numpy as np
import pyspark.sql.functions as F
from pyspark.sql import DataFrame
from data_profiling.config import Settings
from data_profiling.model.summary_algorithms import histogram_compute
def numeric_stats_spark(df: DataFrame, summary: dict) -> dict:
column = df.columns[0]
... |
941d3de47daaae2e559d3776675cfb3a918ee8fc0cb1717a9efc80fd46228098 | Python | 5,314 | 177 | import PIL.Image
import numpy as np
import cv2
import json
import os
import argparse
import shutil
import time
class IMAGE:
pass
class TILE:
pass
class BBOX:
pass
import torch
def to_tensor(img):
img = torch.from_numpy(img).float().cuda().permute(2,0,1).unsqueeze_(0).half()/255.0
#img = img/25... |
b7f558b805863bab1b0b1cb75e4105da42a9fdb45c838c85e2e8a2facf109352 | Python | 5,314 | 97 | from .bioprocessor import BioProcessor
import pysolr
from bionlp.processors.utils import unique_terms
import re
import os
class ChemicalProcessor(BioProcessor):
def __init__(self, model_name):
super().__init__(model_name)
self.solr_url = os.getenv('SOLR_URL','http://localhost:8983/solr/')
... |
3995f1ed01fd24edb7c80fe9a4ca9148ec3e9a427f2ba60ce1d2d0bcfce2a312 | Python | 5,315 | 155 | import tensorflow as tf
from utils.nn import linearND, linear
from mol_graph import atom_fdim as adim, bond_fdim as bdim, max_nb, smiles2graph, smiles2graph_test, bond_types
from models import *
import math, sys, random
from optparse import OptionParser
import threading
from multiprocessing import Queue
import rdkit
fr... |
c75bc1080541eae706212a6659cdb0af9606df8ed42a69fb40b71e8bfa969114 | Python | 5,315 | 140 |
import gym
import numpy
import random
import os
from gym import error, spaces, utils
from gym.utils import seeding
from matplotlib import pyplot
from collections import OrderedDict
import gym_sted
from gym_sted import rewards, defaults
from gym_sted.utils import SynapseGenerator, MicroscopeGenerator, get_foreground,... |
61a54bfa503c5a202effe8a3ea33cceac57322f1084301e31612753f7052ab1d | Python | 5,317 | 146 | """Script for precomputing synthetic recordings for a single network."""
# pyright: reportCallIssue=false
import argparse
import logging
from flyvis import NetworkView
from flyvis.utils.config_utils import HybridArgumentParser
logging.basicConfig(
format="[%(asctime)s] [%(filename)s:%(lineno)d] %(message)s", le... |
96e61b378f222dd033a8b769aeaf908907eac1ac86f0d4bb8bb34fe25a3a4241 | Python | 5,317 | 144 | import os
import cv2
import tifffile
import numpy as np
def load_data(data_path, max_proj):
noisy_vid_path = os.path.join(data_path, 'noisy_imgs')
all_noisy_data = []
all_img_name = []
img_list = os.listdir(noisy_vid_path)
for img in img_list:
if os.path.isfile(os.path.join(noisy_vid_pat... |
2359dbe743d71fe1e71f429f4770760f6f277c707b519e5cf1b06cedddcf9f95 | Python | 5,318 | 192 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import argparse
from pathlib import Path
import yaml
DOCS_DIR = Path(__file__).resolve().parent
SITE_... |
24450b258420c5952eb300ad4bc07ece3405cf0fbde458dfc7c241a938771259 | Python | 5,318 | 109 | """
Dataloader for sleep stage classification on GCAMP data
using TFRecords using on local machine
Author: Xiaohui Zhang
Date created: 03/18/2022
"""
import os, glob, json, re
import tensorflow as tf
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import numpy as np
def add_argum... |
8b84d27d242048139e7f4ba91af9a8d1890abc43f85d766aeb8403c34352c466 | Python | 5,318 | 153 | # 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 law or agreed to in writing, software
# distributed under th... |
ab3cecc65621e4e1178289903afbd6c06824f8b1bc041c7b5eafe4d949cdeb9f | Python | 5,319 | 137 | # 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 law or agreed to in writing, software
# distributed under th... |
79f099e0bc5d46a22e18fe2628235d0cad5a6083a7291bc48d2947b2499a8677 | Python | 5,320 | 147 | import torch
import numpy as np
from datetime import datetime
from torch.optim import AdamW
from transformers import get_linear_schedule_with_warmup
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from sklearn.utils.class_weight import compute_class_weight
from agent.classifiers.evaluation.e... |
af2d8fda6c6f230ee305cdfd078bab77301c6b42b29599fa1e3a1d13617d4a31 | Python | 5,320 | 161 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 13 17:56:31 2023
@author: hansav
"""
import os
import numpy as np
from pcntoolkit.util.utils import calibration_descriptives
from pcntoolkit.dataio.fileio import load_nifti, save_nifti
from pcntoolkit.dataio.fileio import load as ptkload
from pcnto... |
17ce3fe9b465f5b5e88f6f17785272d40bf20e3a547d2eb2e30fc7c4f956cfd8 | Python | 5,322 | 146 | """eQTL mapping for ``ov.genetics`` — Matrix eQTL backend.
Exposes :func:`eqtl_map`, a dispatcher over the linear / ANOVA /
linear-cross models of `Matrix eQTL <https://github.com/andreyshabalin/MatrixEQTL>`_
(Shabalin 2012). The heavy lifting lives in the standalone
:mod:`pymatrixeqtl` package — this module is a thin... |
1b3a28aeee31e558f7a994ae261e3f8c059cceda95845aa505f5505a6cd5dd03 | Python | 5,324 | 149 | # coding=utf-8
# Copyright 2023 HuggingFace Inc.
#
# 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 law or ag... |
30d1e9a2edc03d563ee92f786710573716ff6f00b530a5f83578dfcfcb9c3546 | Python | 5,326 | 150 | import scanpy as sc
import numpy as np
import torch
#from tensorflow_probability import math as tm
#tfk = tm.psd_kernels
#import spatial_factorization as sf
from typing import Optional
from scipy.sparse import csr_matrix
from ._townes_nsf_utils import *
from sklearn.decomposition import NMF
def construct_gems_using_p... |
b698e58ff6458ddeb640bd8d1f1922846f915b238de2136506f4600769ca09df | Python | 5,326 | 148 | import copy
import logging
import os
from cryptography.hazmat.primitives import serialization as crypto_serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from ray.autoscaler._private.constants import DISABLE_NODE_UPDATERS_KEY
from ray.autoscaler._private.event_system import CreateClusterEvent, g... |
e3780d870d0c057057a6bfcdd3846bf75b113cb937151e8501cdf877d58b4fe6 | Python | 5,327 | 120 | import tensorflow as tf
import numpy as np
import pandas as pd
from sklearn.metrics import accuracy_score
import glob
import pickle
import matplotlib.pyplot as plt
from utils.constants import *
from utils.experiments_tools import *
from utils.regressor_tools import *
from utils.plot_tools import *
eval_all = True # if... |
91ee91f64c637680cbf41300cba0386ea4a876a8ccbbaa674912ef04c223e8c3 | Python | 5,328 | 122 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
f41be26e3d57aa02a3302c28ec477df8a045422744fbd9f04a7316958042d93b | Python | 5,328 | 163 | from typing import Any
import optuna
from sklearn.base import BaseEstimator, clone
from siapy.core import logger
from siapy.core.exceptions import InvalidInputError
from siapy.core.types import ArrayLike1dType, ArrayLike2dType
from siapy.datasets.schemas import TabularDatasetData
from siapy.optimizers.configs import ... |
8ab2d646742f54c94ee933b7c3bf22c9dd35c1db6af82e96feafb90ed1059218 | Python | 5,330 | 170 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import unittest
import numpy as np
import pytest
from fairchem.core.datasets.samplers.max_atom_distri... |
573ac1240bef61dda091ac090b3c9e4537968c4dce8bae75afd3b3e20d0dc6d3 | Python | 5,331 | 219 | # Short term workaround for https://github.com/ray-project/ray/issues/32435
# Dataset has a hard dependency on pandas, so it doesn't need to be delayed.
import pandas # noqa
from packaging.version import parse as parse_version
from ray.data._internal.utils.arrow_utils import get_pyarrow_version
from ray.data._intern... |
60c3f58775ddcbb9eb2c1c7ec828e43570d8ca4911a5362188a515459968fc35 | Python | 5,336 | 140 | import torch
from diffusers import DDIMScheduler
from .test_schedulers import SchedulerCommonTest
class DDIMSchedulerTest(SchedulerCommonTest):
scheduler_classes = (DDIMScheduler,)
forward_default_kwargs = (("eta", 0.0), ("num_inference_steps", 50))
def get_scheduler_config(self, **kwargs):
con... |
a2c3a7c3cc4237695b5c8159375033336abc42300b938b163ecd811cc31bf742 | Python | 5,337 | 182 | import torch
import torch.nn.functional as F
import numpy as np
import math
# class NCC:
# """
# Local (over window) normalized cross correlation loss.
# """
#
# def __init__(self, win=None):
# self.win = win
#
# def loss(self, y_true, y_pred):
#
# Ii = y_true
# Ji = y_pred... |
87ef54c497149c91c495e5ad83c24602e2fe6dfc6b6468d220c4825d7622c714 | Python | 5,340 | 191 | """AlphaFold Protein Structure Database API client."""
from typing import Dict, List, Optional, Any
from .base import BaseAPIClient
class AlphaFoldClient(BaseAPIClient):
"""Client for AlphaFold API."""
def __init__(self):
super().__init__(
base_url="https://alphafold.ebi.ac.uk/api",
... |
13b6d75ed517a62fde28bf927b1f5f83ebe91639032dce5de1ea9e3537419767 | Python | 5,341 | 191 | """AlphaFold Protein Structure Database API client."""
from typing import Dict, List, Optional, Any
from ..base import BaseAPIClient
class AlphaFoldClient(BaseAPIClient):
"""Client for AlphaFold API."""
def __init__(self):
super().__init__(
base_url="https://alphafold.ebi.ac.uk/api",... |
e4fdc96f8d5057e8254cf0f563630e929f8012c114d074786e7a2097429b9771 | Python | 5,341 | 196 | import os
import time
import numpy as np
from discontinuous_galerkin.base.base_model import BaseModel
from discontinuous_galerkin.start_up_routines.start_up_1D import StartUp1D
import matplotlib.pyplot as plt
import pdb
import scipy.stats
import yaml
from matplotlib.animation import FuncAnimation
import ray
from late... |
b0781fd11d97938c77f579b76628aee532860131918e45203226b635e2efcf97 | Python | 5,342 | 111 | '''
Created on Sep 16, 2015
@author: jivan
'''
from collections import namedtuple
from unittest import TestCase
from sequence_io import FASTASequenceInput, WhitespaceSeparatedSequenceInput, OneSequenceInput
from sequence_io import SequenceOutput
InOutPair = namedtuple('InOutPair', ['input', 'expected_output'])
class... |
fe1ee048482c50d0a6a81a23d2804008df5a540480e290ba90fb6b940e305d09 | Python | 5,342 | 197 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import os
import psutil
from fairchem.data.omol.orca.calc import (
NBO_FLAGS,
OPT_PARAMETERS,
... |
2c53de3d10e68c7a3403dbd29f3828dbc65ec73bb086cdeab4b7dc72582dfcdd | Python | 5,344 | 180 | from pathlib import Path
import pandas as pd
import numpy as np
from collections import defaultdict
import random
from scipy.stats import multivariate_normal
from scipy.stats import wasserstein_distance
from scipy.stats import pearsonr
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mat... |
748fd6fa37848274179c6700d1a46f3ceeff2c6acc7b4abcd093af35c62638ee | Python | 5,344 | 124 | proj_dir = "/path/to/main_project_folder/" # edit this line
import numpy as np
import pandas as pd
import xarray as xr
import time
import sys
sys.path.append(proj_dir)
from project_fxns import parameters as param
import importlib
importlib.reload(param)
#############################################################
d... |
6c6e1f0f2a61afd6743ab43dff4e4ac05db816b1b719ca35ef8f3eb8b45f486b | Python | 5,345 | 160 | import re
import torch
import networkx as nx
from torch_geometric.data import Data, InMemoryDataset
# Word to index
word_to_ix = {"X": 0, "A": 1, "G": 2, "C": 3, "T": 4, "U": 4}
word_to_ix1 = {"<PAD>": [0,0,0,0,0], "A": [0,1,0,0,0], "G": [0,0,1,0,0], "C": [0,0,0,1,0], "T": [0,0,0,0,1], "U": [0,0,0,0,1]}
# Index to wo... |
c7815d9843131d094dec41b56f9d4179d950f2178570d9595d0c8602c29070cf | Python | 5,345 | 158 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
e7fe6bb7d3a477ec3e87d242edfbc74403e566c27755caa34e4b782c9740ca7f | Python | 5,348 | 147 | import numpy as np
import pandas as pd
import sys
import matplotlib.pyplot as plt
from scipy.stats import norm,skewnorm
import Utility_working as Utility #custom-made utility file, contains lengthy functions
from constant import *
from lmfit.models import SkewedGaussianModel
######### USER INPUT REQUIRED
grp = 26340-f... |
abfb967a7d40faddae75a7913863c3532f02754bdf06ca6e6e043f441a56fb16 | Python | 5,351 | 162 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
3b9899202e6a8727a5b2e6748ff0c68e0788fb54a4a5cba67d5be7e6467b647a | Python | 5,352 | 118 | """Helper functions for loading pretrained gene embeddings."""
from pathlib import Path
from typing import Dict, Tuple
import torch
from scanpy import AnnData
import numpy as np
import pandas as pd
# Global variable that will be set by the UCE model wrapper
EMBEDDING_DIR = None
def _get_default_embedding_dir():
... |
3dd6013ac91b44bafc847c2affe1cc260d4d23746c0c2fa76a32286a544b9416 | Python | 5,352 | 190 | ################################################################################
# -- Default set of parameters
################################################################################
import numpy as np
import pylab as pl
import matplotlib
## the number of cores to be used for simulations
n_cores = 1
# defi... |
e34a30a5981c4f426c59404731ea33303232fd806d596eb87d58a806e9eda44e | Python | 5,352 | 167 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
09caaf3072cfa7a581e198c016243e1a4d5cf47153f50e8b24539339da4a62b8 | Python | 5,353 | 155 | """Color coded flow-field animation."""
from typing import List, Literal, Optional, Tuple, Union
import numpy as np
import torch
from matplotlib.axes import Axes
from matplotlib.cm import ScalarMappable
from matplotlib.colors import Colormap
from matplotlib.figure import Figure
from matplotlib.text import Text
from ... |
41d192b627ead3d1aa1fb44f4c4e8cc7a2d277bc9656a813374158981675501b | Python | 5,353 | 190 | ################################################################################
# -- Default set of parameters
################################################################################
import numpy as np
import pylab as pl
import matplotlib
## the number of cores to be used for simulations
n_cores = 1
# defi... |
4f78c8d8018d25cc1c426980c2d3dfb3391154ec398b349c1535d0982024e710 | Python | 5,355 | 132 | import numpy as np
import torch
import pickle
from eval_fns.eval import Masked_MS_SSIM, compute_convolutional_max_metric, compute_convolutional_min_LPIPS
from lib.data_utils.matched_cells_struct import OrderedMatchedCellsStruct
import lib.dataset_config_parser.dataset_config_parser as dcp
from lib.dataset_config_pars... |
bee9f01baa3e678d7b44a72ba40cf4f100789b38ba3e87ec14c2139516b8fdd6 | Python | 5,355 | 82 | import streamlit as st
import numpy as np
from sklearn.preprocessing import StandardScaler
import joblib
import shap
# Load the logistic regression model
logreg = joblib.load('logreg_model.pkl')
# Function to preprocess input data
def preprocess_input(age, blood_pressure, specific_gravity, albumin, sugar, r... |
321f36f42f19bd4e3ae86de0905f17d83b399556cf0c593d05d12238f0a950dd | Python | 5,356 | 193 | # Copyright 2021 Google LLC
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
94ac5c95fd290562a33bc91f609e7c8cc62a1ba3906477e2048aea588b815724 | Python | 5,356 | 203 | import pytest
import ray
from ray._common.test_utils import wait_for_condition
from ray.dag.input_node import InputNode
from ray.dag.output_node import MultiOutputNode
from ray.util.state import list_tasks
def test_output_node(shared_ray_instance):
@ray.remote
def f(input):
return input
with pyt... |
2e4da5c179e5e1d3608b0c1b1f474451ffd4d5517187d77f84b76bca6d2a4923 | Python | 5,357 | 120 | import argparse
from random import uniform
from time import sleep
import torch
from lightning.pytorch.callbacks import ModelCheckpoint, LearningRateMonitor, TQDMProgressBar
from lightning.pytorch.loggers import TensorBoardLogger
from lightning.pytorch.utilities.model_summary import ModelSummary
from lightning.pytorch ... |
158d28c15d714e29cc0480a6e2c3c81cf5f94d7f6c5a7a316dcba40bc145d256 | Python | 5,360 | 125 | import os
import pandas as pd
import matplotlib.pyplot as plt
from adjustText import adjust_text
annotations = ["chess", "gencode", "refseq_ucsc"]
colors = ['blue', 'red', 'green', 'cyan', 'magenta', 'olive', 'black', 'gray', 'orange', 'purple']
os.makedirs("matching_stats", exist_ok=True)
for level in ["transcripts... |
57b1ad8d9d5ee6fb78781220c20a09a38c90c1298c565e02548591ba8193ec64 | Python | 5,365 | 154 |
import os
import pickle
import pandas as pd
import numpy as np
import nibabel as nib
import pcntoolkit as ptk
from pcntoolkit.dataio.fileio import load as ptkload
from pcntoolkit.dataio.fileio import save as ptksave
from pcntoolkit.dataio.fileio import save_nifti, load_nifti
from pcntoolkit.normative import predict, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.