sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
868fa1d06612aeaace93dc283133db053f815cebf8c5ebe464681ef260eca71c
Python
8,658
211
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice...
9fffe51a87880ebe45d6fbf9a1048384545b7ef98037da52d8a2274aaffdd655
Python
8,658
229
# 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 Sequence, Union import numpy as np import sklearn.metrics from numpy import ndarray import scipy.stats import math import ...
3854c583b0f211a32a6656854dfb6bb9bbe905575d5985d42b02dd513da5ab11
Python
8,660
187
import collections.abc import functools import json import typing import warnings from pathlib import Path import typing_extensions from rnalysis import FROZEN_ENV from rnalysis.utils import parsing PARALLEL_BACKENDS = ( ('multiprocessing', 'sequential') if FROZEN_ENV else ('multiprocessing', 'loky', 'threading'...
9b111861ab8fc458254a1c499cc4e223994182fe48da7105cc034e435f51120b
Python
8,661
227
import numpy as np import pytest from scvi.data import synthetic_iid from scvi.external import RESOLVI @pytest.fixture(scope="session") def adata(): adata = synthetic_iid( generate_coordinates=True, n_regions=5, n_proteins=10, ) adata.obsm["X_spatial"] = adata.obsm["coordinates"] ...
beebec949688fcbfea335a3f12e46f7d719bea46c96dd5da10179600bf160519
Python
8,663
231
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from scipy import ndimage import random from tractseg.libs import img_utils def pad_and_scale_img_to_square_img(data, target_size=144, nr_cpus=-1): """ Expects 3D or 4D image as i...
38e2240e6484354088c8e6a8df49fb8a92d31b67b9bd01b5943f3345964baa6a
Python
8,667
189
""" Name: Robert Kim Date: 05-14-2023 Email: robert.f.kim@gmail.com Script to quantify CEBRA-trajectory separation for attended vs. unattended modality in the 2-modality DMS RNN. Computes bootstrap-style Euclidean distances between condition centroids in each attention regime, then plots them side-by-side as boxplots....
e74a66c910c6332469c529e02bf2b0a24d218ac0fe87e54eca47c860b4f78469
Python
8,667
225
""" This module contains data processors for the training of Garfield model. """ from typing import List, Optional, Tuple import scipy.sparse as sp import torch from anndata import AnnData from torch_geometric.data import Data from torch_geometric.transforms import RandomNodeSplit, RandomLinkSplit from torch_geometri...
b72ce83b577526adcb24db9a67f0d71514aceb29cf5be293c715f55fd63bf6b9
Python
8,669
241
import numpy as np import torch from torch import Tensor import torch.nn as nn # from .._internally_replaced_utils import load_state_dict_from_url from typing import Type, Any, Callable, Union, List, Optional import torch.nn.functional as F device = torch.device("cuda" if torch.cuda.is_available() else "cpu") def co...
de77ffb2ac80ddc602afadb87d3cf05df2e49ed351652cab8ddff9c15093336d
Python
8,669
250
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory.abs from dataclasses import datacla...
531e9046b8db9aa3bd114e3a7df83400ca12b1fd2370ea530f43c9f0c75521a2
Python
8,670
255
from __future__ import annotations import os from pathlib import Path from typing import TYPE_CHECKING import pytest from cleo.io.buffered_io import BufferedIO from cleo.io.null_io import NullIO from packaging.utils import canonicalize_name from poetry.factory import Factory from poetry.publishing.publisher import...
ab903f077b1fb25ef719982783f590949910facadb224d51ae22d3625dd9464b
Python
8,670
230
import math from functools import partial from typing import Dict, Tuple import haiku as hk import jax import jax.numpy as jnp import optax from ..device_utils import DEVICE_AXIS, replicate_on_devices, select_one_device from ..geom import norm from ..preprocess.augmentation import random_rotation_matrix from ..types ...
2275c851c7ebf9740a902a2fd13f2c44630626a817257a4244ff7efec15d4794
Python
8,671
230
from typing import Dict, List, Tuple import numpy as np import pandas as pd from BLEval.evaluator import Evaluator from BLEval.data import EvaluationData def _normalize(arr: np.ndarray) -> np.ndarray: """ Min-max normalize an array to [0, 1]. Parameters ---------- arr : np.ndarray 1-D a...
0805102ab244f2bc2fa7a76af910de65779422627e1ce09cab96ef08cc65323f
Python
8,678
281
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch from graph_tool.all import Graph from graph_tool.topology import max_cardinality_matching from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, group, df, x0, x1, n_bins, n_boots):...
b4fa7002cb01bfb80598754f0b8278fd0e37bab6f8fd5cc6f14fc67188bfea66
Python
8,688
226
# /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 scipy.io as sio 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...
479a6d8073def046639f4ef898fb8a02e442c7723efeee406da7ce4b1e2de5b5
Python
8,689
282
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch import jax from graph_tool.all import Graph from graph_tool.topology import max_cardinality_matching from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, group, df, x0, x1, n_bins...
322bbbd29ab1a406d16204fcb324ab5a6c6f129a4e9210893a1692aa8fb26947
Python
8,690
261
# -*- coding: utf-8 -*- """ Created on Mon Jul 15 15:16:22 2019 @author: 俊男 """ # In[] Define the class for Simple Regressor from sklearn.linear_model import LinearRegression import pandas as pd class SimpleRegressor: __regressor = None __y_columns = None def __init__(self): self.__regressor = L...
b8c8d65ddaf84aa1f2dfde26b990ab83236bf769f817157745b90fab0f7f9a6d
Python
8,690
283
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch import jax from graph_tool.all import Graph from graph_tool.topology import max_cardinality_matching from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, group, df, x0, x1, n_bin...
cbc2ae7dffc5c1d605f832815fe18436c905e80e77140e9591f6072f87330e14
Python
8,690
229
from pathlib import Path import cv2 import numpy as np import matplotlib.pyplot as plt import xarray as xr from skimage.segmentation import mark_boundaries import dask.array as da import decord import click from matplotlib.widgets import RadioButtons from .lookup_utils import build_lookup_table, segment_image_with_lo...
283fcd97dc81a9cebfa0e8a2e70f1436b652458c48f8cd4340921f49423d0838
Python
8,691
271
"""Pure unit tests for `d3text.schema`. No data files, no network, no GPU: the schema is a leaf module over plain dataclasses. """ import dataclasses import pathlib import pytest from d3text.schema import EntityType, RelationType, Schema ENZYMES = EntityType(name="enzymes", prefix="enz") BACTERIA = EntityType(name...
7d656bff8eedb1c5a925d964701389dee471301c41f92e9ac2022c75f455f38c
Python
8,694
223
import os import glob import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy.io import loadmat from scipy.stats import kruskal import scikit_posthocs as sp fig_dir = '/home/shared/instruction_timing/figures/fig6_review/' os.makedirs(fig_dir, exist_ok=True) # Models without feedforward inhib...
ca293ab0d6bbec60cbec29b0d55d750ef2e63bbb8bdf250d32e30f42c085e0ff
Python
8,694
226
# /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 scipy.io as sio 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...
160d065a452fc1e61181d0abb41e669ef55791d5844c5455ece43ed436f01864
Python
8,695
225
"""Reclassify organisms in the `other_organisms` fields of the doc database. When one of those organisms is a bacteria in the NCBI taxonomy, move it to the bacteria field of the document and add an entry for it in the `bacteria` table of the database. Similarly, if one of those organisms is a bacterial strain, move i...
27f099b33c2c1ef235461a44ff77173c12909060ca1cf230b0a22ec6ac735958
Python
8,697
239
"""Tests for hessian.find_out_idx. Pin down current behavior so a faster rewrite can be validated against it. """ import jax import jax.numpy as jnp import numpy as np import pytest from folx.api import ( JAC_DIM, FunctionFlags, FwdJacobian, FwdLaplArgs, FwdLaplArray, ) from folx.hessian import f...
6fabd8f07fa3b98f55ec98ef816e782d47b73e9cb2395df86abb1cb1ddbe83e4
Python
8,700
227
# /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 scipy.io as sio 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...
1336532453316465fdc0f165b8e2be2fde3cc9c5d30291b1d488d1e3b37372e5
Python
8,702
226
# /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 scipy.io as sio 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...
631b22deae0107f2e5957e154a73db88fbe009fd9fbb853a31b0b2c930c9344e
Python
8,703
207
""" config.py — Configuration for the cross-session pipeline. All runtime settings are loaded from default.yaml (or a user-supplied YAML). The Config dataclass defaults below are fallbacks only — edit default.yaml to change behaviour. Quick reference (see default.yaml for full documentation): Datasets: bnci004 ...
20b058b95c561beb08dd29fb580b351ac13e624ddaa3e04c1b77367d43edd090
Python
8,706
184
from md.Simulator import Simulator import openmm as mm from openmm import unit as u from openff.toolkit import Molecule import argparse import os def submit_ligand(name, c1_idx, checkpoint_folder, output_folder, time, cpu, memory, idx, steps, force_constant, xi_0, start, number, ligand, seed): simulation_folder = ...
f86345bc7cf3fbd609c74130ddeeeebe4d499d7da06749f3752da87e0344b135
Python
8,706
222
"""Joint Embedding VAE module.""" from __future__ import annotations from typing import TYPE_CHECKING import torch from scvi import REGISTRY_KEYS from scvi.external.joint_embedding_scvi._utils import ( binomial_split, cross_correlation_loss, sample_thinning_probs, variance_loss, ) from scvi.module._...
4bbe7f62fa5a2ccabb50a75fff34b099184e4e6fdb1e5c7719eb9fb50d126d24
Python
8,707
283
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch import jax import jax.numpy from graph_tool.all import Graph from graph_tool.topology import max_cardinality_matching from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, group, ...
7bea7370aa59cdd297bb5e91db82193567484b5b102c4bcefbef85280ad2d696
Python
8,707
222
""" Extract HIPPIE latent embeddings for one or more datasets. This example uses the public ``hippie.inference`` API. By default it pulls the pretrained checkpoint from the HuggingFace Hub (``Jesusgf23/hippie``); pass ``--checkpoint`` to use a local ``.ckpt`` file instead. Datasets must follow the canonical HIPPIE CS...
eabb9dc1de1e4b9cb1292a251f43e0045763e2bdeccfc412a10a7e737f4a7c4b
Python
8,709
313
#Illustration of the spatial-jitter simulation pipeline #%% # Imports import os.path as op import numpy as np import pyvista as pv import mne from pyvistaqt import BackgroundPlotter from bfieldtools import sphtools as sph import functions import trimesh import pkg_resources import matplotlib.pyplot as plt #%% fon...
3d2994207a5ed0379e58ada41281cad395862695f08f09f6568c91a836f13b6d
Python
8,711
194
"""Real Qt items/events and actual mask autosave, without SAM2 inference.""" import os from pathlib import Path import sys import tempfile import unittest os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") os.environ.setdefault("SEGREF3D_DISABLE_SAM2", "1") sys.path.insert(0, str(Path(__file__).resolve().parents[1]...
7eb9d53591d7cb5d868b6c76ecec279783d74e7efea2df0532eec0f28c927d5e
Python
8,711
291
#!/opt/anaconda3/bin/python3 import streamlit as st import glob import os import read_lif import numpy as np import cv2 import matplotlib.pyplot as plt import math import plotly.graph_objects as go import SessionState from plotly.offline import plot from skimage.measure import label, regionprops from skimage import da...
124192839069cbf972d51eb5adb74e2d795a737cb572726de3c464baa25a3b86
Python
8,713
283
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch import jax import jax.numpy as jnp from graph_tool.all import Graph from graph_tool.topology import max_cardinality_matching from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, g...
18eaf965e8a57cfd6f3793fe7d67a990088288b4b434f94c8b4c1d28005c2d36
Python
8,715
227
# /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 scipy.io as sio 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...
f0c7066c3e93ed786a081c10537d34d4f887ceacc83de19e0f70ef9be6ddee11
Python
8,715
205
import os import gzip import pandas as pd import numpy as np import GEOparse import json import mygene dest_dir = "__MS_GEO_ROOT__/Expression_Data" def fast_parse_metadata(soft_path): # Instead of reading the entire multi-GB array table, we just parse the soft file headers to get MS vs HC metadata metadata = ...
203ded2bda25edf64162019f862d8904970cfa4fb4b581442ef5cfd12baabdd4
Python
8,718
245
from __future__ import annotations import pytest import torch from torch import nn import scvi.nn._base_components as base_components_module from scvi.nn import FCLayers # --------------------------------------------------------------------------- # Basic forward behaviour # -----------------------------------------...
590898cb247223a92acdbdd0e48fb4a7cccc3afed1e64e23b57f15d7678cd94e
Python
8,718
240
import logging import pandas from patsy import dmatrices import numpy from numpy import dot as _dot, diag as _diag import statsmodels.api as sm from .. import Exceptions from ..misc import Math class Context(object): def __init__(self): raise Exceptions.ReportableException("Tried to instantiate abstract Multi Ti...
05fb2f0bfb0ab1136f0c66a7e6905507b9c470e7f78d295a7fb4c80f8f9a50fe
Python
8,719
237
"""Fit OCE on perovskite or MOF feature matrices and report headline metrics. Reads: data/<subset>/features.npz — X (n,p), names, sizes, families data/<subset>/feature_index.json — column metadata data/<subset>/structures.json — energy_total_eV (when present) Splits parent-stratified by `family` (to...
2d3b64a2dea0d7f63ea0ec1f0eb2dc6c5d80f8e43da95bd2750da682e1020b79
Python
8,721
226
# 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 functools import lru_cache import numpy as np import torch from fairseq.data import Dictionary, data_utils from . import BaseWrapperDat...
e98e2ae1e90bd80d58235681ca2937bfced5117eb75ce92639ceab64d02808dd
Python
8,723
241
# 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 scipy.spatial.distance impo...
91867ac47a0ce36912d430539844d877964017b6b6ae2b79baf187b57d080b0e
Python
8,726
251
import os import copy import numpy as np from PIL import Image import matplotlib.cm as mpl_color_map import torch from torch.autograd import Variable from utils.datasets import * def convert_to_grayscale(im_as_arr): """ Converts 3d image to grayscale Args: im_as_arr (numpy arr): ...
f0ba17d37069a4ebd73baf69c4c65edc42990fe4cd82613b7198655780f79562
Python
8,726
256
# # Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC # (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government # retains certain rights in this software. # # See LICENSE for full license details # from __future__ import annotations from dataclasses import dataclass, ...
fba32a0a7204da2cdce35c7b3b3b4e46dea0b8c5704653a7fa3d65a16bbcf090
Python
8,728
262
""" Various utilities for neural networks. """ from enum import Enum import math from typing import Optional import torch as th import torch.nn as nn import torch.utils.checkpoint import torch.nn.functional as F from einops import rearrange, repeat def equinorm(channels, ksize=5, pad=2): """ Make a standard...
32862e565f4f462b800fb43a3d1e939f57c0103b070e9a0161dadd9e174f4d87
Python
8,729
226
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import numpy as np import time import torch import os import CBIG_pMFM_basic_functions as fc def get_init(gradient_pc1, gradient_pc2, highest_order, init_para): ''' Thi...
e73e1850577c3e000424228de86c8ab7ce614c8e0223e067b2ff886fdb488f3e
Python
8,737
182
"""R1-C6: stability of the KAN explanation across random seeds, CV folds and preprocessing choices. Uses the PAPER's pipeline: paper2/loaders.py, the published group hold-out (seed 42, 30%), the per-food preprocessing, and the compact 8-component equation front-end (interpret_food.EQUATION_NC). Preprocessing and PLS a...
1981aa8ec03024f0b59f249fe366118472e5ae153544fe77d8a76266c8099837
Python
8,738
315
import argparse from pathlib import Path from scgpt.tokenizer import GeneVocab, random_mask_value import sys from datasets import Dataset, load_dataset import os sys.path.insert(0, "../") parser = argparse.ArgumentParser() parser.add_argument( "-d", "--data-source", type=str, required=True, help='...
e64830d7e14adc6db9b02b19e7cb6373e7dfc13e82060d847b6aba2b49c2288c
Python
8,738
219
"""GUI tests for the Training dialog (window_utils.open_training_window). Tests verify the dialog opens correctly with both panels (Segmentation and Classification), dataset creation widgets, training parameter entries, and action buttons. """ import pytest from PyQt6.QtWidgets import ( QDialog, QRadioButton, QLin...
02c16733a29569e9e2348f46e630af20154000e35b7b272933e0cbf5e1c0e0b1
Python
8,742
184
# coding=utf-8 import os import sys sys.path.append("..") sys.path.append("../utils") import numpy as np import cv2 import random import torch from torch.utils.data import Dataset import config.cfg_lodet as cfg import dataloadR.augmentations as DataAug import utils.utils_basic as tools from PIL import Image import mat...
cbe0058ae9cd2c737d628105a34a9418c7104aa4d4855129c51e45e871c262ec
Python
8,742
268
"""Which compression actually suits the precomputed-embeddings store. When this was written, `tensor_to_bytes` used fp16 + BITSHUFFLE + ZSTD clevel 9 and achieved 1.145x, which is close to not compressing at all for a second of CPU per document; the `CURRENT` row still measures that scheme. This sweeps the alternative...
dd5922ae1c88d60e8f9948342b8096fb71a7482f0107c90075b4d8a56a28b22f
Python
8,743
210
#!/usr/bin/env python3 """ @file test_baseline.py @author Simon Yu @date 12/02/2024 @brief Script for testing baseline models. """ import argparse import dataset import header import logger import model import sklearn.metrics import torch import tqdm import type import utility import wandb def getBinaryLabelsAt...
506ec94547c8a12299722ddb35c6f6adc90580b8f2cab508f0f94add33c9cca7
Python
8,744
173
#!/usr/bin/env python3 """O canal de hibridação corrige o viés dos iodetos? Protocolo do artigo: alvo `gap_reg` (gapadas sem misto_F), features / n_atomos, CV agrupada por familia A/B, base wave15 como referencia. TRES TESTES, em ordem: 1. NOS IODETOS (n~205) -- o regime onde o vies mora e onde o canal deve agir. ...
a81d5ffa4701866f3c6b3ab8588438d7f6e9f6c99176fe50011744c95878cfd1
Python
8,750
270
""" Copyright 2020 The Google Research Authors. Copyright (c) Microsoft Corporation. Licensed under the MIT License. Based on code from https://github.com/yang-song/score_sde_pytorch which is released under Apache licence. Abstract SDE classes, Reverse SDE, and VE/VP SDEs. Key changes: - Adapted to work on batched p...
4726d0385905aa1cafd6fb5aeeed1ad77b8d98587054b252c96237c1dc7e6850
Python
8,754
250
## To train model, run below. import os import torch import random import numpy as np import time from colab.utils import random_transform, gen_train_dataloader, DatasetSUPPORT_test_stitch from colab.model import SUPPORT from tqdm import tqdm def train_SUPPORT(img, model_size=4, n_epochs=20): random.seed(0) t...
ac133b20eca13cdb56550cba2d7c20da60d3b8636886e745fbd044cf123e789d
Python
8,758
222
import importlib.util from pathlib import Path import numpy as np import pandas as pd SCRIPT = Path(__file__).with_name("parameter_sensitivity_analysis.py") def load_module(): spec = importlib.util.spec_from_file_location("parameter_sensitivity_analysis", SCRIPT) module = importlib.util.module_from_spec(sp...
cedb723ce29d81ab48d50ed54fe16373e73872666e922ebe9ef7fa9819fbdb05
Python
8,758
197
# -*- coding: utf-8 -*- from dipy.data import get_sphere from dipy.reconst.shm import sh_to_sf_matrix import numpy as np from numba import njit from scilpy.gpuparallel.opencl_utils import CLManager, CLKernel from itertools import product as iterprod import logging class AsymmetricFilter(): def __init__(self, sh_o...
d5bb5b26193b5215151474acd1ffb8d1b1e564ccd1415d8ccde94fc018401a03
Python
8,759
231
"""tests for vak.prep.spectrogram_dataset module""" import pathlib import pandas as pd import pytest import vak.common.annotation import vak.common.constants import vak.prep.spectrogram_dataset.prep import vak.prep.spectrogram_dataset.spect_helper from ...fixtures.annot import ANNOT_FILE_YARDEN from ...fixtures.audi...
2e1e446ae50815d4f4fa0b4a032ddfce37e06b95c76a05286e9e8afc2bb0d4da
Python
8,763
211
#!/usr/bin/env python3 """Compare paired gmx_MMPBSA API results from two external result trees. The comparison is deliberately independent of CSV formatting. It loads each paired ``_GMXMMPBSA_info`` or ``COMPACT_MMXSA_RESULTS.mmxsa`` file through the current public API and compares numeric cells in raw data, summarie...
253b0d8f4de4ba456d83469566367980274ae12782616713ff2def8c40f07922
Python
8,765
271
import numpy as np import tensorflow as tf import scipy.linalg as splin from . import utils def _soft_rectified_tanh(x, gamma=10.0): return (1 / gamma) * tf.math.log(1 + tf.math.exp(gamma * tf.keras.activations.tanh(x))) cos = tf.losses.CosineSimilarity() mse = tf.losses.MeanSquaredError() def SAD(y_true, y_...
939ab437863b1ff0ba2bae2ca1b4c1ae5ee4e10b45d1238cf60a7fc27807a1c9
Python
8,772
268
######################### # In this script we train PVGG on ImageNet # We use the pretrained model and only train feedback connections. ######################### # %% import torch import torchvision import torchvision.models as models import torchvision.transforms as transforms import wandb from torch.utils.data impor...
004b6c2dfc2aabbc988bf4bd01a43859b6dbcdae2d022328f170b11a8840f76b
Python
8,774
275
# 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 unittest from copy import deepcopy from dataclasses import dataclass import pytest from typing import Optional from unittest.mock impor...
ad1bf80fff990c6e482bd3ec779a41daf3a8e74cf4f2d51249f37e82de81684e
Python
8,776
286
"""`batch_progress`: a bar for loaders that cannot report a batch count.""" import logging from typing import Any import pytest import torch from d3text import progress from d3text.data.data import get_batch_loader class FakeBar: """Records what a bar was told, instead of drawing one.""" instances: list["F...
abc979810d7607cfb704a25e89e84fc6bdf72401d5aa4d8fff686c707a8f6650
Python
8,777
226
# /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 scipy.io as sio 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...
18b3522e197d72dc9ca037d4babb0d208e5b9be7a483624a44064d3aca9d289a
Python
8,778
227
# /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 scipy.io as sio 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...
5a6d8a153f657118856a8210b814f0d13f2ddf4ae0b29af5d97f608727c85a17
Python
8,786
267
from __future__ import annotations import subprocess from typing import TYPE_CHECKING import pytest from poetry.utils._compat import WINDOWS if TYPE_CHECKING: from cleo.testers.application_tester import ApplicationTester from cleo.testers.command_tester import CommandTester from pytest_mock import Moc...
3a42ebf03542278cdd0d393e0cb86a1e8ce604ad57cd14d95d0f8eed92873e54
Python
8,789
268
# 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 functools import operator import torch import torch.nn.functional as F from fairseq.modules.fairseq_dropout import FairseqDropout from...
a57e5e57c9b2fbb5338354379656d0ae3f2a81d96164b537b5a7293a49c1dc40
Python
8,789
227
# /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 scipy.io as sio 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...
135b602477b3c61ee877a55d76d029b3e656e94f0ecaa810bf6eafe607969f0b
Python
8,791
226
# /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 scipy.io as sio 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...
aadac3ca6e1ad3b7a1e10dc56b9d936fb714f8243f1e57ce98f87cd994e25ee6
Python
8,794
228
# /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 scipy.io as sio 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...
9949e563ffc5940988a320809a4c40ee7e352011beed410dd279eb3285483472
Python
8,795
169
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'ScheduleUI/beastScheduleUI.ui' # # Created by: PyQt5 UI code generator 5.9.2 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtWidgets class Ui_Form(object): def setupUi(self, Form: QtWidgets.QWidget...
2a21519eaa796c24e097874a06740ede5a6991fe490ad0e9e36a56e062a5c961
Python
8,798
198
import unittest import sys import os import shutil import re if "DEBUG" in sys.argv: sys.path.insert(0, "..") sys.path.insert(0, "../../") sys.path.insert(0, ".") sys.argv.remove("DEBUG") from metax.Person import Person class TestPerson(unittest.TestCase): def testPersonConstructor(self): ...
1f169f7a30d66f306659fdeeab0852718ff6e8cf0dad25fd9817e78621e86777
Python
8,799
263
"""Reading a tagger's own spans out of an encodings-store group: the join that feeds the linker a checkpoint's own detections rather than gold mentions, from a corpus-prefixed group's windowed token ids to `TaggedSpan`s grounded in that document's own text.""" import contextlib import pathlib import h5py import numpy...
0cc26631e9d22d727bbab662249adda84dbf4ad681b4c004b29cc34ff59a9b4f
Python
8,807
287
# 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 mmap import os import shutil import struct import typing as tp from functools import lru_cache import numpy as np import torch from fa...
bb4acf275ea073c9a6325ae4c02483d6ce698e9e4b44cc2241a8b0ea105e79a2
Python
8,810
232
#!/usr/bin/env python # ENCODE DCC adapter trimmer wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse import copy from detect_adapter import detect_most_likely_adapter from encode_lib_common import ( copy_f_to_dir, copy_f_to_f, log, ls_l, mkdir_p, read_tsv, rm_f, run_shell_cmd,...
99483d4a8f466a32a8ca517b6fac124545737e726bf8bb663775d52975bfac5c
Python
8,812
234
# /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_main as fc import warnings def get_init(myelin_data, gradient_data, highest_order, init_p...
adecf64c6bab65b31740c321e568cf174f753d5617745aa5762d842339d68b53
Python
8,813
250
#!/usr/bin/env python # # Copyright 2009, Google Inc. # 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 # notice, this list...
6c257bc4d5768d9e9b3fe2fea7c481ea914bee1eded4e81d34925f3fbcc7e10d
Python
8,815
223
"""Phase 9 — off-criticality p sweep. Vary site-occupation probability p around p_c on the honeycomb lattice (C-AIREBO) to test whether: (a) D_f → 91/48 ≈ 1.896 is unique to p = p_c (we expect yes) (b) γ ≈ 0 holds at all p where the largest cluster grows with L (we expect yes — it is a "compact dens...
1ecf4a58e153da67ddc67ba264232642f74f991021323131dc5ff91e4711e1d0
Python
8,822
200
import numpy as np import torch from torch.utils.data import DataLoader import time from pathlib import Path from input_data_from_mesh import prep_input_data from fit import fit, fit_with_early_stopping from optim import * from plotting import plot_field def train(field_comp, disp, pffmodel, matprop, crack_dict, numr...
5f5a82199bdb134e1cd16f89fd5031a0aa77241a957b929b0f271005d4ae4fc0
Python
8,825
242
# 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 functools from typing import Any, Dict, List, Tuple, Union import torch import torch.utils.checkpoint as checkpoint from fairseq impor...
b1dad386cac52f4730b9d592f0e8e3d188d265ea3a07b4e4b29004d44174155b
Python
8,828
228
from __future__ import annotations import argparse import csv import json import math from pathlib import Path ROOT = Path(__file__).resolve().parents[1] MAIN_ROOT = ROOT / "results" / "revision_known_composition_benchmark" REPEAT_ROOT = ROOT / "results" / "revision_known_composition_seed_repeats" MANUSCRIPT_TABLE_D...
c5a56d9fab089b74c694cfa2812429f461d75b678e6ddad04d45125ad96eef1d
Python
8,832
253
# 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 numpy as np import torch from . import FairseqDataset, data_utils def collate(samples, pad_idx, eos_idx, fixed_pad_length=None, pad_...
a63fdf3ef5322ed062f94bd958092b4bbfad7a19ad699e1c879dc27bac6fabf8
Python
8,834
242
# 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 random import json import pickle from tqdm import tqdm import os import numpy as np class CaptionDedupProcessor(object): """remov...
2a545f178638c7b4a73e7018abf816fcc9859b82a54e46dd81e5df15bcfb4694
Python
8,836
223
#!/usr/bin/env python3 """G2-cross-species — macaque → mouse counterfactual cell-type profiles. For each overlapping cell type between a source (macaque, Lisberger src=3) and a reference (mouse, Hausser src=1) dataset: 1. Encode all macaque cells of that type using their true source conditioning (source_id = s...
240114a6d6c912e01b45756719a3718245dd95e867e376164a30a7c80d688c16
Python
8,837
253
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import pytest import torch from torch_scatter import scatter_add from mattergen.common.data.chemgraph import ChemGraph from mattergen.common.data.collate import collate from mattergen.common.data.transform import set_chemical_system_string from ...
745bc82075f7d28d7b3c7b3df461b44330c66393159fa1a58d677ec3bf569f8c
Python
8,837
211
from __future__ import annotations from typing import TYPE_CHECKING import torch from torch import nn from torch.distributions import Bernoulli, Normal from scvi import REGISTRY_KEYS from scvi.external.vivs._constants import VIVS_REGISTRY_KEYS from scvi.module import VAE from scvi.module.base import BaseModuleClass,...
e2246533dee6508eee8e7529f8fd9ea362844ecd76445d3a227bbc7cd6654dbd
Python
8,838
281
from __future__ import annotations import json import re from pathlib import Path from typing import TYPE_CHECKING from typing import Any from urllib.parse import urlparse import pytest import responses from packaging.utils import canonicalize_name from poetry.repositories.legacy_repository import LegacyRepository...
f3767e70c753786e94a4d7d1d5fc3dfb0114da5051fc186cf5dec5d979b2de84
Python
8,840
263
#!/usr/bin/env python3 """ Profile external models (params/FLOPs/peak memory) with dummy inputs. Examples: # MONAI UNETR (if monai is installed) python profile_external_models.py \ --model monai.networks.nets.UNETR \ --model-kwargs '{"in_channels":1,"out_channels":3,"img_size":[96,96,96],"feature_size":16}...
82a1a58c379682b41962792cff9910b736418c432424008bbbec019e51431f8d
Python
8,842
211
import numpy as np import numpy.polynomial.polynomial as poly import matplotlib.pyplot as plt import sys def LyE_R(X,Fs,tau,dim,*args): """ inputs - X, If this is a single dimentional array the code will use tau and dim to perform a phase space reconstruction. If this is ...
82a31ba2809915301d89b991070652b70640f34c9dbd99c9d9a1426dd4534f99
Python
8,849
234
# /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):...
1d101d63efce7fbbbfc643a3865ad24fe3fa6e4c48eeec1d6b627f38edad7cda
Python
8,855
286
import os from copy import copy import itertools import pandas as pd import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data as data import torch.distributions as dist import torch.optim as optim import torch.utils.data from tqdm.auto import tqdm from torchvision i...
e26a93ce59a9e409788afb0f01c4dfa6f2bec16d9c5cc26b0e6a5cb7a1793478
Python
8,857
235
# 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 numpy as np import torch import torch.nn as nn import torch.nn.functional as F from fairseq import utils from fairseq.data import encod...
5c955c96b2bdab816dbb107d4a7cbd6b6419629c89ea0ed01301ec2525855af9
Python
8,860
268
######################### # In this script we train PVGG on ImageNet # We use the pretrained model and only train feedback connections. ######################### # %% import torch import torchvision import torchvision.models as models import torchvision.transforms as transforms import wandb from torch.utils.data impor...
8fecd815bb579644f645f4027d4b41e86fbcac6d075dba333670d75c30d6ac25
Python
8,860
246
from __future__ import annotations import inspect import logging import os import warnings from typing import TYPE_CHECKING import anndata import mudata import numpy as np import pandas as pd import torch from anndata import AnnData, read_h5ad from scvi import settings from scvi.data._constants import _SETUP_METHOD_...
79efa5308fa60cca390f3448f680d89cb6e4e32436a36b4886b02fbb70bbf806
Python
8,861
344
project = "Neuroglancer" copyright = "2021 The Neuroglancer Authors" version = "" release = "" import typing from typing import NamedTuple, Optional import os import re import sys import docutils.nodes import sphinx.application import sphinx.addnodes import sphinx.domains.python import sphinx.environment os.environ...
e7013cd5c2e809ba567414ef4e37d494a855dda46d07ac9f2a8b7ecf3918419b
Python
8,861
241
import tqdm import gensim import numpy as np import pandas as pd from scipy.spatial.distance import cosine from gensim.models.doc2vec import Doc2Vec, TaggedDocument from typing import Union, List import logging # Retrieves cleaned data from RELISH and TREC npy files def process_data_from_npy(file_path_in: st...
b93ba217023f1a94e4242899d864e4e664fc03f6cac98906cd5ca644b936a121
Python
8,862
288
""" This module contains methods used in analysis windows or in report in Email module. Calculation of d' is left as commentar in weighted_binned_performance method. """ """ Copyright (c) 2019, 2022 [copyright holders here] This file is part of NoSeMaze. NoSeMaze is free software: you can redistribute it and/or mo...
f54f46e198e8ed6632eafcdb5299a4eec25ab12e0f6252d4dd49e14d87d6b7bb
Python
8,865
234
# /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):...
d81758a334911aa9dd3b0bf5e74af45516b1be2dd010164fe47661ddbdfb848c
Python
8,866
222
#!/usr/bin/env python3 """ Author: Ken Chen Email: chenkenbio@gmail.com """ import argparse from tqdm import tqdm import os import sys import pickle import numpy as np import torch from torch import Tensor import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset, Subset fr...
8c0b24277a4d9eaef2176be038af5b082acd071f331922eb075a38fdb3f9c59c
Python
8,868
253
""" Vocabulary backend compatibility module for scGPT. This module prefers torchtext as the GeneVocab base class only when it is actually usable (import succeeds and the Vocab type is subclassable). Otherwise it falls back to a pure-Python implementation. Why fallback is needed: ---------------------- torchtext <=0.1...
a642fb52ac0eb332b9b137f7f64a977ae6db7cab773bf315fea5c567badcc355
Python
8,871
322
import networkx as nx import numpy as np import pandas as pd import pytest from joblib.externals.loky import get_reusable_executor from pgmpy.estimators import TreeSearch from pgmpy.example_models import load_model from pgmpy.factors.discrete import TabularCPD from pgmpy.models import DiscreteBayesianNetwork from pgmp...