sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
28493074033e91eb69fb2a2877f53afb27865f0361679f67a0d2d54a08ff3164
Python
8,872
225
import torch import torch.nn as nn import torch.nn.functional as F from torch_geometric.nn import BatchNorm, LayerNorm, SGConv, SSGConv import numpy as np import math from .module import MultiHopSGConv class FourierPositionMapping(nn.Module): def __init__(self, in_dim=2, num_frequencies=8, sigma=1.0): sup...
c7ee37d60ee7045d980728867a6d9288e91d58fb6d6cbac49d5bc16ebb2a70ca
Python
8,872
265
from typing import Literal import numpy as np import torch from torch.distributions import NegativeBinomial, Normal from scvi import REGISTRY_KEYS from scvi.module.base import BaseModuleClass, LossOutput, auto_move_data class RNADeconv(BaseModuleClass): """Model of scRNA-seq for deconvolution of spatial transcr...
d1200332ddeea79aa01c59ae1641f442c0ff8cc8b5fe0d968afc7211a03ba0ff
Python
8,872
266
import math from typing import Optional import haiku as hk import jax import jax.numpy as jnp from folx.experimental.pallas.attention import multi_head_self_attention from .basic import Constructor, MultiDimLinear, PsiformerDense, param_free_ln class MaskedMultiHeadSelfAttention(hk.Module): def __init__( ...
2ce5427b535ff87efc63d2f6bd591667d41af445c9591f58b34fc202af288f11
Python
8,885
151
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
d918af5ee4de0d8bbb1c9d127d3ef116bf417a1f4a815e26f6803f1911a6495f
Python
8,886
152
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
fa4952dc8f13a56f23a6efea6a46eddd7a0d55d4adee7670186f7376e189a7b3
Python
8,889
223
#!/usr/bin/env python import argparse import ast import csv import gc import logging import pathlib from functools import lru_cache from pprint import pformat import torch import torch._dynamo from d3text import data, factory, runtime, tracking, utils from d3text.cli.args import non_negative_limit from d3text.datase...
a7a44c8f99aa52124e11131b1c1d89077fd3e5ea8a71dd5952fa80b2b7b22807
Python
8,899
186
import tkinter as tk from tkinter import ttk from src.window_utils import center_window_on_screen class ExportOptionsContainer(ttk.Frame): def __init__(self, parent, file_path_var, settings_manager, extract_button_click_handler, save_image, ...
629f0a74860d34e7929d716549e8134ec7f0de187002ff9c2b9e5e202a9ce83e
Python
8,900
213
import theano import theano.tensor as T from theano import In import numpy as np from theano import config def softp(x): return np.log(1 + np.exp(x)) class GenerativeModel(object): """ Generative Model Interface Class The generative model describes the fluorescence dynamics for given latent spikes: ...
8bd10122e1a0b75aa5305f5729d651a65c10d84b5d4dfa3ef58fa191a2900c3d
Python
8,900
216
import os import json import subprocess import sys import tempfile import unittest from pathlib import Path from scripts.validation.common import ( Case, _generated_example_files, apply_legacy_settings, compare_csv, csv_comparison_for_cases, environment_for, load_cases, load_comparison_...
5193517ce08d5a2120c029ac063547e7cefdc1e01b57074af96ffd156c541593
Python
8,903
216
# -*- coding: UTF-8 -*- """ @Project: iDCF @File : shap_utils.py @IDE : PyCharm @Author : hjguo @Date : 2025/7/11 14:51 @Doc : SHAP interpretability analysis code """ import shap import torch import numpy as np import os import matplotlib.pyplot as plt def explain_expression_genes(model, data_tensor, featur...
c97fff7381aea8293db96b20ecb2658ce517709f4e0d41065152afc1ec5fc3bd
Python
8,908
149
from typing import Union, List import numpy as np import torch from acvl_utils.cropping_and_padding.bounding_boxes import insert_crop_into_image from batchgenerators.utilities.file_and_folder_operations import load_json, save_pickle from nnunetv2.configuration import default_num_processes from nnunetv2.training.datal...
1a49ccec63fae37068cf5da4376f1fe701768d9ec78af04208f97c22b3833dc2
Python
8,909
174
from typing import Dict, Optional import torch import torch.nn.functional as F from dgr.utils.warp import grid_warp_x, tv_loss, jacobian_det_penalty_1d_x, grid_warp_2d from dgr.utils.splat import softmax_splat_2d class ReconLoss(torch.nn.Module): def __init__(self, ssim_weight: float = 0.2): super().__i...
8979a9e70ff43c88dd7cbd748b50e0125ea1ace92a1ee8e4d5321ba003fc7331
Python
8,909
279
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging from pathlib import Path import shutil from tempfile import NamedTemporaryFile from typi...
7a58c03f96d4c1b6a4522b185ff5d1bc5b41bb7206e15a581caa34f5ad3f3aaf
Python
8,918
258
from e3nn import o3 from nequip.data import AtomicDataDict from nequip.model import model_builder from nequip.nn import ( SequentialGraphNetwork, AtomwiseReduce, ForceStressOutput, ) from nequip.nn.embedding import ( AddRadialCutoffToData, PolynomialCutoff, ) from nequip.nn.embedding...
f3dfab08f8efbc851b0be79557963ccd2f4c3ffa371372167de28efab9243361
Python
8,919
245
import logging import os import shutil import subprocess import sys from typing import List, Dict, Optional, Set, Union from types import SimpleNamespace from .config import load_config, merge_namespaces from .punchcards import PunchcardDeck, PunchcardSubset, PunchcardView def is_task_complete(paths: SimpleNamespace...
4ba486dbfdfe8c8e999608d6e9807b82da3612eabbfd14bf5b070c9d3d2db1b5
Python
8,922
227
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import dynamicconv_cuda import torch import torch.nn.functional as F from fairseq import utils from fairseq.incremental_decoding_utils import ...
319b96fcb97c8eba5075fc32dc56163c7f0f237a1aeb4c33add22961ca5e9ba1
Python
8,928
231
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc def get_init(myelin_data, gradient_data, highest_order, init_para): ''' Thi...
1e8be41a26c9890edb37d912db0da8b923fb8ad5334f963c987214eb6eeec690
Python
8,931
200
"""Used to operate on a sub-graph of a larger GO DAG.""" __copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" import sys import re import collections as cx from goatools.gosubdag.gosubdag import GoSubDag from goatools.wr_tbl import wr_xlsx as wr_xl...
00e6e60ddc817f7bf94402990705efa2b925cbb5c0b2fd7e34c1ac94828a91e8
Python
8,935
284
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.console.commands.update import UpdateCommand from tests.helpers import get_package if TYPE_CHECKING: from pytest_mock import MockerFixture from poetry.poetry import Poetry from tests.helpers import DummyRepos...
452409567afd91454a5f6d1114bf46de7119e0b5dea7441a20acc5cfcf0141f7
Python
8,936
228
from collections.abc import Callable from functools import partial import click import os import zarr import cv2 import dask.array as da import joblib import numpy as np import xarray as xr from skimage.feature import multiscale_basic_features from skimage.morphology import binary_closing, binary_dilation, binary_erosi...
7b479e9b64a077d6e511cb451a7edee65a424656e9d4176a25868584de2ca43c
Python
8,936
275
import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader from typing import Optional from abc import ABC, abstractmethod from simulation_encoder.logger import Logger class BaseRBM(ABC, nn.Module): def __init__(self, logger: Optional[Logger] = None): supe...
5339f0ad1476572d5eb7302488a3537dab3ec0a2be679ef238a908cd4bd4a603
Python
8,940
211
''' Logic to simulate senescence response for various tau fractions, the results are stored on disk for downstream processing by heatmapandrearange.py Logic is seperated to support running the simulations on multiple processors ''' import numpy as np from scipy.integrate import solve_ivp import os from numba import n...
1505b1d94e73b25bc4aa595364a26ea82ba79896aaf470f20c0af7b72495aa30
Python
8,946
225
#!/usr/bin/env python3 """Maintain RNAlysis contributor acknowledgments. Two capabilities, both dependency-free (stdlib only) so the CI workflow needs no ``pip install``: * ``--update-readme`` append any GitHub contributor missing from the contributor roster in README.rst. Never re...
af4534d58f98833d39cd08e67a10658a48c9913571ccabbb707bfe83242fc417
Python
8,950
181
"""Manage evidence codes as reported by the Gene Ontology Consortium.""" __copyright__ = "Copyright (C) 2016-2019, DV Klopfenstein, H Tang. All rights reserved." __author__ = "DV Klopfenstein" import sys import collections as cx # pylint: disable=line-too-long class EvidenceCodes(object): """From http://geneont...
6b57666bfc769fbefcbaf47fa45a625bdcc52d22c5263d2e09de16f0c5eb71c2
Python
8,953
255
# -*- coding: utf-8 -*- import pdb import os import glob from multiprocessing import Pool import sys import glob import time import subprocess, re import numpy as np import pandas as pd def run_command(cmd): """Run command, return output as string.""" output = subprocess.Popen(cmd, stdout=subpr...
7cc59466669ecd97c43653226a60078bdfc9da95a9694afe0833ada883f71083
Python
8,953
209
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Modifications by Roshan Rao # # 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:/...
43458c6b18731364049dc325d30f939c3ca38fce8748319fba542cc9e4bb80d5
Python
8,954
226
# Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors import torch import torch.nn as nn from .AMPHelpers import aniso_features_qmmm, aniso_features, build_poles from datastructures.Graphs import Graph from modules.D4DispersionScaling import D4 from modules.Modules import AtomicEmbedding, Bes...
57a0933a7c6c3c5795141f5a727a94a83df062b1a91a4b827d8c4300516b4b0c
Python
8,955
179
import sys sys.path.append("../utils") import torch import torch.nn as nn from utils import utils_basic import config.cfg_lodet as cfg #处理类别不平衡问题,使得模型更关注难分类的样本,从而提高性能 class FocalLoss(nn.Module): def __init__(self, gamma=2.0, alpha=1.0, reduction="mean"): super(FocalLoss, self).__init__() s...
1e030d9291c405940aac9abcb9c36e7b52dc399d2323d496a6cba92461999259
Python
8,957
159
import numpy as np import logging import collections from scipy.sparse import csr_matrix, coo_matrix, csc_matrix import pytest from gsa_mixer.utils import AnnotUnivariateParams from .utils import UnivariateParametrization_natural_axis from .utils import UnivariateParametrization_constPI from .utils import UnivariateP...
0896c059fed1e8f45c359204f46aa4a10eb4c8cec9c418ac15a19bbf0fe3df7f
Python
8,959
218
from src.utils import read_gtf, read_SJ import polars as pl from Bio import SeqIO import os import pyBigWig from pathlib import Path def gtf_to_SJ(gtf): import numpy as np assert gtf["feature"].unique().is_in(["exon", "CDS"]).all(), "GTF must only contain exon and CDS features" return gtf\ .filte...
b80fa43109a9c651e244262ec396fc0bbb3737c89b2db35b668988b45052950f
Python
8,961
248
from __future__ import annotations from pathlib import Path import pandas as pd from st_risk.models.base import BaseSpatialModelOutput from st_risk.models.io import save_base_model_output from st_risk.reporting.anchored_validation import ( AnchoredModelSpec, best_score_per_proxy_sample, build_model_summa...
caded74599b29cd51ce004cf37545d7991e836a5aa85438844efca6c458d412a
Python
8,962
253
# checking program import math import pandas as pd from functools import reduce import matplotlib.pyplot as plt import glob, os import numpy as np import matplotlib.lines as mlines import matplotlib as M import json import matplotlib.ticker as tkr # has classes for tick-locating and -formatting # for cdci G...
70728e1158f6e7a19ade21af77df8c691fbbaa7a04f5d1219694d3be83e034a9
Python
8,963
171
import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=FutureWarning) import joblib from pathlib import Path import numpy as np import pandas as pd from analysis.metrics import dPrime_model, dPrime_monkey, dPrime_model_RL from sklearn.model_selection im...
9dccb4825ede371fa260b13b565b96cc18d5f3828c80b6d01181a0bd11d18059
Python
8,967
226
import qt, vtk, slicer import numpy as np from ..Widgets.ToolWidget import AbstractToolWidget from ..Effects.DrawEffect import AbstractDrawEffect from ..Helpers import GridNodeHelper class DrawToolWidget(AbstractToolWidget): def __init__(self): toolTip = '' AbstractToolWidget.__init__(self, 'Draw', t...
1a669bc66159cfdbe8e02a8325fa0fdb23ef5a74ada44d19e3897a6dc93f4a87
Python
8,969
175
#!/usr/bin/env python3 """ EIF2S1 R3 REVISION - AD REPLICATION COHORT (Reviewer 4): GSE5281 superior frontal gyrus. Author: Drake H. Harbert (D.H.H.) | ORCID 0009-0007-7740-3616 | Inner Architecture LLC. Date: 2026-07-05 Reviewer 4 asked for the EIF2S1-PELO analysis in an additional disease dataset (frontal cortex AD...
2833d2ed1ade79e8114cd0e538c8b8aa8e9a69db6600405856b5b299abfba817
Python
8,970
258
import typing import math import numpy as np import sklearn.metrics import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.weight_norm import weight_norm from torch.utils.checkpoint import checkpoint def Linear(in_features, out_features, bias=True): m = nn.Linear(in_features, out...
447adc0ab523aa598e65b5ae4ab8e7d1f8e69903d3f484235d6e1a6f9b5a2edb
Python
8,971
274
import sys import os import itertools import numpy as np from parcellate.constants import * def stderr(s): sys.stderr.write(s) sys.stderr.flush() def get_iterator_from_grid_params(grid_params): _grid_params = {} if grid_params: for grid_param in grid_params: _grid_params[grid_pa...
5ad5bb8e55f2762cd9986d167f880072dda8ebb5f45c282a8ed430f5369cb2f4
Python
8,972
257
from pathlib import Path import os import glob import re import numpy as np import pandas as pd import pickle import argparse # ibl specific imports # from one.api import ONE from celltypes_ibl.params.config import DATASETS_DIRECTORY from deploy.iblsdsc import OneSdsc as ONE from iblatlas.atlas import AllenAtlas from...
9f4423f2afaa3161cf56b475757fc42c126c2373647edf133fa48596fdf4b091
Python
8,985
272
from __future__ import annotations import collections.abc import logging from typing import TYPE_CHECKING import numpy as np import pandas as pd import pyro import torch from scvi._constants import REGISTRY_KEYS from scvi.data import AnnDataManager from scvi.data.fields import LayerField from scvi.module import Amor...
0d46eab5738f2055a12546f8455f4b55ae540630f08494cf612521ce6d7d95ef
Python
8,991
205
#!/usr/bin/env python3 """Trains up a sequence-to-profile model in the BPNet style. This program generates a neural network that maps genomic sequence to experimental readout. In cases where you don't need to regress out a bias track, this is the only training program you'll use. The required input files are two hdf5...
7f46fad9fa1d72f3a97f7c41ef3460f9c3bd70b46504d86c6c013693a237b4ab
Python
8,992
261
# extract_timeseries_c1.py # C1 extraction using Cambridge/BASC atlas (3mm), FIXED to: # - use BASC scale064 explicitly # - extract ONLY run-1 # - feed ONLY preprocessed SPM bolds (prefer wrsub-* then wsub-*) # - NEVER use raw (skip if no wr/w exists) # # Tasks kept: encoding, similarity, rest. import...
ffbf9ade2adc673d52a6820c2fa881934c0dbe4d9b9adc6e2b54f8ffc1aab9ac
Python
8,992
237
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc import warnings def get_init(myelin_data, gradient_data, highest_order, init_para):...
b3846507da2e620f8e17014a1c042b3092e3d93b71bb7ab5c8a5630d314d7f40
Python
8,995
281
# Copyright 2026 Hongyu Sun # Licensed under the Apache License, Version 2.0 import argparse from pathlib import Path import h5py import numpy as np import torch import matplotlib import matplotlib.pyplot as plt from model_eval import QNO from utils import set_seed matplotlib.rcParams.update({ "font.size": 12, ...
51043dd1c228520c157421a97cd2f0e7886c44aa7cf91c03150bae34d3ec2217
Python
9,002
242
#!/usr/bin/env python3 """Execute the calculation-combination matrix in isolated external copies.""" from __future__ import annotations import argparse import json import time from datetime import datetime, timezone from pathlib import Path from typing import Any try: from .common import ( DEFAULT_EXAMPL...
65166005049710d44e6a03a65c7d8df4acb24fb6b3a2477cae3ffb2f243b1db2
Python
9,007
185
"""Page 9: Prediction Error Analysis.""" import streamlit as st import plotly.express as px import plotly.graph_objects as go import pandas as pd import numpy as np from utils import PIPE_ORDER, PIPE_COLORS, style_figure def render(store, dataset): st.header("Error Analysis") st.markdown( "Go beyond ...
4f5b304b60d0d03e5201845472969687c52e66a7de7db06859fa8db4d4143f14
Python
9,008
231
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from dataclasses import dataclass, field from typing import List, Optional import torch import torch.nn.functional as F from fair...
ac0915c6e66c0380e426f1afb794975a968dc492db894c15c9d8fbb02967d556
Python
9,008
229
from typing import Dict, Type, Callable, Optional, Union from torch.utils.data import Dataset from .models.modeling_utils import ProteinModel from pathlib import Path PathType = Union[str, Path] class TAPETaskSpec: """ Attributes ---------- name (str): The name of the TAPE task dataset (T...
b2162315b45ea3890863c24aace91bc278aaef9686e02be92051881a5a829830
Python
9,008
311
import os import argparse import sys import torch.optim as optim import torch import pandas as pd import yaml import ast # ---- Training ---- if __name__ == "__main__": project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(project_root) # Simulate ...
0925abcba8f87d84819921ae661fdafa5c871226a5dbceca61e9947e63acad98
Python
9,019
203
from collections import OrderedDict from copy import deepcopy from typing import Union, Tuple, List import numpy as np import pandas as pd import torch from batchgenerators.augmentations.utils import resize_segmentation from scipy.ndimage import map_coordinates from skimage.transform import resize from nnunetv2.config...
26ab0409df7419f888a87f1917a2f5aeb9a17bfdea9cbf85e0405608e30019a3
Python
9,028
239
""" hippie-wf3dacg — C4 H5 Dataset Loader ===================================== Reads C4-database H5 files (Beau et al., 2024) and returns the arrays needed to construct a HippieWF3DACGDataset. Per-dataset conditioning metadata (source / super-region / technology / layer) follows the same vocabulary used by the rest ...
5425e623968c59e1ac4007d5c0c9e17d0845cb1e782785f2fde6c3fbb36d29f6
Python
9,028
259
from collections.abc import Iterable from dataclasses import dataclass, field import numpy as np import pandas as pd from rich import print from sklearn.gaussian_process import GaussianProcessClassifier from scvi.utils import dependencies @dataclass class DifferentialExpressionResults: """Dataclass for storing ...
281cf3939cabba172f26dd2814eed93429d0a59daec5f843d30d06145f8ff8ee
Python
9,031
238
""" Cross-validate all forecasting models on the training split. The script first reserves a subject-level holdout split, then runs LOSO-CV only over the train subjects. Torch model checkpoints are written under ``saves/checkpoints`` under the parent ``fmri_connectivity`` project root. """ from __future__ import anno...
358fa8a8bcbd89ebefecd8b5deb30a08fde1f2051f20684987593f89d4086f7f
Python
9,032
234
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import math from pathlib import Path import torch from fairseq import checkpoint_utils from fairseq.data.data_utils import le...
03a23122f76ee3af891289f6bd5c92196c9d2dc1ebf8168eed0437ef173d5ade
Python
9,037
319
from reproducible_ephys_functions import ( filter_recordings, labs, BRAIN_REGIONS, query, get_insertions, ) import pandas as pd import numpy as np import matplotlib.pyplot as plt from fig_ephysfeatures.ephysfeatures_functions import get_brain_boundaries, plot_probe from mpl_toolkits.axes_grid1.inset...
582fe5562afbe123f1a61550479978c8d0d961383166bdb37f4ecbd923f08154
Python
9,040
230
import numpy as np import pandas as pd from collections import OrderedDict from ...common.utils import printProgressBar def remove_double_counted_spikes(spike_times, spike_clusters, spike_templates, amplitudes, channel_map, templates, pc_features, pc_feature_ind, sample_rate, params, epochs = None): """ Remove p...
ddd4c46372d054331defefd03e241ea736a70613e2465f50443e94b565af7cc0
Python
9,049
254
"""The bridge table's on-disk contract and its two-way reading. The table is the only thing standing between an evaluation and a 176 MB NCBI dump, so what it says has to survive a round trip and refuse to be read as identifiers of another kind. """ import collections import pathlib import pytest from d3text.datasets...
8749d53b79d94235b5ce295a4045100fbb348fb0fc5030bfb7d8fd4a2f35746a
Python
9,067
270
import logging from typing import Optional import anndata import numpy as np import pandas as pd import scanpy as sc from sklearn.cluster import KMeans from sklearn.metrics import silhouette_score from sklearn.mixture import BayesianGaussianMixture from sklearn.neighbors import KNeighborsClassifier from tqdm import tq...
ed284bb23aae35c52a57a379963ef669a2929de5cd096725a56f12b4496a8e65
Python
9,068
270
"""End-to-end shape-contract smoke tests for `ETEBrendaModel`. A real model with a tiny random BERT injected for the frozen base, so there is no download. Parametrized over the `device` fixture, so on a GPU machine these also exercise device placement of the heads, buffers and pooled tensors. """ import pytest import...
e6d2628243834230a7858a114c242f1fb3c55c55d6617cf5024ddc2e23522e20
Python
9,070
176
import json import os from pathlib import Path import sys import tempfile import unittest from unittest.mock import patch import zipfile import nibabel as nib import numpy as np os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") os.environ.setdefault("SEGREF3D_DISABLE_SAM2", "1") MODULE_DIR = Path(__file__).resol...
a1d1acd78c658d5803880005cfec10f63f3f904b2262854da5a255d92fb0d5aa
Python
9,075
301
import os import anndata as ad import numpy as np import pytest from scvi.criticism import PosteriorPredictiveCheck from scvi.criticism._constants import METRIC_CV_GENE from scvi.data import synthetic_iid from scvi.external import cytovi RAW_LAYER_KEY = "raw" SCALED_LAYER_KEY = "scaled" NAN_LAYER_KEY = "_nan_mask" R...
593661523b1c309f26cffa297c78f37cebfca837b807c0c1c4cab72903eacbdf
Python
9,076
270
"""Base neural network components for DIAGVI model.""" from __future__ import annotations import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Normal from scvi.utils import dependencies EPS = 1e-8 class DecoderSinglePathway(nn.Module): """Single-pathway decoder fo...
7aaf8c604fe117783a5897120789104a8c81693cbf74ace1d9098f7d78dd5501
Python
9,076
255
# sam2_interface.py import os import sys import numpy as np from PIL import Image from PyQt6.QtGui import QPainterPath from PyQt6.QtWidgets import QApplication # # sam2pkg/sam2 をパスに追加 # BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # SAM2_DIR = os.path.join(BASE_DIR, "sam2pkg", "sam2") # if SAM2_DIR n...
4e5ef1cd73fdb31f31c8afee93fc5a04435be1110025291bf0a7c6e0f8da2318
Python
9,083
275
from __future__ import annotations import logging from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Iterable from typing import Literal from anndata import AnnData from mudata import MuData import numpy as np from scvi import REGISTRY_KEYS from scvi.data import AnnDataM...
c9deb8d9af936fbc3b92d69da078e6e9565e4f538a4211c54f48687b25487ef3
Python
9,086
267
import math import torch as th from torch import nn, Tensor from dataclasses import dataclass from typing import Tuple, NamedTuple from einops import rearrange, repeat from utils import M2H from config_base import BaseConfig from .nn import conv_nd, linear, timestep_embedding from .MBAblocks import ResBlockConfig, At...
7201219a51a4a0fff87bb4d3f847938715d403b0d9d0daf909676899b1ecc131
Python
9,088
265
"""Functions for creating splits of datasets used with neural network models, such as the standard train-val-test splits used with supervised learning methods.""" from __future__ import annotations import logging import pathlib import numpy as np import pandas as pd from ...common.labels import from_df as labels_fr...
919431f936b198f68338a2f1e9e6f8eb78f0da5689e4e4a98887e32cbec6c561
Python
9,088
261
from abc import abstractmethod from itertools import combinations from math import prod import networkx as nx from tqdm.auto import tqdm from pgmpy import config from pgmpy.models import DiscreteBayesianNetwork, DiscreteMarkovNetwork class BaseEliminationOrder: """ Base class of the greedy elimination-order...
17bed1309507cda69fdee29e95d18c3be524d3053294fe2f443022dcbbf6d158
Python
9,101
187
#!/usr/bin/env python3 """Análise da DOS das 1.784 perovskitas: o que ela responde para o artigo. Consome `dos_perovskitas.npz` (curvas em grade relativa a E_F + escalares), produzido por `dos_remoto.py`. AS PERGUNTAS, em ordem de importância para o manuscrito do gap: 1. VALIDAÇÃO nas 1.784 (não em amostra): o gap...
6a9f2e5278c0d84ee85d240a706595841e7e32edb45a3ae765003ff401103eb6
Python
9,102
202
import theano.tensor as T from lasagne import init from lasagne import nonlinearities from .conv import Conv2DLayer __all__ = [ "LocallyConnected2DLayer", ] class LocallyConnected2DLayer(Conv2DLayer): """ lasagne.layers.LocallyConnected2DLayer(incoming, num_filters, filter_size, stride=(1, 1), pad...
cb1916ffc92a44ef148c96e58cfecb15963c79240c4b7b909433ba36f46b33f7
Python
9,103
226
# -*- coding: utf-8 -*- """ Created on Mon Jun 8 09:32:26 2020 @author: Muammer """ import numpy as np from sklearn.model_selection import cross_validate from sklearn.model_selection import cross_val_predict from sklearn.metrics import matthews_corrcoef from sklearn.metrics import classification_report from sklearn....
8ad445ae2745ef2a84ee067209e4a328707bd74f347a1a17b16542363c182506
Python
9,106
226
import numpy as np import theano.tensor as T from lasagne import init from lasagne import nonlinearities from .base import Layer __all__ = [ "DenseLayer", "NINLayer", ] class DenseLayer(Layer): """ lasagne.layers.DenseLayer(incoming, num_units, W=lasagne.init.GlorotUniform(), b=lasagne.init.Co...
73a4d5de382427fc19bcf0a81560cf2803a64a17f50582a016ca0cd30627ba86
Python
9,107
196
# Copyright 2021 DeepMind Technologies Limited # # 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 agr...
1b41e6afc98b9d65052b26ba5fecafc9ba9e9723fc4d67e2542ed774cf53b062
Python
9,108
227
import torch from torch import nn import math from rinalmo.model.rope import RotaryPositionEmbedding from flash_attn import flash_attn_varlen_qkvpacked_func, flash_attn_qkvpacked_func from flash_attn.layers.rotary import RotaryEmbedding from flash_attn.bert_padding import unpad_input, pad_input from einops import ...
49b4ae32f9e88bb3638a960743192c0d0040bda2f0ee0b86c87403124640b06d
Python
9,108
216
import numpy as np import json import os import sys import copy def estimate_bilateral_weights(estim_w_rh_json, estim_w_lh_json, target_profiles, fixed_symptom_weights): """ Find bilateral symptoms and estimate bilateral weights accounting for possible asymmetry in fiber values Parameters ---------- ...
37a910963f0e6c40edc13df01b89f4cc54004aa3962a6a0d444deb95860de21a
Python
9,110
277
from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING import pytest from poetry.core.constraints.version import Version from poetry.packages import Locker from tests.helpers import get_package if TYPE_CHECKING: from cleo.testers.command_tester import CommandTester f...
bd0f6fd523bc62d49ecbe2b9472987f8f63dbe663ab1029575994ebb148bf888
Python
9,110
206
import unittest import numpy as np from pgmpy.factors.discrete import DiscreteFactor from pgmpy.models import ClusterGraph from pgmpy.tests import help_functions as hf class TestClusterGraphCreation(unittest.TestCase): def setUp(self): self.graph = ClusterGraph() def test_add_single_node(self): ...
02d17024385ef3baad8a4c6473af1ed207ad59ce7396ceab1a31bb991b2a30d2
Python
9,115
171
import numpy as np import torch from tqdm import tqdm from joblib import Parallel, delayed from torch.optim import Adam data_dir = 'PCA_then_ICA' # 1024 patches per video, 20000 iterations stationary_responses_nonrandom = np.load(data_dir + "/stationary_responses_nonrandom_multi_dist_FastICA.npy") moving_responses_no...
cf8b43b81b1182834e9e7627a678c15e9dbbc7f06e5d26ec86e8267dd0cd4cd3
Python
9,116
235
# Form implementation generated from reading ui file 'GUI/main_dialog.ui' # # Created by: PyQt5 UI code generator 5.12.1 and edited by IBP # # To implement: # * Cache last selected folder # * Batch mode for multiple input folders and a single output # * Uncaugth exception handling from PyQt5 import QtCore, QtWid...
cbce7e918e7bc642d60009306be04ef2a2246ea6808796b6ef7e5a8afae9a92f
Python
9,117
241
""" Naive Adjustment Regressor in sklearn Compatible Design. """ import numpy as np from sklearn.base import BaseEstimator, clone from sklearn.linear_model import LinearRegression from sklearn.utils.validation import ( check_is_fitted, validate_data, ) from pgmpy.prediction._base import BaseCausalPrediction ...
d61db262a27c08b2c131b797954a45273b91765f2c0155fc4354311eadc3dc08
Python
9,121
237
# ############################################################################## # GPLv3 LICENSE INFO # # # # Copyright (C) 2020 Mario S. Valdés-Tresanco and Mario E. Valdés-Tresanco ...
3da3477fae87d909a0086daf4c6dbb0e385121e044929a9eedbb60e3a05b28d4
Python
9,123
211
import os import numpy as np import pandas as pd from currentscape_calculator.CurrentscapeCalculator import CurrentscapeCalculator from simulator.ModelSimulator import ModelSimulator from preprocessor.Preprocessor import Preprocessor from currentscape_visualization.currentscape import plot_currentscape class Current...
7bad9c548cdbf575e4076745e6d4978972a32f15616255cd4a79c245a4d3b8fc
Python
9,123
267
# This Python script creates a full set of C++ C header files that # are missing on some platforms. # # Usage: # mkdir cpp_c_headers # cd cpp_c_headers # python generate_cpp_c_headers.py # # The files created by this script are in the directory: # root/boost/compatibility/cpp_c_headers # # Supported platforms: ...
cd752723bcf126ab94ebaea197674a56f6a578a5d6b98b75cd4d2baec11514e8
Python
9,124
218
"""Internal CLI parsing helpers used by GOATOOLS.""" from __future__ import print_function __copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" import argparse import shlex import sys from goatools.godag.consts import NS2GO from goatools.gosubdag...
697e513ab3503df9646b0c0b4742d269da57a13e887f7d642684c232f33a97f5
Python
9,125
271
"""The psycholinguistics noise pool: disjoint per split, stable per process. These pin a `brenda_references` function from d3text's own gated suite on purpose. The pool is drawn once per split inside `brenda_dataset`, so a regression here does not raise — it silently changes which documents a run trains and evaluates ...
da4cc2054646d4f0dbf1cae231785c66f7a00738c3b3e1229c06d995e9b1b789
Python
9,129
243
"""Calculates read level embeddings, then pools by averaging embeddings.""" import warnings import torch import medaka.architectures.base_classes as base_classes import medaka.architectures.read_level_modules as read_level_modules import medaka.features class ReversibleLSTM(torch.nn.Module): """A wrapper around...
94ed027b88878d0c27d1c5c65338fdd34b82a548e2ec4ebd7dc008e21637687c
Python
9,131
211
import os import numpy as np import pandas as pd from currentscape_calculator.CurrentscapeCalculator import CurrentscapeCalculator from simulator.ModelSimulator import ModelSimulator from preprocessor.Preprocessor import Preprocessor from currentscape_visualization.currentscape import plot_currentscape class Current...
3d51a38a4d8699c4c793eaf45cabc50b245aa9a3819812d338aa936b3a82a3f9
Python
9,132
241
#!/usr/bin/env python from itertools import combinations import networkx as nx import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from pgmpy import config from pgmpy.causal_discovery._base import BaseCausalDiscovery, _TreeSearchMixin class TAN(_TreeSearchMixin, B...
4de998e7b7bc877f62a436c1d6c363642f4703c45b542d09520be5deaede7192
Python
9,132
224
""" Study Preprocessor for NeuroVFM Loads and preprocesses medical imaging studies for inference. """ import torch from typing import Dict, List, Optional, Union from pathlib import Path import logging from neurovfm.data.io import load_image from neurovfm.data.preprocess import prepare_for_inference, tokenize_volume...
8fe9888fb53a499d5df8a909eabf4e23b722a1c675d1142640357e8f616e52ea
Python
9,132
301
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import torch from fairseq.modules import ( ESPNETMultiHeadedAttention, LayerNorm, MultiheadAttentio...
d4b1c449072fc2217b7e7f20097ad7169766405ff78e4ea19f4833ec6f0d79ae
Python
9,133
279
""" Copyright (c) Facebook, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ import json import torch from torch_scatter import segment_csr def read_json(path): """""" if not path.endswith(".json"): ...
0fd8863656fa6c9b069569343eed823977cfcc87b5a3f8e12ae8e54a2451c4db
Python
9,134
274
# Copyright 2021 DeepMind Technologies Limited # # 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 agr...
5e1b8926617309e2e77256c4aad925a72e642059b5cf5b4a472f2fd66a254a35
Python
9,141
253
# Copyright (c) 2024, Shenghao Cao & Ye Yuan. Shanghai Jiao Tong University, Shanghai 200240, China # Some classes and functions are modified from scGPT (https://github.com/bowang-lab/scGPT), copyright (c) 2022 suber # Some classes and functions are modified from scFoundation (https://github.com/biomap-research/scFound...
dbed9b8fb13c8513850e848e4865fa4fbd3e2ec390ac8ae7521b0555c6d022e0
Python
9,148
244
"""Unit tests for packaging/snapshot_api_payload.py (pure logic; no live network). The script lives in ``packaging/`` (which is *not* a Python package and would shadow the PyPI ``packaging`` distribution if imported by name -- see ``tests/test_contributors.py`` for the same pattern), so it is loaded directly from its ...
f6a0da726a8bcdd40640fab39c0814a56d6188531b44a3ce6e7e7137755c9a02
Python
9,149
270
import logging import typing import torch import torch.nn as nn from torch.nn.utils import weight_norm from .modeling_utils import ProteinConfig from .modeling_utils import ProteinModel from .modeling_utils import ValuePredictionHead from .modeling_utils import SequenceClassificationHead from .modeling_utils import Se...
30154f906a18e8700f35984ffb3c83537bd0e727f830786f85c006d405a3c666
Python
9,156
258
import pickle import numpy as np import os import json import scipy.io import scipy.spatial.distance as ssd import scipy.cluster.hierarchy as sch from scipy.stats import pearsonr from helper_functions_egestive_priming import * from helper_functions_image import plot_group_neurons from collections import Counter from sc...
09c1afc1eba2fd10dece757ddb05724de3d95d647f2068c5b7df71155d4eec1a
Python
9,160
286
# encoding: utf-8 """ @author: LiFan Chen @contact: s18-chenlifan@simm.ac.cn @software: pycharm @file: utils.py @time: 2019/7/19 15:29 @desc: """ from collections import defaultdict import copy import importlib.util import math import os import sys from typing import Callable, List import warnings import torch import ...
c91cb255a6ab0ba8d1d79fd9ddce223e15dbb0bf0a3c78355343c11165a6c310
Python
9,161
180
from PyQt5.QtWidgets import * import os from PyQt5.QtGui import * from PyQt5.QtCore import * import sys import cv2 as cv import numpy as np class Data_Postprocess(QWidget): def __init__(self): super(Data_Postprocess, self).__init__() self.setFixedSize(400, 275) self.setWindowTit...
c477f66b742490f0cb148800723939f7a4bd3411694ff9293bf5f9e885b9ade3
Python
9,162
244
from __future__ import annotations import math from typing import TYPE_CHECKING import torch from torch import nn if TYPE_CHECKING: from typing import Any class StackedLinearLayer(nn.Module): """A parallel stacked linear layer that applies multiple linear transformations in parallel. This layer applie...
5597f7a429688d4a09267ef11ce35fccfd2589cdfaaf628627eadfe6fb18ee0b
Python
9,166
205
import scipy.stats as ss import numpy as np from scipy.stats import norm import cmmcost_omp as cmmcost import argparse import sys import time if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--no-precision", action="store_true", help="Don't measure precision") ...
969d2c714c6645efd6fb6f82b73d5a2eb4d3a9ab63da23ef0162ce9b57b08888
Python
9,166
269
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/utilities.py # This file includes the modifications to the source codes according to this project! import tqdm import gensim import logging import numpy as np import pandas as pd from gensim.models.word2vec imp...
994b47578331cb2b3002872777a046c202f4efeae61d0be0e9503c136e2dc31b
Python
9,168
197
from time import localtime, strftime import pandas as pd import numpy as np import argparse from collections import namedtuple from multiprocessing import Pool import scipy.io as sio annotation_categories = ["transcript", "exon", "intron", "utr5", "utr3", "coding", "upstream_1kb", "downstream_1kb"] v...