sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
8edc9089a1453800a6c8e1cf5f68a61ae1a9ad7f611b6a664cc7c4d3b7159fb8 | Python | 5,320 | 147 | import os
import sys
import json
import numpy as np
import PIL.Image
from io import BytesIO
from PIL import Image
from PIL import Image, ImageDraw, ImageFont
from zipfile import ZipFile
import cv2
import torchvision.transforms.functional as TF
from torchvision import transforms, utils
def load_classes(path):
if p... |
df9230fd7e975ab12089ff08049c55162638ecfe6a2e1d188d34b796fcad719f | Python | 5,320 | 127 | """W051-STOCH / AUD-CODE 2.2: batch ``do()`` draws never depend on clause order.
The batch normalizer used the clause ORDINAL as the disambiguation suffix, so
the second clause's draw changed whenever an equal-content plan preceded it and
batch ``do()`` differed from sequential ``do()``. Suffixes now derive from each
... |
e76c3c32a849c7045d3b70adf3d4b89de51769b24f1d2dd22b233986c0a18c5b | Python | 5,321 | 88 | """General-purpose training script for image-to-image translation.
This script works for various models (with option '--model': e.g., pix2pix, cyclegan, colorization) and
different datasets (with option '--dataset_mode': e.g., aligned, unaligned, single, colorization).
You need to specify the dataset ('--dataroot'), e... |
02095bf25c56a80c95dbb9feefbce409944309d8fd631d5527231ab3cb51e345 | Python | 5,322 | 158 | import os
from argparse import ArgumentParser
from configparser import ConfigParser, MissingSectionHeaderError
from distutils.util import strtobool
def read_from_conf(
conf_file, conf_section='defaults', conf_key_map=None, no_strip_quote=False
):
"""Read key/value from conf_section of conf_file.
Hyphens ... |
1bd953e00fa0357b0e8749ee02b2a33eb6203398567a8c74f26d752c7a994953 | Python | 5,322 | 136 | """
Computes and saves molecular features for a dataset.
"""
import os
import shutil
import sys
from argparse import ArgumentParser, Namespace
from multiprocessing import Pool
from typing import List, Tuple
from tqdm import tqdm
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from Batma... |
754d7bcb06402384a7b2259f25333ce6fef47a30efd8297e5b9bd1b452960646 | Python | 5,322 | 157 | ## GoPro Instant Streaming v1.0_r1
##
## By @Sonof8Bits and @KonradIT
##
## WOL touch by @5perseo, code updated by @podfish
##
## 1. Connect your desktop or laptop to your GoPro via WIFI.
## 2. Set the parameters below.
## 3. Run this script.
##
## Supported cameras:
## GoPro HERO7 Black, HERO5 (incl. Session), HERO4 (... |
8594233dcca293940af02fc5576627f7148bb2a25fe60232a98469f24499c499 | Python | 5,322 | 147 | """Periodic gauge emitter for control-queue depth and worker-process counts.
Scheduled by Celery beat (see ``galaxy.celery.__init__.setup_periodic_tasks``)
at a fixed cadence. Opens a short-lived kombu connection, iterates the control
queues returned by ``all_control_queues_for_declare`` and samples each queue's
messa... |
277c87ca6ca0f75856e22230e86636218dbcc6ce56470882e36e18a13df86bc6 | Python | 5,323 | 160 | """Modified NMS ops as static/dynamic layers"""
import numpy as np
import torch
from torchvision.ops import boxes as box_ops
from torchvision.ops import nms # BC-compat
__all__ = ['batched_nms', 'ml_nms']
def batched_nms(boxes: torch.Tensor, scores: torch.Tensor, idxs: torch.Tensor, iou_threshold: float):
"""
... |
49941a573e18ceb65df80fd1db2d9eb8812b6f56aa0b1438a4e02995d8a3e132 | Python | 5,323 | 141 | import abc
import functools
import logging
import os
from typing import (
ClassVar,
)
import fs
import fs.errors
from fs.base import FS
from galaxy.exceptions import (
AuthenticationRequired,
MessageException,
)
from galaxy.files.models import (
AnyRemoteEntry,
FilesSourceRuntimeContext,
Remot... |
c8f6d605b524d30098e4a55e3904de191305b2d1e26e2ff2940fa6ecaf1c9cc0 | Python | 5,323 | 109 | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ------------------------------------------------------------------------------
import torch
import torch.nn as nn
import torch.nn.functional a... |
1dee8a20849e0b1f797a19b786e4a632384dc6ee4ccffd1bd03f9490a9a6dd04 | Python | 5,324 | 175 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
"""Generate negative background sequences by sampling from peak-containing transcripts outside of peak regions."""
# In[ ]:
import sys
import copy
# In[ ]:
import argparse
import subprocess
import tempfile
from pathlib import Path
# In[ ]:
import numpy as np... |
1f02a4baa4a1ec6fc07655ba58d3a17f6272f12d116d985799ef866978148f79 | Python | 5,324 | 143 | import pytest
import zarr
from numpy import zeros
from ome_zarr.data import create_zarr
from ome_zarr.format import FormatV04
from ome_zarr.io import parse_url
from ome_zarr.reader import Label, Labels, Multiscales, Node, Plate, Well
from ome_zarr.writer import write_image, write_plate_metadata, write_well_metadata
... |
d1734983ba718e1b6201888f48796cddbacee680c0cfb0534e83faa68dcf5c6a | Python | 5,324 | 118 | """03. Train classifier or detector with HPO using GluonCV Auto task
====================================================================
The previous image classification example shows the basic usages to train/evaluate/predict
using estimators provided by `gluoncv.auto.estimators`. Similarly, you can train object de... |
14e57323587f3f3af363f89054bd77db8af59b0ab7fb63258ab1e97eb71edccd | Python | 5,325 | 144 | from pytorch_lightning.utilities import cli as CLI
import pytorch_lightning as pl
from lib.models import BoneAgeModel
from lib.utils import visualize
from lib.utils.log import log_system_info
from pytorch_lightning.callbacks import (
EarlyStopping,
LearningRateMonitor,
GPUStatsMonitor,
)
import logging
from... |
9fcba3d90b0f902668fec6f37f23644ba323a328e9c3ed5fd15a6d60bf9b56e0 | Python | 5,325 | 186 | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 30 13:44:06 2022
@author: longzheng
"""
import sys
from keras.datasets import fashion_mnist
from keras.models import Sequential, load_model
from keras.layers import Conv2D, MaxPooling2D, Dropout, Dense, Flatten
from keras.utils import np_utils
from keras.optimizers impo... |
31d9b41d7872067912cfa0b19eaa572a65a5f043ebddeca774402e31342c6466 | Python | 5,326 | 142 | #!/usr/bin/python
#-*-coding:utf-8-*-
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance wi... |
5c89cd291343af6955dd35d39182c5686b5a68fdcab5ca5dc5d6f5ebd7caae2e | Python | 5,326 | 119 | from collections import OrderedDict
import numpy as np
import torch
from torchmetrics.functional import dice
from tqdm import tqdm
from utils.network_utils import AverageMeter
def calc_dice_metrics_heart(individual_labels,
std_individual_labels,
b_loss,
... |
c3f3f3cf7413fd56d44c8c3ba93676549e2bf2c5f41b371c85ba70b1a7dbb563 | Python | 5,326 | 163 | # SOURCE: vendored from juexinwang/scGNN @ 09ac50ba0a2bbf87535613a2d284872074804d02
# https://github.com/juexinwang/scGNN/blob/master/gae/model.py
# https://github.com/juexinwang/scGNN/blob/master/gae/layers.py
#
# scGNN (Wang et al. 2021, "scGNN is a novel graph neural network framework
# for single-cell RNA-Seq analy... |
f567764c1a4b21e255235cacb0f184eab0909e778a216e7b1ad9e5f73c00c124 | Python | 5,327 | 125 | """
style plugin - change the visual properties of the trace plot
UI loading and handling. Must be loaded from the base UI system.
SimplyFire - Customizable analysis of electrophysiology data
Copyright (C) 2022 Megumi Mori
This program comes with ABSOLUTELY NO WARRANTY
This program is free software: you can redistrib... |
4e93a8b18b0b6c11eb1742c569d8c51cdc66037ca1f5ead36a0832ee670257c3 | Python | 5,328 | 139 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: malfatti
@date: 2019-07-27
Loads data recorded by Open Ephys in Binary format as numpy memmap.
DatLoad(Folder, Processor=None, Experiment=None, Recording=None, Unit='uV', ChannelMap=[])
Parameters
Folder: str
Folder containing at least the subf... |
146b76a071393fd0a784d86643f5c7fbad4d7004fe14814ab3efdc8bb41c07b1 | Python | 5,329 | 93 | import os
import h5py
import numpy
# from read_projection_volumes import read_volume, read_coordinates # part of this repo
from .embed import compute_diffusion_map # part of this repo. originally: https://github.com/satra/mapalign
def coordinate_overlap_bitmask(coords_view1, coords_view2):
is_valid_view1 = numpy... |
f15588496b5280ad5a9db5f40010ce84999fe8585756adbd2837a74748ce4591 | Python | 5,331 | 140 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
import matplotlib.gridspec as gridspec
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
import os
SMALL_SIZE = 13
MEDIUM_SIZE = 14
BIGGER_SIZE = 14
plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes
plt.rc... |
6656d33d4ef216e21a4958e04f44d23a22f2d5f30b7da4c4a30d89102fbb6010 | Python | 5,333 | 144 | # LICENSE
#
# _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._
#
# BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License");
#
# - you may not use this software except in compl... |
a903017834319224eb2aa5d881ce2fd46a8ffa8b79d26ad3b6095c886799a3aa | Python | 5,333 | 135 | """tl.debug grad_fn walker (lane F37; approved diagnostic, R grad_fn ruling).
Structure-only post-hoc sketching of a tensor's autograd graph: a REAL loss
tensor from a real architecture class walks completely with named parameter
leaves; renders always carry the structure-only legend; graphless tensors
refuse typed wi... |
abe13dcf397a0cd278220fd504b492476e679a0a0a53640f1687ab7318019ce0 | Python | 5,333 | 171 | #!/usr/bin/env python
import sys
# from rpy import *
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
r = robjects.r
grdevices = importr("grDevices")
def stop_err(msg):
sys.stderr.write(msg)
sys.exit()
infile = sys.argv[1]
x_cols = sys.argv[2].split(",")
method = sys.argv[3]
ou... |
278f0838a18653bd4d6b4385821b0826f86fa31bb19194656b9f3bfef988d157 | Python | 5,334 | 128 | import h5py
import torch
import glob
from . import audio_transforms
import pickle
import numpy as np
class jsinV3_precombined_all_signals(torch.utils.data.ConcatDataset):
# Makes a dataset using pre-paired speech and audioset background sounds
# Works with hdf5 files for the jsinv3 dataset. As the authors for ... |
ca01bd86fee9a94735f8f3b1b1165937f179c8ffff976a7533d346d4cc8413c1 | Python | 5,335 | 157 | # Copyright 2025 Google.
#
# 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, soft... |
0686fe97ef3a12dd6b7261c6b7ffdabf69020ef5b8f422c3dca7d942d371c1a4 | Python | 5,336 | 114 | """
Ensures that only one instance of codecarbon is running at a time.
It creates a lock file in /tmp/.codecarbon.lock and removes it on exit.
If the lock file already exists, it exits the program.
"""
import atexit
import errno
import os
import signal
import tempfile
import threading
from codecarbon.external.logger ... |
16646614560dfa4b15ce24b7c77851a1012aacc05a6a2dd09606daa5ec01ea6d | Python | 5,336 | 151 | from functools import partial
from typing import Any, Callable, Optional, cast
import torch
import torch.nn as nn
from timm.models.vision_transformer import Block
from torch import Tensor
from torch.nn import LayerNorm, Parameter, Sequential
from lightly.models import utils
from lightly.models.modules.masked_vision_t... |
b8f25ab542896b5c57008ea7c673e32e399be6efc8768082b9ed78b1a430f63e | Python | 5,336 | 170 | """Optimizers and related classes for use with TensorGraph."""
import tensorflow as tf
class Optimizer(object):
"""An algorithm for optimizing a TensorGraph based model.
This is an abstract class. Subclasses represent specific optimization algorithms.
"""
def _create_optimizer(self, global_step):
"""C... |
a2c75b53cca8152f4d89881384660a461c648dc6b2082cfb1638f5dc2ad7d3f3 | Python | 5,337 | 163 | """
CREaTor
Copyright (C) 2023 Microsoft Research
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed... |
0ffd0d5022db3700394ddc32b5f6901a3e8ea7ee0bbc2587aff04777ab723e55 | Python | 5,338 | 109 | #==============================================================================#
# Author: Dominik Müller #
# Copyright: 2024 IT-Infrastructure for Translational Medical Research, #
# University of Augsburg ... |
32e744cb7436574f434f4cd03de5a8cbf509bf06e1c34445268a50377a4d7a10 | Python | 5,338 | 167 | import itertools
from functools import lru_cache
from permacache import permacache, drop_if_equal, stable_hash
import numpy as np
import tqdm.auto as tqdm
from modular_splicing.evaluation.predict_splicing import predict_splicepoints
from modular_splicing.legacy.hash_model import hash_model
from modular_splicing.data... |
6fc3d9c9fb929e4e695420499ffe4ce1f6e00d8a7deef622d40ae9cba5799d46 | Python | 5,338 | 149 | """GPU/MPS gate for the transforms library (memo B12/10.3; C-XFORM row).
GPU and MPS behavior is UNMEASURED by the design panel (no CUDA/MPS on the
authoring box) and the memo publishes NO on-device number; these tests ARE
the required gate that must run green (on the cluster, D02's C-XFORM row)
before any on-device c... |
b25c42ab34c5b812471c09df9d4e890e568cc23a6847788a7409a7f64a844a35 | Python | 5,338 | 186 | import argparse
import numpy as np
from galaxy_ml.utils import read_columns
from sklearn.decomposition import IncrementalPCA, KernelPCA, PCA
def main():
parser = argparse.ArgumentParser(description="RDKit screen")
parser.add_argument("-i", "--infile", help="Input file")
parser.add_argument(
"--he... |
daf6760e73a82ca15e682946efd615fd0a21d6febd1b1735d20037e69f0b0c3a | Python | 5,339 | 142 | """Behavioral tests for report profiling, honesty labels, and capture-time logging."""
from __future__ import annotations
from collections.abc import Iterator
import pytest
import torch
from torch import nn
pd = pytest.importorskip("pandas")
import torchlens as tl # noqa: E402
from torchlens.report import build_p... |
9396157c07ace49183c3a235eb6ea89c17ed3c9a179d11da1019e3ac8662ab4c | Python | 5,340 | 131 | """
Copyright (C) 2018 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
from __future__ import print_function
from utils import get_config, pytorch03_to_pytorch04
from trainer import MUNIT_Trainer, UNIT_Trainer
import... |
8deba8285c03aee713ba4350c377c733eaa728ad78b2339bb3d0e57afa351ca8 | Python | 5,341 | 119 | import torch
import torch.nn as nn
import numpy as np
import math
def make_model(args, parent=False):
return LapSRN(args)
def get_upsample_filter(size):
"""Make a 2D bilinear kernel suitable for upsampling"""
factor = (size + 1) // 2
if size % 2 == 1:
center = factor - 1
else:
cent... |
e28ce9414eee2bc66cf8ba66e6a29f3829ab5f1b120ab7fb6c27f0668c8e53ec | Python | 5,341 | 134 | # CUB Image feature model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt
from torchvision.utils import make_grid, save_image
from src.datasets import CUBImageFt
from src.utils import Constants, NN_looku... |
15148cdc18856af0fa297af9147733fb4b277a4a723bb2d35dad1a6172be813d | Python | 5,342 | 162 | import itertools
from typing import Tuple, Optional, Union
import numpy as np
from .criteria import *
from .utils import *
def pca(
img: np.ndarray, criteria: Union[str, int], mask: Optional[np.ndarray] = None
) -> np.ndarray:
"""
Perform Principal Component Analysis (PCA) for denoising CEST images.
... |
2e34dc5205daa8c2c67fd8815c1a87e2632dc5fc76e33bb47e7e83a2d18a0d7f | Python | 5,342 | 109 | import os
import numpy as np
import matplotlib.pyplot as plt
from irnlm.utils import check_folder
from fmri_encoder.data import fetch_masker
from fmri_encoder.plotting import compute_surf_proj
from irnlm.contrasts import plot_brain_fit
if __name__=='__main__':
###
# Replicating Fig7: Context
###
sav... |
224b9c0a75c9b94af7f639272d2784291d9ecc67da0cd94facd43ed7d8d1bf1e | Python | 5,343 | 145 | import copy
from typing import List, Tuple
import torch
from pytorch_lightning import LightningModule
from torch import Tensor
from torch.nn import Identity
from torch.optim import SGD
from torchvision.models import resnet50
from lightly.loss import NTXentLoss
from lightly.models.modules import MoCoProjectionHead
fro... |
32cc86f94e884a31d461264ad9781e524b73cb551802435d9489960cbf73bf0b | Python | 5,348 | 157 | """This module implements an abstract base class (ABC) 'BaseDataset' for datasets.
It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses.
"""
import random
import numpy as np
import torch.utils.data as data
from PIL import Image
import torchvision.... |
6304bd1a4473e4c21fed2ef813f4c4d82cf6b5287f0d60c05e5bac705aa16936 | Python | 5,349 | 167 | from brian2 import *
from model import get_osn_model, osn_params
from utils import timeit
import numpy as np
import os
def concentration_to_current(max_signal, Amax, hill_coeff=5.5):
"""
convert a concentration value into a current through a hill function
:param max_signal:
:param Amax:
:param hil... |
503eecdb4475dd3d0a1aee77f040501905b85cdf721360d61a7294cd1c1c8e3f | Python | 5,351 | 137 | #!/usr/bin/env python3
# coding: utf-8
"""
Created on September 2018
@author: Nathan de Lara <nathan.delara@polytechnique.org>
@author: Thomas Bonald <bonald@enst.fr>
"""
from typing import Union
import numpy as np
from scipy import sparse
from sknetwork.embedding.base import BaseEmbedding
from sknetwork.linalg impor... |
5ecb2c9665fb92637cf00ccfe4d8211ad131c41ee59df7814520ea9c6790eb08 | Python | 5,351 | 164 | import argparse
import os
import os.path as osp
import torch
import numpy as np
from .broadening import group_broadening
from ..attribution_gnn1.QM9_SpecData import QM9_SpecData
from ..attribution_gnn1.split import save_split
from torch_geometric.loader import DataLoader
from SpectraGNN import SpectraGNN
from .trainer... |
480e2f378ba88ccfe94aa18d685cd43c50255142b64c619c7e457f83763c1571 | Python | 5,352 | 137 | import unittest
import shutil
import os
import subprocess
from Bio import SeqIO
# single, leftright
# fasta, fastq
# one file, two files
# forward, reverse
# clear, gzip, bzip
class TestTrinityPrepFlag(unittest.TestCase):
@classmethod
def setUpClass(cls):
try:
os.remove('coverage.log')
... |
67a2057692fe2244920d826418fcbdc44d84456a37d20ef61b70672e59437b29 | Python | 5,352 | 128 | # ------------------------------------------
# Original code available here:
# https://github.com/kwagstyl/surface_tools
#
# This function was slightly modified to take an additional argument: tmp
# The user must define a temporary directory for processing
# This directory is defined by micapipe.
#
# ---------------... |
bd838053032d8514a8ef9311e33646a755c2ba986245fd23beb6479301fa25ec | Python | 5,352 | 140 | """Foreign-thread pure-READ channel touches must not ceiling a capture (FLAKEHUNT).
The smoke-gate UNVERIFIABLE flake family (r61 expanded-view user-state, T72
genuine-cnn, T74b convbn_train): the clock/entropy module-attr patches are
process-wide, so a benign background thread left running by an EARLIER test (a
track... |
ca044f3c48434e4797a31a49657e0f5bea88d7561312bc7ca7db4c38855cf1fb | Python | 5,352 | 143 | #%%
import torch
import torch.nn as nn
import torch.nn.functional as F
class conv_pass_1(nn.Module):
def __init__(self,in_feature,n_feature_maps=20):
super(conv_pass_1, self).__init__()
self.Conv1D = nn.Conv1d(in_channels=in_feature,out_channels=n_feature_maps,kernel_size=1,stride=1,padding=0)
... |
f825c677733d3bd34b7a9ffff08a1eec4db26f6df55b6bc890c9829fbed44eaf | Python | 5,354 | 146 | from argparse import ArgumentParser
from typing import Any, Dict, List, Tuple, Type
import torch
from pytorch_lightning import LightningModule, Trainer, seed_everything
from torch import Tensor, nn
from torch.nn import functional as F
from torch.optim import Adam
from torch.optim.optimizer import Optimizer
class Lin... |
99391782185956f8ba324502e0d54fff0a0c453c00439ff546fc8e408d6572c5 | Python | 5,356 | 117 | #!/usr/bin/env python
# coding: utf-8
"""
Sensor-level RSA using a searchlight
------------------------------------
This example demonstrates how to perform representational similarity analysis (RSA) on
EEG data, using a searchlight approach.
In the searchlight approach, representational similarity is computed betwe... |
a5dac04be59467038b27327ef12620b7b0ee36c355fda1cd3bc7ff4a0935f8c3 | Python | 5,357 | 192 | """CBAM: Convolutional Block Attention Module.
Paper: CBAM: Convolutional Block Attention Module.
Woo, Park, Lee, and Kweon, ECCV 2018.
CBAM refines an intermediate CNN feature map with two sequential gates:
channel attention from shared-MLP average/max pooled descriptors, then spatial
attention from channelwise aver... |
a0f5e2db335698193a71fa56245d0ecbd22be85a7cb4a8c7cd68e04592caf7c1 | Python | 5,359 | 152 | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# +
from pathlib import ... |
01b1c36edb39846d48b262b41e214e1c433b5a0f38ac8bf1cfcc729b7a2ed2f3 | Python | 5,360 | 170 | import operator as op
import numpy as np
import pylab as pl
from scipy import stats,ndimage,signal
from functools import reduce
bclose, bopen = ndimage.binary_closing, ndimage.binary_opening
#### Raman spectral images are organized such as arr[i,j,:] gives a spectrum at
#### location i,j (i is rows or Y, j is columns... |
41ef3d4aac9e2e84fab9cb2d8c1b393f9d7e195f18421c92edeef157fe707057 | Python | 5,360 | 183 | import itertools
from collections import defaultdict
from types import SimpleNamespace
from matplotlib import pyplot as plt
import tqdm.auto as tqdm
import numpy as np
from modular_splicing.dataset.h5_dataset import H5Dataset
from modular_splicing.evaluation.predict_splicing import predict_splicepoints_cached
from sh... |
05ca2aec17bdd9ebbf92c9768823e3f5442771bfd98a5d709d57bfcd783996b5 | Python | 5,361 | 164 | import dgl.function as fn
import torch
import torch.nn as nn
import torch.nn.functional as F
class DotDecoder(nn.Module):
def __init__(self):
super().__init__()
"""Dotproduct decoder for link prediction
predict link existence (not edge type)
"""
self.act = nn.Sigmoid()
... |
98f3eabb1a56dd9be898741e103e91ab333e65384b25d984c0ea2e718781334c | Python | 5,361 | 132 | """Record-level tabular export conformance tests."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import pytest
import torch
from torch import nn
pd = pytest.importorskip("pandas")
import torchlens as tl # noqa: E402
from torchlens.constants import ( # noqa: E402... |
0f935b44edbca95e4a9854219388d490881bbebb3ccafb93e541938fdecdc1d6 | Python | 5,362 | 84 |
import numpy as np
import pandas as pd
import sys
import scipy
import os
import pydot
import pydotplus
import random
import pickle
#for POPname in ["ASW"]:
for POPname in ["CLM","MXL","PEL","PUR","ACB","ASW"]:
all_lengths_counts =[]
for i in range(22):
print(i)
with open("/rds/general/user/ama... |
71cad57d76bb56cb0f80fa3812e5f4e0aec8d2cbbffefc0047e71a750c2d3c16 | Python | 5,362 | 121 | # -*- coding: utf-8 -*-
import mne
import os
import sys
import glob
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_PATH)
from visualize.visualize import *
spacing = 4
def create_source_space(subj, src_fname, subjects_dir):
try:
src = mne.read_source_spaces... |
88c8acb34c6df18541963363bf0ccbf03e5c4ed16442f9e0f182fbfac1140938 | Python | 5,362 | 140 | from typing import Dict
import tensorflow as tf
from angorapy.agent.ppo.optim import learn_on_batch
from angorapy.utilities.model_utils import reset_states_masked_tf
from angorapy.utilities.core import detect_finished_episodes
def ff_train_step(batch,
joint,
distribution,
... |
c62c461d40318defe395011060a59ac32568a3c0c40c777ad337de7b2837590d | Python | 5,362 | 144 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Non-local helper"""
import torch
import torch.nn as nn
class Nonlocal(nn.Module):
"""
Builds Non-local Neural Networks as a generic family of building
blocks for capturing long-range dependencies. Non-local... |
2db25b3833330d4f00a6359a75f95baeca05a08b7b0b24e79aabaeaa88af5142 | Python | 5,366 | 141 | #Autor: Carlos Alberto Hernández Nava
#ASVspoof2017 spectrograms Log 3 to Log 4
import cv2, sys, os, gc
import librosa
import numpy as np
import pandas as pd
import seaborn as sns
import openpyxl as pxl
import tensorflow as tf
from tensorflow import keras
import IPython.display as ipd
from numpy.random import randn
fr... |
1b39b57aceb8c5e18c9308b0c568188540ff11f6e626126da2b08514179f6d12 | Python | 5,367 | 181 | from dataclasses import dataclass
from typing import Optional, Union
from scipy import constants
@dataclass
class Unit:
"""Definition of a physical unit."""
name: str
value: float
@dataclass
class Quantity:
"""Definition of a quantity."""
name: str
units: list[Unit]
default: str
... |
0aba775a1a9742284216e894f0e501c6f291aa2993171f171e1dee2572423646 | Python | 5,368 | 185 | """
MVP of end to end training process, not used
for final results.
"""
import torch
import torchvision
import torch.nn as nn
import torch.optim as optim
import torchvision.datasets as datasets
import glob
import random
import pandas as pd
import numpy as np
import time
import argparse
import logging
parser = argp... |
e02c85d2af66116782789ac0cf673959c40eb534a40b33b107cf2879232501f1 | Python | 5,368 | 151 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
cc596acb8cad808df525ae3c3e4af9d0b0bbefc2cea7e1acea11340bc4c9643b | Python | 5,371 | 130 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 15 17:44:01 2021
@author: Audrey Mazancieux
This script computes specific contrasts for the local-global model.
It includes:
- contrast estimation for GS vs. GD
- contrast estimation for LSGS vs. LSGD
- contrast estimation for LDGS ... |
53199b2a1f6a3df78a8ad832ab237012aaf707a6503d9785fc39c34737c4ed5d | Python | 5,372 | 158 | import unittest
import pytest
import torch
import torch.nn.functional as F
from pytest_mock import MockerFixture
from torch import Tensor
from torch import distributed as dist
from lightly.loss import VICRegLoss
class TestVICRegLoss:
def test__gather_distributed(self, mocker: MockerFixture) -> None:
moc... |
dff4feffbc90165627eee12e2a6e27d8d6ee52a375ba301401c175b22327125b | Python | 5,372 | 144 | #!/usr/bin/env python3
# coding: utf-8
"""
Created in April 2020
@author: Thomas Bonald <tbonald@enst.fr>
"""
from typing import Union
import numpy as np
from scipy import sparse
from sknetwork.classification.base import BaseClassifier
from sknetwork.classification.vote import vote_update
from sknetwork.linalg.norma... |
ece2c93f0cce94ee9e3a42b0306a233affa163f1364ef14bc6d1e4e8d2c35c34 | Python | 5,373 | 161 | import os
import os.path as osp
import shlex
import shutil
import subprocess
import lmdb
import msgpack_numpy
import numpy as np
import torch
import torch.utils.data as data
import tqdm
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def pc_normalize(pc):
l = pc.shape[0]
centroid = np.mean(pc, axis=0)... |
02008ec315b3743c1814e8dc77fb6ac704386db755f714c904e8f5ae5cc97fb2 | Python | 5,374 | 265 | # BASE
URL = "https://download.bbbike.org/osm/bbbike"
suffix = ".osm.pbf"
class Cities:
available = [
"Aachen",
"Aarhus",
"Adelaide",
"Albuquerque",
"Alexandria",
"Amsterdam",
"Antwerpen",
"Arnhem",
"Auckland",
"Augsburg",
"Au... |
ae3cbd5946294481ebb666530e598a827016b8c19bcd9446eae4260a3aa478eb | Python | 5,374 | 186 | #!/usr/bin/env python
# Created on: January 2, 2014
__author__ = "Sven Kreiss, Kyle Cranmer"
__version__ = "0.1"
import ROOT
import PyROOTUtils
from array import array
SMMarker = ROOT.TMarker( 1.0, 1.0, 34 )
SMMarker.SetMarkerColor( ROOT.kBlack )
container = []
openFiles = []
def getContours( hist, level,... |
c2f583970cfd8ed270e98eaccc7aa5d30f62aa05a7366b7ac9652c8cf5bb5623 | Python | 5,374 | 141 | #Autor: Carlos Alberto Hernández Nava
#ASVspoof2017 spectrograms Log 2 to Log 4
import cv2, sys, os, gc
import librosa
import numpy as np
import pandas as pd
import seaborn as sns
import openpyxl as pxl
import tensorflow as tf
from tensorflow import keras
import IPython.display as ipd
from numpy.random import randn
fr... |
0569b4ae922779f434e76b92b3b6b6f8968d1ab6d46b4833f9c296d514c5e441 | Python | 5,376 | 165 | # This script processes MIMIC-III dataset and builds longitudinal diagnosis records for patients with at least two visits.
# The output data are cPickled, and suitable for training Doctor AI or RETAIN
# Written by Edward Choi (mp2893@gatech.edu)
# Usage: Put this script to the foler where MIMIC-III CSV files are locate... |
dde04d673b7b1e614280824191fc22c56e6697fd9233c8e5d38011e7484d62ec | Python | 5,378 | 139 | # CUB Image model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt
from torchvision import datasets, transforms
from torchvision.utils import make_grid, save_image
from src.utils import Constants
from src... |
1f55a69ec5cc21332b6c796485fd23294da3e7a885e1bde171c143431f0e3daa | Python | 5,380 | 158 | import subprocess
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import Mock
import pytest
from larvaworld.lib import reg
from larvaworld.cli.main import main
pytestmark = [pytest.mark.integration, pytest.mark.fast]
def cli_args(cli_str: str):
mockfun = Mock()
main(cli_args=c... |
6edd0a531e7bac50334dba1526db19f5ef833a154762f17926d8d44926d3e760 | Python | 5,381 | 186 | """Eventlet execution pool."""
import sys
from time import monotonic
from greenlet import GreenletExit
from kombu.asynchronous import timer as _timer
from celery import signals
from . import base
__all__ = ('TaskPool',)
W_RACE = """\
Celery module with %s imported before eventlet patched\
"""
RACE_MODS = ('billiar... |
9862c26133d58c87a18c97d1ef5fab80ab7edea29cc94458eccc1d7ec81a4ce0 | Python | 5,381 | 148 | # -*- coding: utf-8 -*-
"""
local_pi_revc.py -- Panel configuration for Magpi client Rev C boards.
Rev C boards use a solenoid-driven hopper on GPIO 16. The single PCA9685
at address 0x55 drives all LED and house light outputs at 1000 Hz.
Do not use this file on Rev D boards. The board revision is detected
automatica... |
8b8a94b26fc485b4b6f54d679373550819e119f86bcec2ece5ca30c985b23f11 | Python | 5,382 | 131 | # -*- coding: utf-8 -*-
import torch
from itertools import accumulate
def make_batch_align_matrix(index_tensor, size=None, normalize=False):
"""
Convert a sparse index_tensor into a batch of alignment matrix,
with row normalize to the sum of 1 if set normalize.
Args:
index_tensor (LongTensor... |
1fc9d40f28f383ecd1f5ff1bacd5b1a003a2df6dcab7d0de348bc8f2a1c42516 | Python | 5,383 | 153 | import pytest
import torch
from pytest_mock import MockerFixture
from torch import distributed as dist
from lightly.loss.dcl_loss import DCLLoss, DCLWLoss, negative_mises_fisher_weights
class TestDCLLoss:
def test__gather_distributed(self, mocker: MockerFixture) -> None:
mock_is_available = mocker.patch.... |
a38bc9161e4e010b53c720d85e2513c04ba24097eddeedf90985cc0dfd709e1e | Python | 5,384 | 148 | import random
from typing import Optional
import numpy as np
import torch
from anndata import AnnData
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
from ...configuration import SKM
from .utils import compute_pca_components
@SKM.check_adata_is_type(SKM.ADATA_UMI_T... |
4e249bef68f28bd50eddc782db1a275e2948c6e63ac2368b8cd38328aa5527a1 | Python | 5,385 | 136 | import torch
from torch import nn
import numpy as np
ch = torch
class FakeReLU(torch.autograd.Function):
@staticmethod
def forward(ctx, input):
return input.clamp(min=0)
@staticmethod
def backward(ctx, grad_output):
return grad_output
class FakeReLUM(nn.Module):
def forward(self,... |
81c9de36b2a4ae461cd47e59ba6d668e0f38877e96deead3e690dcc73b32225e | Python | 5,385 | 143 | # Copyright 2025 Google.
#
# 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, soft... |
9cf91d02318d03fa73066b335510cd30afb1407242d9753f6eec0b201505f98b | Python | 5,385 | 139 | import unittest
import numpy as np
import tensorflow as tf
from deepspeech_training.util.helpers import ValueRange, get_value_range, pick_value_from_range, tf_pick_value_from_range
class TestValueRange(unittest.TestCase):
def _ending_tester(self, value, value_type, expected):
result = get_value_range(va... |
456d02daf26c96de9c7b15efd0790c05bf50af2ebcd06e1b6a8097a8278d11d2 | Python | 5,387 | 174 | from typing import Any, Callable, Optional, Sequence, Union
from pl_bolts.datamodules.vision_datamodule import VisionDataModule
from pl_bolts.datasets import TrialCIFAR10
from pl_bolts.transforms.dataset_normalizations import cifar10_normalization
from pl_bolts.utils import _TORCHVISION_AVAILABLE
from pl_bolts.utils.w... |
8b16bb182e937aebe754d763b553b90ed2e47c25df224cbf469feccca1987023 | Python | 5,387 | 151 |
class ClassSetting(object):
""" Class to hold parameters of classification problem
Attributes
----------
confidence_scores_class : dict {string : float}
Dictionary holding per methylation class a minimum confidence score will be used if filter_methylation_confidence is True
confidence_sc... |
c9a801f615f6c1a9b0bbcc300525f39acf472f88f73169547c83e884b7e1fe56 | Python | 5,387 | 156 | import numpy as np
from mitochondria import Mito
from gates import get_ros
from utils import Recorder, Q_nak
def fet_run_sim(mito_baseline, spike_quanta, psi_fac=1e-3, refrac=6,
iclamp=2, theta_fet=-0.025):
print('Baseline : ', mito_baseline, 'Quanta :', spike_quanta)
print('Psi factor: ', ps... |
60ba7b8f94fb6893d20f38231578dbe815089c2b993a1e8f647be34b0c2e2e47 | Python | 5,389 | 259 | def get_file_paths(control_file):
"""
:param control_file:
:return control_dic:
parses control_file into a dictionary providing the code access to all the paths it needs to run
control file format is @\tkey=path
key is used as a dictionary key and the path is assigned to that key
the d... |
d3adddced09494f04956bbf227e6a2adafaa4cfc6bf7681627c0492fcdbccd3d | Python | 5,389 | 133 | """F06 B8 real-checkpoint rows for text() (attrib memo section 4).
The gpt2 Eiffel headline (residual < 1% asserted end to end), the distilgpt2
fast row, and the bert [MASK] callable-target row on the auto pad+scaffold
baseline -- the only measured converging encoder baseline; NO residual bound
is asserted for the zer... |
f01f58f0dca80ab8bf970ac3ef75a032576d6405502bd380d3146ff233fb92e2 | Python | 5,389 | 151 | import numpy as np
from tqdm import tqdm
import pandas as pd
import pathlib
from functools import partial
import multiprocessing
import click
import re
from causal_optoconnectics.buzsaki import transfer_probability
from causal_optoconnectics.tools import min_error, process_metadata
def load(path):
data = np.load(... |
08df8f1e947a4f83ead248de3c181d0222ba9abb773cc8bd773d4697a7def713 | Python | 5,390 | 129 | """The normative writer contract and its digest (ecosystem MEMO 3.1).
``writer_contract_digest()`` is the NORMATIVE digest over the canonicalized
persistence contract: version constraints, the KEEP/DROP field-policy tables
AND persisted field-NAME sets per record type, nested component spec tables,
manifest/body/codec... |
1f89e914c1b4a1239bfd8539a9799b19862af615540bbe8d329bdb21cd39a40b | Python | 5,390 | 162 | #!/usr/bin/env python
import os
import string
import sys
from argparse import ArgumentParser
CONFIGURE_URL = "https://docs.galaxyproject.org/en/master/admin/"
DESCRIPTION = "Initialize a directory with a minimal Galaxy config."
HELP_CONFIG_DIR = "Directory containing the configuration files for Galaxy."
HELP_DATA_DI... |
518863c3be7d8fecb9b13c48dfdb7e609d9a0ac293733921ac9be58ca09df51d | Python | 5,390 | 99 | from Configurations import config as cfg
###############################################################################
# SIMULATION MODEL PARAMETERS, i.e. the diffusion
# number of simulation model parameters
idxModTypes = len(cfg.EnumModelParams)
# NOTE: We divide EmissionRate by StepsPerFrame, i.e. 10, and Parti... |
cb221a7e0ba5eee299052c6835e6ec8b5414d090344d1fce282542da020942da | Python | 5,390 | 104 | import unittest
import unittest.mock
from svim.SVCandidate import CandidateDeletion, CandidateInversion
from svim.SVSignature import SignatureDeletion
class DeletionCandidateTestCase(unittest.TestCase):
def setUp(self):
self.contig = "chr1"
self.start = 1000
self.end = 2000
self.me... |
302acd8e2c3a3b0041eb3002350b4b87b3ffc809ced18e5af880cc054bcdcb7a | Python | 5,391 | 159 | # coding=utf-8
# Copyright 2023 The Google Research Authors.
#
# 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 applicab... |
49ef9e00255fd4c4a367cc45ed0120bd07a4a47d140bb09c1c321b98019317b4 | Python | 5,393 | 153 | # flake8: noqa
import numpy as np
import pytest
from absl.testing import parameterized
from keras.src import backend
from keras.src import layers
from keras.src import testing
from keras.backend import set_image_data_format
class UpSampling2dTest(testing.TestCase):
@classmethod
def setUpClass(cls):
c... |
9dd2bc15d43182bbb12e3809c8a20ca82b58171684437eb9dde53b667c743766 | Python | 5,394 | 183 | import os
from abc import (
ABCMeta,
abstractmethod,
)
from typing import (
Any,
)
from galaxy.job_execution.datasets import DeferrableObjectsT
from galaxy.job_execution.setup import JobIO
from galaxy.model import Job
def dataset_path_to_extra_path(path: str) -> str:
base_path = path[0 : -len(".dat")... |
1300f3d0a90ebbeee2a1a0b1385b904a60c628fededa12a229a6a9a5cc2b77cc | Python | 5,395 | 180 | #!/usr/bin/env python
# Aufruf convert_graph.py --infile datei --informat typ --outfile ausgabedatei --outformat ausgabetyp
import argparse
import sys
import networkx as nx
from networkx.readwrite import json_graph
from xgmml_networkx import XGMMLParserHelper, XGMMLWriter
# supported graph_types
graph_types = ["gml"... |
857356fa58ae736217f2d4f3dee2506e239462282bcbb295a7813c53572df2dc | Python | 5,395 | 159 | """Helpers for suggesting workflow output labels during extraction."""
import re
from dataclasses import dataclass
from typing import (
Literal,
)
from galaxy.managers.context import ProvidesHistoryContext
from galaxy.managers.jobs import get_output_name
from galaxy.managers.markdown_parse import UNQUOTABLE_ARGUM... |
257b819ccf589c75c832f5f603ed3041d67dc5fd225d112d8d36be33aa862901 | Python | 5,396 | 178 | #!/usr/bin/env python
import sys
import rpy2.rlike.container as rlc
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
r = robjects.r
grdevices = importr("grDevices")
# from rpy import *
def stop_err(msg):
sys.stderr.write(msg)
sys.exit()
infile = sys.argv[1]
y_col = int(sys.arg... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.