sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
dc742ce700078cad7a01853079dcf9a9745a090d6e55b8c65768e563cf00aa48 | Python | 8,878 | 212 | """
Copyright (c) 2022 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJE... |
f6a07b2dd06a1bc6064ee95fe3534962b8b911c467aee41b99700a90eda94235 | Python | 8,878 | 241 | # SOURCE: vendored from https://github.com/rail-berkeley/rlkit @ ac45a9db24b8
# (rlkit/torch/networks/mlp.py: Mlp; rlkit/torch/sac/policies/gaussian_policy.py: GaussianPolicy;
# rlkit/torch/distributions.py: MultivariateDiagonalNormal; rlkit/torch/pytorch_util.py: fanin_init)
#
# Implicit Q-Learning (Kostrikov, Na... |
79801524c6bba8e4717c09558b86508aed1c716c8ca59ad75573582f8eac635b | Python | 8,879 | 218 | # Copyright (c) 2026, Tri Dao.
"""CUDA graph capture and replay for the FA4 (CuTe) entry points.
A captured call may not synchronize with the host (`.item()`, `.tolist()`, a host read of
a device maximum), must launch on the capturing stream, and must read every per-sequence
length from device memory, so that a replay... |
0846105e272c4c9c7a0fc6b02d8a1d8bbe40e8099f6119b538df32d62956f6c6 | Python | 8,880 | 189 | '''
A top 4 atom GRU, 4 linear layer Pretraining network for NMR shifts.
'''
import torch
import torch.nn as nn
import logging
logger = logging.getLogger(__name__)
device = "cuda" if torch.cuda.is_available() else "cpu"
class NMR_MPNN(nn.Module):
'''
Edge based message passing neural network. Messages are pas... |
e2663ef22720a4eeeaa1c56c009a188eee75a5e9896442584dc92b8f54239be7 | Python | 8,880 | 200 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 29 18:04:08 2021
This is the configuration file for Experiment 3. To run the experiment, pass the path to the folder which is to contain
the data from all Experiments on lines 176-177.
@author: emilia
"""
import numpy as np
import itertools
import t... |
6236f8b672bc1cd80c71e293795c89308c26f46fd6fa6e9bbe819314fe3948c9 | Python | 8,881 | 202 | #! /usr/bin/env python
import pandas as pd
import numpy as np
import multiprocessing
import tqdm
import sys
import os
import sqlite3
from sqlalchemy import create_engine
import time
from itertools import repeat
def get_cell_interactions(
enzyme,
replicate,
query_type,
df,
inte... |
ebbef1c477908fc9c6e74e067adb0fe4c4aa484bc96817078f191332dc4a803e | Python | 8,882 | 195 | from functools import partial
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange, repeat
# from flash_attn.utils.benchmark import benchmark_forward, benchmark_backward, benchmark_combined, benchmark_all, benchmark_fwd_bwd, pytorch_profiler
from flash_attn.utils... |
266f7ff7b85dd8177edcd158f2573b6a44fe7ea8b4eddbcbe392a2a4014d232f | Python | 8,884 | 253 | #!/usr/bin/env python3
"""
5D Eval — Diagnostic C: classifier swap (LDA → KNN, Mahalanobis).
Does replacing Fisher LDA with a non-Gaussian / non-parametric classifier
improve individual-subject BA on the same 5D features?
- LDA: Paper 6 baseline. Gaussian-blob assumption per class.
- KNN (k=3, 5, 7): nearest-neighbor... |
5cd8e58f0300f76bb6e214410eceb91691863e3d14ca46c19d79f8f9c06a0203 | Python | 8,890 | 244 | """Paddle recurrence grouping: multi-pass layers, relabel safety, tamper oracles."""
from __future__ import annotations
import dataclasses
from typing import Any
import pytest
paddle = pytest.importorskip("paddle")
import torchlens as tl # noqa: E402
from torchlens.backends.paddle import GradOptions, PaddleBacken... |
a2dbb7c6e813b489b39c584e826e6cecbbc8e521de7e1324a12b9a7246848d32 | Python | 8,890 | 242 | """Tests for the ArangoDb."""
import datetime
from unittest.mock import MagicMock, Mock, patch, sentinel
import pytest
from celery.app import backends
from celery.backends import arangodb as module
from celery.backends.arangodb import ArangoDbBackend
from celery.exceptions import ImproperlyConfigured
try:
import... |
d2fbc9d963715f68d3f3f4f34e1341cdc0d4240bea6faa74c31f6878359baef9 | Python | 8,892 | 235 | # 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... |
d607d49364d611278ea4f2a87295b3d0d181d4ef267b06406362554bd639d722 | Python | 8,895 | 250 | """tlspec v9 audit-row admissions (C07 coordinated schema write).
Three families land in the ONE closed ``intervention_audit`` row grammar:
1. ACT site rows admit the OPTIONAL string ``source`` disclosure the shipped
selection-door writer already emits (A04 dense-subspace point-of-use
stamp). Pre-v9 the validat... |
b558cff3b1ffe630db817568a0b04fbb3793e052615656d95329a0322c1d0025 | Python | 8,897 | 261 | import functools
import os
from permacache import permacache, drop_if_equal
import tqdm.auto as tqdm
import numpy as np
import torch
import matplotlib.pyplot as plt
from modular_splicing.dataset.basic_dataset import basic_dataset
from modular_splicing.evaluation.standard_e2e_eval import evaluate_on_checkpoint
from mo... |
1081a8b67abaa8cda76c6b6796067c5e9e557cfd96e3ef54382cd018cc32e4c6 | Python | 8,899 | 268 | """Exceptions used throughout package"""
from __future__ import absolute_import
from itertools import chain, groupby, repeat
from pip._vendor.six import iteritems
class PipError(Exception):
"""Base pip exception"""
class ConfigurationError(PipError):
"""General exception in configuration"""
class Instal... |
fce7df627c8e54978a8b4420cf205b1bb0b3def69037012dc08dfd110d2242f8 | Python | 8,900 | 185 | #==============================================================================#
# Author: Dominik Müller #
# Copyright: 2024 IT-Infrastructure for Translational Medical Research, #
# University of Augsburg ... |
31573342e6691b4b3ec94e030cfe706d74fe56bf7349f3ed4e59bc7cc7fe5aa4 | Python | 8,901 | 225 | """
Relative Unconstrained Least-Squares Fitting (RuLSIF): A Python Implementation
References:
'Change-point detection in time-series data by relative density-ratio estimation'
Song Liu, Makoto Yamada, Nigel Collier and Masashi Sugiyama,
Neural Networks 43 (2013) 72-83.
'A Least-squares Approac... |
6b8c700a93e3f053f578bf55325022b834750ca230dd89776bfcb643f8a649a0 | Python | 8,902 | 290 | # coding=utf-8
# Copyright 2022 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... |
cc90a5e21477b85f39f7bbc3426b48e4729385f2f16ab9f305e1890185a79148 | Python | 8,904 | 320 | """Utility functions & decorators for the module."""
from copy import deepcopy
###################################################################################################
###################################################################################################
## DATA
DOCSTRING_SECTIONS = ['Parame... |
2af33c00414619e47a57aac6a79bb0c12032f7408132aa5134fafdcbd90eaf9f | Python | 8,905 | 252 | """Static ownership contracts for the narrow runnable-to-Trace seam."""
from __future__ import annotations
import ast
import pickle
from dataclasses import fields
from pathlib import Path
from types import MappingProxyType
import pytest
from _source_corpus import package_ast, package_files
from torchlens._runnable_... |
023a32a87ac729bb09cfe24b2a1014f90004d50242da6fc884c6a114ac5a3657 | Python | 8,907 | 179 | import tensorflow as tf
import tensorflow.keras as ks
from kgcnn.layers.casting import ChangeTensorType
from kgcnn.layers.conv.painn_conv import PAiNNUpdate, EquivariantInitialize
from kgcnn.layers.conv.painn_conv import PAiNNconv
from kgcnn.layers.geom import NodeDistanceEuclidean, BesselBasisLayer, EdgeDirectionNorm... |
c4c68cb91167d59edc604298dc2b938cf856da779691cb6bb6685ea3630478da | Python | 8,907 | 242 | """
Functions for NN model inferencing using Keras module.
Copyright (C) 2021 Tham Cheng Yong
This file is part of NanoVar.
NanoVar 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 Licens... |
7779c5417933913bd6c763b1f24ccddefc701a171590b47399cb6d09a826e446 | Python | 8,908 | 223 | """Time-series / sequence primitives: DLinear and DSS (diagonal state space).
DLinear: "Are Transformers Effective for Time Series Forecasting?"
Zeng et al., AAAI 2023. Paper: https://arxiv.org/abs/2205.13504
Source: https://github.com/cure-lab/LTSF-Linear/blob/main/models/DLinear.py
Distinctive primitive: a mo... |
88d359cdb5272cb413bd7a4123619ff9f8c901d551ae12913ce762c562dd1edd | Python | 8,908 | 238 | """
data_loader_01.py — Load EEG datasets (two-group design: healthy + stroke)
Returns trial-segmented arrays, not continuous recordings, because the stroke
labels exist only in the sourcedata .mat files as per-trial annotations.
Both groups are returned on a common footing:
29 EEG channels, 160 Hz, 4 s motor-ima... |
a27e4bc63cefb84a1b52e04c59c8d5fcea9b626cb18cdae34eec199d758a4385 | Python | 8,912 | 266 | from nfp.frameworks import tf
assert tf, "Tensorflow 2.x required for GraphLayers"
tf_layers = tf.keras.layers
register_keras_serializable = tf.keras.utils.register_keras_serializable
@register_keras_serializable(package="nfp")
class RBFExpansion(tf_layers.Layer):
def __init__(
self, dimension=128, init_... |
46c4b742577aecddc00ce2d34bfb92e42e792bdadaec290c1cef5968bd26f470 | Python | 8,913 | 261 | from __future__ import print_function, division, absolute_import
import csv
import os
import os.path
import tarfile
from six.moves.urllib.parse import urlparse
import numpy as np
import torch
import torch.utils.data as data
from PIL import Image
from . import utils
object_categories = ['aeroplane', 'bicycle', 'bird'... |
c8d4b7354224f8b4de5c48c159e795e17126058ef92836cdcbad7b046da92f0f | Python | 8,917 | 277 | # coding=utf-8
# Copyright 2024 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... |
3493c6d5a76f9f24eec817b1c02d7ad1933893b04aa161e22d104a2d4eda5662 | Python | 8,918 | 219 | """
Loss functions used for training COOT model
"""
from torch import nn
import torch
__all__ = ['MaxMarginRankingLoss', 'CycleConsistencyCootLoss', 'IOULoss']
class MaxMarginRankingLoss(nn.Module):
"""MaxMarginRanking loss used in COOT paper (Eq. 1): https://arxiv.org/abs/2011.00597
Inputs:
- x_emb... |
a15e3651071513fb36ffbe706929d11b891b7561a1321e052b016c8fb36e328e | Python | 8,918 | 239 | """W051 regressions for the episode step-join grading (audit 3.1, 3.4, 3.5).
* 3.5 -- ``exogenous_positions`` was the length of the UNALIGNED SUFFIX, not
a count of exogenous positions: one context token edited in an 8-token
entry reported 8. It is now a positional diff (1).
* 3.4 -- teacher-forced episodes whose ... |
30cf2e7578084ab00ff9c2c9cd568593882bd8a69a03e4eb270c42ed1557dfce | Python | 8,919 | 209 | # # Training tempotrons for the simulation
import os
from os.path import join
import numpy as np
import pandas as pd
from library.Tempotron import Tempotron
from library.script_wrappers import datagen_jitter
from library.shared_vars import sim_results_dir
from library.utils import save_pickle, load_pickle
for analysis... |
42b849a9c4dcf77edc7bbe6fc9f483fe48908c261f45e1a8c372b2dd74fb6af6 | Python | 8,925 | 255 | """R18F regression tests: residual recipe, patching state safety, observer labels/spans.
Covers:
- H3 residual recipe only fires on genuine attn+mlp transformer blocks; resid_mid is
the real post-attention add, never the degenerate first-add-equals-output fallback.
- H8 activation/attribution patching snapshots and ... |
33a8ac256fd68fd02e3af243390452be3707e0d273dc9c54744c347396a7bba5 | Python | 8,928 | 259 | import logging
import os.path
from typing import Dict, List, Union
import pytorch_lightning as pl
import numpy as np
import torch
import torchmetrics
from scipy.special import softmax
from time import time
from lib.modules.losses import CombinedLoss
from lib.models import *
import matplotlib.pyplot as pl... |
845605aa229100b140873c4e7194d1407dddf4ca3760cc746d7d15efba040ce7 | Python | 8,929 | 201 | import math
from typing import Tuple, Union
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
import numpy as np
from numpy.linalg import norm
from scipy.linalg import lstsq
from scipy.spatial import cKDTree
def rough_subspace(pcs: np.ndarray, n: int = 20) -> list:
... |
2320f8c46ed156f91e9f5e9aabe193ed64563aec537f480f33ca653f14406c74 | Python | 8,930 | 270 | # 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.
""" Generic Code for Object Detection Evaluation
Input:
For each class:
For each image:
Predictions: box, score
... |
785728fecea858f7e09d1e6ec67e70bd7a2704d517fffabe8ba4d59cd939ae0c | Python | 8,930 | 269 | """ Performs LR analysis by grouping LR pairs which having hotspots across
similar tissues.
"""
from stlearn.pl import het_plot
from sklearn.cluster import DBSCAN, AgglomerativeClustering
from anndata import AnnData
from tqdm import tqdm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import... |
5a23aef5008a292530a515e8bd7e80f73fdb76160d57dcf322a0f8c1ad47f43c | Python | 8,932 | 219 | """The module describes the ``cgroup`` job metrics plugin."""
import logging
from collections import namedtuple
from typing import (
Any,
)
from galaxy.util import (
asbool,
nice_size,
)
from . import InstrumentPlugin
from .. import formatting
log = logging.getLogger(__name__)
VALID_VERSIONS = ("auto", ... |
2ceb830a9a9698a058f1019ebeb277fe2976235488b7859979efd2ecef41152c | Python | 8,935 | 216 | """
Galaxy FilesSource implementation for RSpace.
This module implements a FilesSource that interacts with an RSpace [1] instance. RSpace is an electronic lab notebook
(ELN) designed for documenting, managing and sharing scientific data. The central concepts in RSpace are the Workspace,
the Inventory and the Gallery.
... |
599e7212c8bc97b58702daf24057be5d341af7f7e6c24a7c3d3182d71761de71 | Python | 8,935 | 295 | from __future__ import annotations
import json
import numpy as np
import osam
import pytest
from numpy.typing import NDArray
from labelme._automation._text_detection import MaskOutputUnavailableError
from labelme._automation._text_detection import get_bboxes_from_texts
from labelme._automation._text_detection import... |
ebaad88193ac043374ff830e406100586b20db234a4f78b7a0a8dd3f4c2b5c95 | Python | 8,938 | 225 | from typing import Tuple
import pytest
import torch
from pytest_mock import MockerFixture
from pytorch_lightning import Trainer
from torch import Tensor, nn
from torch.utils.data import DataLoader, Dataset
from lightly.utils.benchmarking import KNNClassifier
from lightly.utils.benchmarking.knn_classifier import F
c... |
6f46366fc95af1b9f87d02497e04296d76411cf58619ad44622f8f4b1e6ef8e2 | Python | 8,945 | 231 | import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.utils.data
from src.getdata import getdata_from_csv, get_cold_data_from_csv
from src.utils import DrugTargetDataset, collate, AminoAcid, ci
from src.models.DAT import DAT3
import random
parser = argparse.ArgumentParser()
parser.add_argu... |
244caf26d9e5ffb277881edc7dbf64a0babbf72bcdc0d0308fa58843970a2e1c | Python | 8,946 | 247 | """Tests for xcp_d.ingression.ukbiobank."""
import json
from pathlib import Path
from unittest.mock import MagicMock, patch
import nibabel as nb
import numpy as np
import pytest
from xcp_d.ingression import ukbiobank
# Small grid for minimal NIfTIs (nibabel/nilearn need non-empty valid files).
_SHAPE_3D = (5, 5, 5)... |
7267665f207dfa7fe91202a171059d166712ff4a6d88c9200b3432246629396d | Python | 8,946 | 294 | """Variables
With multiple sessions, the same variable name might have multiple definitions::
variables = {
'name': [Var(session='1'), Var(session='2')],
'name2': Var(session='2'),
}
"""
import numpy as np
from .._data_obj import Factor, Var, assert_is_legal_dataset_key
from .._utils.numpy_utils import INT_... |
ad96f28e2db77b883a745ec3e94e899025a36604688046cbb24e21d4eda96eb4 | Python | 8,949 | 271 | import numpy as np
import pytest
from absl.testing import parameterized
from tensorflow import data as tf_data
from keras.src import backend
from keras.src import layers
from keras.src import models
from keras.src import testing
from keras.src.utils import backend_utils
class RandomZoomTest(testing.TestCase):
@p... |
bcc9b01d292a66a1d3a899bf1c948ba5bf9e01d92508e089ad8be7ad92e6feba | Python | 8,950 | 209 | # -*- coding: utf-8 -*-
"""
local_pi_revd.py -- Panel configuration for Magpi client Rev D boards.
Rev D boards use a servo-driven hopper on PCA9685 U7 (I2C address 0x45).
The hopper servo channel is defined by HOPPER_SERVO_CHANNEL (channel 0,
HOPPER_CTL). The second PCA9685 runs at 50 Hz. The lights PCA9685 (U1) is
a... |
833a882093e0908a0b7f05b9547fc21fff960ae390be7d51586353208edc3858 | Python | 8,953 | 253 | #!/usr/bin/env python
# Created on: October 21, 2013
__author__ = "Sven Kreiss, Kyle Cranmer"
__version__ = "0.1"
__description__ = """
Creates a 2-bin counting model using HistFactory.
"""
import optparse
parser = optparse.OptionParser(version=__version__, description=__description__)
parser.add_option( "--... |
94bc7d4a510b97ba6eac1aa7be1aee4331544db7b4d1b4d9a98bec7d9ab2a3f8 | Python | 8,953 | 283 | """S5 byte-identity tripwire for render DOT and collapse-plan plumbing."""
from __future__ import annotations
import hashlib
import json
from collections.abc import Callable
from pathlib import Path
from typing import Any
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.visualiz... |
477e3862db2534a9adb2d6e8297a228fbb6092b56759bf3efcdcb7e39b3a7f91 | Python | 8,954 | 228 | """Adapted from: https://github.com/https-deeplearning-ai/GANs-Public."""
from argparse import ArgumentParser
from pathlib import Path
from typing import Any, List, Optional, Tuple
from warnings import warn
import pytorch_lightning as pl
import torch
import torch.nn.functional as F
from pl_bolts.callbacks import SRIm... |
66766fd39ad665cea16394b1c16834b67f541eed4b74edc941fabfa4e8745c07 | Python | 8,954 | 268 | import torch
import copy
import random
import numpy as np
import torch.nn.utils.rnn as rnn_utils
from utils import tokenize, read_object_property_file
class GeneratorData(object):
"""
Docstring coming soon...
"""
def __init__(self, training_data_path, tokens=None,
end_token='/', max_... |
7daf4eae00927b8f0920220d49fd69987e1d085f44ded5bb2ace3e970ea0a475 | Python | 8,954 | 247 | """
velvet datatypes
James E Johnson - University of Minnesota
for velvet assembler tool in galaxy
"""
import logging
import os
import re
from galaxy.datatypes import (
data,
sequence,
)
from galaxy.datatypes.metadata import MetadataElement
from galaxy.datatypes.protocols import (
DatasetProtocol,
Has... |
93bbc7c214eb26f339f947f79ff3b717fb395a53ba51d7d387405ebb559a1167 | Python | 8,956 | 317 | """
analysis method for experiment results.
across 5 fold cross validation and then print the metrics.
meanwhile can print the CM.
"""
# %%
import torch
import torch.nn.functional as F
import os
import sys
sys.path.append('/workspace/Walk_Video_PyTorch/project')
from models.pytorchvideo_models import WalkVideoClas... |
dada6b6d9ebcb78c103a5b5bb75a2d141190bb053d43f9b08fe2211e7a68cd3f | Python | 8,956 | 282 | '''Tools for working with files in the samtools pileup -c format.'''
import collections
import pysam
PileupSubstitution = collections.namedtuple("PileupSubstitution",
(
"chromosome",
... |
2356e25901d3fe6c0914cf33001f75afa7320bf39f8cdf7b036fb43ca076262f | Python | 8,960 | 326 | """Stable module-containment snapshot serialization helpers."""
from __future__ import annotations
from collections.abc import Iterable, Mapping
from typing import Any
def _stringify(value: Any) -> Any:
"""Convert nested values into JSON-stable primitive containers.
Parameters
----------
value:
... |
25e3b16576a7f1ea9db6e9a3e0aba8207fc1192f58bd26f2c4b231bc71b0505d | Python | 8,961 | 206 | # code from https://github.com/jianhuupenn/SpaGCN
import scanpy as sc
import pandas as pd
import numpy as np
import scipy
from scipy.sparse import issparse
import numba
@numba.njit("f4(f4[:], f4[:])")
def euclid_dist(t1,t2):
sum=0
for i in range(t1.shape[0]):
sum+=(t1[i]-t2[i])**2
return np.sqrt(s... |
a5224baae1e67f078b84753168612450c613cef769ce687cacf139e22ea487dd | Python | 8,961 | 276 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import time
import os
import sys
from tqdm import tqdm
import multiprocessing as mp
from pathlib import Path
from copy import deepcopy
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
fr... |
da2bbb0030a8b73824ba62f40d9d0108a874697d30f9d29bc42dcfeab43edcd5 | Python | 8,962 | 246 | """Behavioral tests for streaming-stat edge semantics and the aggregate fast path.
The compiled sparse ``aggregate(target="out")`` plan only arms on fully-eval
models, so these tests pin the load-bearing contract: fast-path results are
identical to the exact per-batch full-trace path, including the fingerprint
drift f... |
905240d77f25379d74e875817cf76caa1fde558f2e0c232980b93cac9ff030ad | Python | 8,963 | 259 | import os
import os.path
from functools import singledispatch
import numpy as np
import pandas as pd
from mirp._data_import.directory import ImageDirectory, MaskDirectory
from mirp._data_import.generic_file import ImageFile, MaskFile
from mirp._data_import.utilities import supported_file_types, supported_image_modalit... |
e01cebada6d0b744489c21470276658272ae75a4294dec660b64850ff227b24f | Python | 8,963 | 259 | # -*- coding: utf-8 -*-
import os
import sys
import random
import mne
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import median_abs_deviation
from collections import defaultdict
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_PATH)
from visualize.v... |
989441031701bc1e4ab2c4c68c6b3446403f800ca297c23e2f72b9f7a1ca4b0c | Python | 8,966 | 296 | """Smoke tests for backward grad_fn_handle visualization."""
from pathlib import Path
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.options import CaptureOptions, VisualizationOptions
from torchlens.visualization import show_model_graph
from torchlens.visualization._render_com... |
f2b1f0aa363916ec6f3d6d5a65fba23d1c7032bd3e9d4504d537d58a39515ae4 | Python | 8,967 | 227 | #!/usr/bin/env python3
"""
Dx AP — eval step (uses extras already extracted by the parent script
that crashed at the eval phase). 12-feature pool (5D + AP_TOPO) — drop
the 3 CONN_ALPHA connectivity features which require a separate
connectivity pipeline not run here. Per Dx AH, dropping iplv/dpli
features is empiricall... |
d43174143eb2df0f46c9e931c203d794637e7e03bbce97655d66f00d299cbc6a | Python | 8,969 | 283 | """Tests for Phase 2 onramp and discovery APIs."""
from __future__ import annotations
from pathlib import Path
from typing import Annotated
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens import utils
from torchlens.experimental import attribute_walk
class TinyMLP(nn.Module):... |
ea16ffc761c9ad2730ff275ca228b0a300a4dc1811ede00395b80e9d83a870f7 | Python | 8,970 | 221 | import hashlib
import logging
import random
from datetime import datetime
from sqlalchemy import func
from galaxy import (
model,
util,
)
from galaxy.tool_util.deps.dependencies import ToolInfo
log = logging.getLogger(__name__)
VALID_JOB_HASH_STRATEGIES = ["job", "user", "history", "workflow_invocation"]
... |
a7d09d7885efb99a4feacea7b47a206fe78239f129c409d700baa383e2d5a051 | Python | 8,972 | 262 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Test classes and functions in tfep.nn.graph.
"""
# ===========================================================... |
6146c9fba1186f15ca4baa6b028993ca489d8052bd740b32b996b09ddfd092dc | Python | 8,973 | 199 | import numpy as np
import vtk
import vtk.util.numpy_support as vtk_np
from vtkmodules.util.numpy_support import vtk_to_numpy, numpy_to_vtk
import subprocess
import sys
import os
class Helper():
#source: https://discourse.vtk.org/t/convert-vtk-array-to-numpy-array/3152/3
@staticmethod
def vtkToNumpy(data):... |
09fd2dc6cf7afcb379919df3d98c710b4bf5842e2dbd9390dee5945ed709fb98 | Python | 8,974 | 287 | """
Sensors for the 2D robot simulation.
Provides the light and proximity sensors used by the Braitenberg-style robot
agents, which sample the environment along a ray from the sensor's mounting
point rather than at the agent's centre.
"""
from __future__ import annotations
from typing import Any
# import math
import... |
4f3cf3156541fe4a4c1c9b263d02ef3e80a26b1d2fe6e66baad8838d03721746 | Python | 8,975 | 259 | from keras.src import backend
from keras.src import dtype_policies
from keras.src import ops
from keras.src import tree
from keras.src.api_export import keras_export
from keras.src.backend.common import get_keras_mask
from keras.src.saving.keras_saveable import KerasSaveable
from keras.src.utils.naming import auto_name... |
b4cd85a076a3ca995d18cd17ef99d011d6347bcb7c688940b9f987a7aa4ec267 | Python | 8,976 | 274 |
import itertools as itt
import numpy as np
from scipy.ndimage.interpolation import map_coordinates
from imfun import fseq
from ..core import fnutils
import pickle
import gzip as gz
import collections
_boundary_mode = 'nearest'
class Warp:
def __init__(self):
self.field_ = None
self.fn_ = No... |
28d33d92331d87657f9dfd05e3cf97f20b74a7dc32f0d838c91ab4af0cc32335 | Python | 8,982 | 255 | import pickle as pkl
import random
import os
import numpy as np
import re
import torch
import tqdm
from collections import defaultdict
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, T5ForConditionalGeneration
device = 'cuda' if torch.cuda.is_available() else 'cpu'
device_count = torch.cuda.device_coun... |
64501b867c91e4d0ee0ca4324a83da3d828d9ae977ef2b0bef6f3720cc4305e3 | Python | 8,983 | 259 | """F16 B5: the single-file offline report (treescope memo decision 4).
The row gate's JS-off/no-network regression lives here: the report must
carry zero external references, read fully without JavaScript, scrub home
paths, regenerate byte-exactly under ``deterministic=True``, and disclose
exactly what it embeds and o... |
962223c8238cabe4fdd97c786a99f2b75d820ec3c8cad4a3782907e99f51c619 | Python | 8,985 | 229 | """AWQ core functionality for layer-wise quantization.
This module provides the orchestration logic for applying AWQ quantization
to transformer models in a layer-by-layer fashion.
"""
from contextlib import contextmanager
from absl import logging
from keras.src import ops
from keras.src import utils as keras_utils... |
2698ce5e1233fa097eda71dcf63ac1f1439de95862a1c8252b01ed44983f38a6 | Python | 8,988 | 210 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class XBins(_BaseTraceHierarchyType):
_parent_path_str = "histogram"
_path_str ... |
6288d75cc82ff23ea6c36ac1815508965ee3093c51d2c5dbf72b6a02589d4f24 | Python | 8,988 | 305 | #! /usr/bin/env python
import math
import optparse
import os
import string
import sys
import tempfile
import fasta
def format(seq, N=60):
nseg = int(math.ceil(len(seq) / (N + 0.0)))
return "\n".join([seq[i * N: (i + 1) * N] for i in range(nseg)])
# write into fasta format file
parser = optparse.OptionPars... |
7f7b7e9fd62ddb59e0902d8b8321fd96264ce1be89134a6a4d40bcfe93806f1b | Python | 8,988 | 210 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class YBins(_BaseTraceHierarchyType):
_parent_path_str = "histogram"
_path_str ... |
1c2af0b77f8e06d28be344b83e3145a34d54e5ca3a2051648bf3a31b33ff746f | Python | 8,992 | 322 | import pynvml
import time
import warnings
FROM_mWATTS_TO_kWATTH = 1000 * 1000 * 3600
class NoGPUWarning(Warning):
pass
class GPU:
"""
This class is interface for tracking gpu consumption.
All methods are done here on the assumption that all gpu devices are of equal model.
The GPU class is not i... |
1c5b628d1ecdeb0fe308f2ee0a8c72561e5b440c5ab0054a42633a566ffa8ac6 | Python | 8,993 | 220 | import numpy as np
from neurogym.core import TrialEnv, TrialWrapper
class SideBias(TrialWrapper):
"""Changes the probability of ground truth with block-wise biases.
Args:
env: The task environment to wrap (must expose `choices`).
probs: Explicit probability matrix with shape (n_blocks, n_cho... |
84a9ae4cc0041878fbfb19b4928a5620895f16d5c309683544280dc6248cb6b3 | Python | 8,994 | 249 | # Copyright 2022 Deepfold Team
#
# 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 i... |
b2b7bcc560bc39abe7b13874202288778a8a3928f711cf6bb139724f17924799 | Python | 8,995 | 267 | from pathlib import Path
from typing import Literal
import numpy as np
import pandas as pd
import scipy
from anndata import AnnData
from scipy.sparse import csr_matrix
import stlearn
from ._weighting_matrix import (
_PLATFORM,
_WEIGHTING_MATRIX,
impute_neighbour,
weight_matrix_imputed,
)
_COPY = Lit... |
d1cd69de7618c26ecfd92cc4ce93c64ce3990c50fc1ca04c01da30888057af01 | Python | 8,995 | 242 | #!/usr/bin/env python3
"""
File: overview_lineplot.py
Created: 2021/05/20
Last Changed: 2021/10/25
Author: M.Vochteloo
Copyright (C) 2020 University Medical Center Groningen.
A copy of the BSD 3-Clause "New" or "Revised" License can be found in the
LICENSE file in the root directory of this source... |
d6d6b6230f2e724570a36b32e8873167db7d70991f57534586511a257e10de14 | Python | 8,995 | 243 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created in February 2024
@author: Thomas Bonald <thomas.bonald@telecom-paris.fr>
@author: Yiwen Peng <yiwen.peng@telecom-paris.fr>
"""
from typing import Tuple, Optional, Union, List
import numpy as np
from scipy import sparse
from sknetwork.utils.check import is_sym... |
e4d0046bb2628b490d862f8eb5253aae268b78a53bc8a0f77b69dc2558243520 | Python | 8,995 | 207 | from os.path import splitext
from os import listdir
import numpy as np
from glob import glob
import torch
from torch.utils.data import Dataset
import logging
from PIL import Image, ImageDraw
import torchvision.transforms.functional as TF
import random
from torchvision import transforms
import matplotlib.pyplot as plt... |
a5d56f08273862d07f9c8fc4f43ee78914134bbb73549db9a42e4fcc282ccc70 | Python | 8,996 | 200 | #%% Packages
import os
import torch
import copy
import utils
import draw_utils
import json
import warnings
import numpy as np
import tgan_utils
import matplotlib.pyplot as plt
import torch.optim as optim
from TGGAN.TGAN import Discriminator, Generator
warnings.filterwarnings('ignore')
os.environ["CUDA_VISIBLE_DEVICE... |
69b5773b58350fab949bd623ad5023585d0e027d3a412b359505ba456a036f47 | Python | 8,998 | 227 | from datetime import datetime
from nitorch.spatial import voxel_size
from nitorch.core.math import round
from nitorch.io import (map, savef)
import os
from timeit import default_timer as timer
import torch
_unires_title = r"""
_ _ _ ____
| | | |_ __ (_) _ \ ___ ___
| | | | '_ \| | |_) / _ \/... |
e35864431756ce1a2c312bd10998e5959bcf00dc5560af850a6bf361a29e785d | Python | 9,000 | 165 | from SocialGNN_modelfunctions_Gaze import SocialGNN, get_inputs_outputs, CueBasedLSTM, get_inputs_outputs_baseline
from collections import namedtuple, Counter
import pickle
import numpy as np
import sys
mode = sys.argv[1]
which_model = sys.argv[2]
output_labels_type = int(sys.argv[3]) #2 for social/non social, 5 for g... |
faf3159aa470141ae39c90823dd990624c0638f9f19cfe7f71452b3df00dea28 | Python | 9,001 | 223 | """Gauge Equivariant CNN on the Icosahedron.
Cohen et al., "Gauge Equivariant Convolutional Networks and the
Icosahedral CNN." ICML 2019. arXiv:1902.04615.
Source: https://github.com/mariogeiger/se3cnn (early implementation)
https://github.com/gpleiss/equivariant_maps
Distinctive primitive:
Convolution on a... |
9f57252b78b17ada9131ebf0282772762ca4e07cd3fd4c4a1991c223b26224db | Python | 9,002 | 274 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import copy
from functools im... |
3224c5e42e6c82bb97dc5845b46088ddcd775c90c2a7d3ace8d0d6ae20741d2b | Python | 9,006 | 291 | # -*- coding: utf-8 -*-
import time
import datetime
import logging
#import RPi.GPIO as GPIO
from pyoperant.interfaces import base_
from pyoperant import utils, InterfaceError
logger = logging.getLogger(__name__)
#!/usr/bin/env python
# PCA9685.py
# 2016-01-31
# Public Domain
import time
import pigpio
class PWM:
... |
c522e47d298882c9332b5f9823aeeef3713476f96fb6680bdfc009061ed6c245 | Python | 9,008 | 281 | '''PyTorch module.'''
from __future__ import annotations
from typing import Iterable, List, Dict, Union, Tuple, Any, Callable, Optional
from collections import OrderedDict
import os
import warnings
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
from . import models
_tensor_t = Union[np... |
fefc4937898f89cdd4f832ba4d27197e4035a2f96acc83a337b7c8a6ddf29a46 | Python | 9,009 | 228 | #!/usr/bin/env python3
"""
File: prepare_bryois_eqtl_files.py
Created: 2022/01/26
Last Changed:
Author: M.Vochteloo
Copyright (C) 2020 University Medical Center Groningen.
A copy of the BSD 3-Clause "New" or "Revised" License can be found in the
LICENSE file in the root directory of this source tr... |
c7fd273b783057306873d0dbc38c3dfb86257384bec891fa32fde2df10691076 | Python | 9,010 | 262 | import tarfile
import zipfile
from pathlib import Path
import pandas as pd
from PIL import Image
from hobj.data import behavior as behavior_loaders
from hobj.data import download as download_module
from hobj.data.images import get_image_path, load_image
def _write_minimal_packaged_dataset(data_root: Path) -> None:
... |
aa7d9bc12b10ca26443b955c8d4b19204246051f30c56920000aabc2474df3be | Python | 9,012 | 278 | import json
import logging
import warnings
from abc import ABC, abstractmethod
from inspect import getmembers
from typing import Any, Dict, Optional
import networkx as nx
import numpy as np
from nfp.frameworks import tf
from nfp.preprocessing.tokenizer import Tokenizer
logger = logging.getLogger(__name__)
class Pre... |
10f2ca484e40ca6461dc4d439f27e1b009e7291b5a77af3550e4c302fcec91b2 | Python | 9,013 | 205 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 29 18:04:08 2021
This is the configuration file for Experiment 2, post-cue delay length = 5 cycles variation. To run the experiment,
pass the path to the folder which is to contain the data from all Experiments on lines 178-179.
@author: emilia
"""... |
39dcb4fb429ee175ce03d5a612e420decf369203a322c7bea645ac309a44d78d | Python | 9,018 | 245 | import time
from unittest import mock
import jwt
import pytest
from starlette.requests import Request
from carbonserver.api.errors import AuthenticationError
from carbonserver.api.routers import authenticate
from carbonserver.api.services import auth_service
VICTIM_SUB = "d1b9d5e0-58e8-45f0-9ef5-4549b3d6f3f0"
DEV_JW... |
b0dd7bb66fd1f30d68564da6cc23e9fbcf0056bfca6c0484854e3b2be3a587b6 | Python | 9,018 | 265 | import itertools
from collections import defaultdict
import numpy as np
import tqdm.auto as tqdm
from more_itertools import chunked
from permacache import drop_if_equal, permacache
from modular_splicing.dataset.h5_dataset import H5Dataset
from modular_splicing.eclip.data.eclip_peaks import eclips_from_onehot
from mod... |
69d8db8df944a60e2f8442d6ee23bd8f9dfc082c647cd1ff0c7d746be6a25e74 | Python | 9,019 | 289 | # %%
from pytorchvideo.models import resnet, csn, r2plus1d, x3d, slowfast
import torch
import torch.nn as nn
import copy
# %%
class MakeVideoModule(nn.Module):
'''
the module zoo from the PytorchVideo lib.
Args:
nn (_type_):
'''
def __init__(self, hparams) -> None:
super().__... |
8be5e8777d94c6624b74b427ff9d417b4c24f5033c64ccdbcceb9b41b33d3821 | Python | 9,020 | 261 | import numpy as np
from carbontracker import exceptions
from carbontracker.components.gpu import nvidia
from carbontracker.components.cpu import intel, generic
from carbontracker.components.apple_silicon.powermetrics import (
AppleSiliconCPU,
AppleSiliconGPU,
)
from carbontracker.components.handler import Hand... |
2a1ad7583151ba2904c5d66a6b978f4a5cfc2818e4e19a077509c8047d6a7764 | Python | 9,021 | 257 | from typeguard import typechecked
from typing import Union, Dict, List, Tuple
import math
import torch as tt
from .transforms import scale_features
import matplotlib
import matplotlib.pyplot as plt
@typechecked
def centre_crop(
image: tt.Tensor,
shape_output: Union[tt.Size, List[int]],
value_pad: int = 0,... |
05bcb149dcd9fb88411d27f0215e53db7a57ea6171c9910d8023803236a4f3e6 | Python | 9,022 | 275 | import locale
locale.setlocale( locale.LC_ALL, 'en_US.UTF-8' )
import re
import pandas as pd
try:
from local_extractor.states.state_utils import HR_utils
except ImportError:
import sys, os, pathlib
path = pathlib.Path(__file__).absolute().parents[2]
path = os.path.join(path, 'local_extractor', 'states... |
7cc82dff6b7cffed060c2c92d189bb77d2f35a97d63a4e80138a7ebc0f42e041 | Python | 9,022 | 260 | # type: ignore[override]
import os
from typing import Any, Callable, Optional
from pytorch_lightning import LightningDataModule
from torch.utils.data import DataLoader
from pl_bolts.datasets import UnlabeledImagenet
from pl_bolts.transforms.dataset_normalizations import imagenet_normalization
from pl_bolts.utils impo... |
5b6d551fff173d55562aab4ba449e4096895f678e25885645ad98044de741ef4 | Python | 9,024 | 231 | import os
import torch
import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
from scipy.optimize import linear_sum_assignment as linear_assignment
from sklearn import preprocessing
from scDGD.classes.representation import RepresentationLayer
def set_random_seed(seed):
torch.manual_s... |
5ca1e0ae5ba6f0b76ba415e2f8bfb444b9ba9f73d2345cd37c11ddfcefbefba2 | Python | 9,027 | 287 | # %%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import cv2
import os
from globals import path, sessions, subjects, folder_spots_noboth, colours_types
ss = 25
transparency = 0.9
figure_paper_number = "3a"
# %% get data from txt file
file_adtest_path = f"{path}/adtest.txt"
adtest_df = pd.rea... |
183352472b8c592cd07e6a436dc2e6d21bc707c0d6e14e69d150b011ed643f8e | Python | 9,030 | 266 | import tensorflow as tf
from tensorflow.keras.layers import Layer
# https://stackoverflow.com/questions/65195956/keras-custom-batch-normalization-layer-with-an-extra-variable-that-can-be-change # noqa
# https://github.com/dksakkos/BatchNorm/blob/main/BatchNorm.py
@tf.keras.utils.register_keras_serializable()
class A... |
982a456c2edea5c7707ab2a710af0ad1761e2da81c134656433d0eae6bbdc833 | Python | 9,033 | 270 | # pylint: disable=arguments-differ
"""Bounding boxes operators"""
from __future__ import absolute_import
import numpy as np
from mxnet import gluon
class NumPyBBoxCornerToCenter(object):
"""Convert corner boxes to center boxes using numpy.
Corner boxes are encoded as (xmin, ymin, xmax, ymax)
Center boxes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.