sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
bc0c932504419d73cc09a7946bfe4ebf55475328db95b3a18a9ec8a3e94fd090 | Python | 3,915 | 97 | import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras import activations, constraints, initializers, regularizers
from tensorflow.keras.layers import Layer, InputSpec
class ClusteringLayer(Layer):
def __init__(self, weights=None, alpha=1.0, **kwargs):
if 'input_shape' not in k... |
e9b10f5f6376c184d400f254032d0805e7a669863ac1f524809bd2ae9ebda697 | Python | 3,915 | 123 | #!/usr/bin/env python
# emulator.py - a simple BCI system emulator
# Copyright (C) 2007-2011 Bastian Venthur
#
# 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 2 of the License, ... |
fa35f196be1e6601ad7e7976a97c1c9dde1c3edc57e1df8b193c9e352ebbeb81 | Python | 3,915 | 124 | import math
import anndata
import numpy as np
from PIL import Image
from skimage.transform import resize
def transform_spatial(coordinates, original, resized):
# obs transform
x = coordinates[:, 0]
y = coordinates[:, 1]
x1p = x / original[1]
y1p = y / original[0]
x1 = x1p * resized[1]
y1 ... |
c1d159de6db6693ca81568284f1cc65805a24a44c6ffe21b50be0855f6187832 | Python | 3,916 | 95 | """2. Predict with pre-trained AlphaPose Estimation models
==========================================================
This article shows how to play with pre-trained Alpha Pose models with only a few
lines of code.
First let's import some necessary libraries:
"""
from matplotlib import pyplot as plt
from gluoncv imp... |
d0b9d263974c9fcba7853795b9e1d8226f24b535d068f294cf291a1fd852da07 | Python | 3,916 | 104 | import logging as logg
from typing import Union, Optional, Tuple, Collection, Sequence, Iterable
from anndata import AnnData
import numpy as np
from scipy.sparse import issparse, isspmatrix_csr, csr_matrix, spmatrix
from numpy.random.mtrand import RandomState
import scanpy
def run_pca(
data: Union[AnnData, np.nda... |
d79c5250eefc997ac19c62e29a4745bc29c78e3fc1793ebe4f7f65fdadf40f01 | Python | 3,916 | 118 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Test objects and function in the module tfep.nn.flow.pca.
"""
# ==============================================... |
dec500a8eb08e0ccb19b6aa6c85d01afe066bd2d87c92f1a4e4e4673bedbf9ba | Python | 3,916 | 98 | '''
@saulzhang
The implementation code of test the testing dataset in the paper
"Predicting Future Frames using Retrospective Cycle GAN" with Pytorch
date: Nov,12,2019
'''
import argparse
import os
import numpy as np
import math
import itertools
import datetime
import time
import torchvision.transforms as transforms
i... |
99aa2a63af553fee028a0e8595e800f5142024f96b9fb61ad07fb76636b9f8ed | Python | 3,917 | 105 | import torch.nn as nn
try:
from torchvision.models.utils import load_state_dict_from_url
except:
from torch.hub import load_state_dict_from_url
from .custom_modules import FakeReLUM
__all__ = ['AlexNet', 'alexnet']
model_urls = {
'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
}... |
b777ade3a84044b0b98ed772d091ac63e5d6d9dc842bd19e1eca267719b2ecba | Python | 3,917 | 113 | """Layer-to-layer per-unit receptive-field extension tests."""
from __future__ import annotations
from collections.abc import Iterator
import pytest
import torch
from support.rf_isolation import preserved_rf_registry
from torch import nn
import torchlens as tl
from torchlens.receptive_field import _query, _rules
fr... |
824aabb12303c1f3c051e669df8a6926f5b8c6f5ee1904c12faab1a55e0997bf | Python | 3,918 | 96 | """F29: schema files + lockstep, both directions (agent memo 3.9 item 24).
Direction 1: every shipped schema file parses as Draft 2020-12 and is served
by the schema tool. Direction 2: every LIVE tool result validates against its
declared schema document. The registry's output schema ids and the shipped
file index can... |
af57236c74d393d3e4ffc2e234ae4c3f7d51f2c9eff2ba71b3a10efd2243a240 | Python | 3,918 | 123 | """Phase 6 capture-unification storage-axis tests."""
from __future__ import annotations
from pathlib import Path
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens._training_validation import TrainingModeConfigError
from torchlens.fastlog import CaptureSpec, PredicateError, Recor... |
f6aa7fc6686fcd42cf0d1d4a6f8a9157b2a4031ab09374f9db415613fe10a2e6 | Python | 3,919 | 80 | """Prepare the 20BN-something-something Dataset V2
==================================================
`Something-something-v2 <https://20bn.com/datasets/something-something>`_ is an action recognition dataset
of realistic action videos, collected from YouTube. With 220,847 short trimmed videos
from 174 action categor... |
3b62a5a3e609d59512e092394dd633fbae07b7898fdb0a130858987b98d2d1ea | Python | 3,920 | 127 | """Mode object."""
from specparam.modes.paramdef import ParamDefinition
from specparam.reports.strings import gen_mode_str
from specparam.utils.checks import check_input_options
###################################################################################################
########################################... |
c8ea07e7562b50fcb5c3d512234c9b6fd17c76c281e8112bc5b77dc9ac8ec908 | Python | 3,921 | 115 | import logging
import time
import paramiko
from pulsar.managers.util.retry import RetryActionExecutor
from galaxy.util import (
smart_str,
string_as_bool,
unicodify,
)
from galaxy.util.bunch import Bunch
from .local import LocalShell
log = logging.getLogger(__name__)
logging.getLogger("paramiko").setLeve... |
67d58cef93a6456d48bd74d2ef0e1325f1fed9a660163fe79a6a29b1cb592c68 | Python | 3,922 | 121 | """
Generate validation data from the transformed and reference point inside a .csv file
"""
from os.path import join, dirname, abspath
import plotly.express as px
import pandas as pd
from math import sqrt
import json
import csv
import sys
def main(argv):
"""Get the euclidean distance between the point of the ref... |
707b2d8031e7abc3b63beef7858ea86ad1110a1d9d6dcdf05945d286b9c56178 | Python | 3,922 | 116 | import numpy as np
from scipy import signal
import yaml
import datetime
import inspect
import os
import shutil
from typing import List, Tuple, Union, Any
__all__ = ['PyFiber', 'Intervals', 'Events']
Intervals = List[Tuple[float,float]]
Events = np.ndarray
class PyFiber:
"""Parent object for Behavioral, Fiber a... |
8fa6c54e97c506ecfd18f18c1809e3c93577dc116eb74bb07f370b8c7b379442 | Python | 3,923 | 109 | #!/usr/bin/env python
#=========================================================================
#
# Copyright NumFOCUS
#
# 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://... |
a6f9f3f2b52087dcb47b8d605ad2d70a683ca6f622fcd275e85a7e30ad9f4df5 | Python | 3,923 | 135 | """Gradient streaming statistics tests."""
from __future__ import annotations
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.intervention.errors import MultiMatchWarning
class TinyClassifier(nn.Module):
"""Small model for gradient aggregation tests."""
def __init__(s... |
a7ffeb1711f4664457ef7dc77d0dc64f9baaa83007a2803ca79d4123aab3e320 | Python | 3,923 | 130 | import os
import random
import h5py
import pandas as pd
import scipy as sp
import torch
def setup_seed(seed):
torch.cuda.cudnn_enabled = False
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manu... |
092aab91269a9816b0029894a8f2c3de70dafbd6a37daeb619ece284aba8eb7a | Python | 3,924 | 110 | """Parameter reference table for Module Inspector - code to symbol mapping."""
from __future__ import annotations
__all__ = ["get_parameter_reference_html"]
def get_parameter_reference_html() -> str:
"""Generate HTML parameter reference table with symbols, units, and descriptions.
Returns a searchable, sor... |
606d841a97126e249961c3d253b9b2e49cdcd89f32de56517faeabc6a1955a3a | Python | 3,924 | 106 | from typing import Any, Generator
from functools import lru_cache
from mirp.settings.feature_parameters import FeatureExtractionSettingsClass
from mirp._features.base_feature import Feature
from mirp._images.generic_image import GenericImage
from mirp._masks.base_mask import BaseMask
def get_discretisation_parameter... |
10106402c2b840192fb4b70936fc82baf271cb259427cd70c3c4e25f47688265 | Python | 3,925 | 100 | import os
import importlib.resources
from PyQt6 import QtCore, QtGui, QtWidgets
from matplotlib.backends.backend_qtagg import NavigationToolbar2QT
from matplotlib import cbook
# TODO:
# - use the capabilities of the new toolbars?
class NavigationToolbarCustom(NavigationToolbar2QT):
"""A custom toolbar that all... |
b623dc3357809791cdfe5d579d30adda5ad76acab5e26a40d34603efc2a4922a | Python | 3,927 | 145 | # -*- coding: utf-8 -*-
"""
tensorflow 2.1.0
tfrecordへの書き出しとロードについて簡単にまとめたファイル
"""
import tensorflow as tf
import os
import re
import glob
import json
from collections import OrderedDict
import numpy as np
from Bio import SeqIO
import sequence_tokenizer as seq_tk
## tf.Example と互換のある tf.train.Fe... |
dad64fc66ef486b3358e362e87b8a15ad9a6520c18ee27090596bcea943b4064 | Python | 3,927 | 130 | # %%
'''
Uses FD to exclude participants.
'''
import numpy as np
import json
import pandas as pd
import matplotlib.pyplot as plt
import pingouin as pg
import seaborn as sns
from functions.data_helpers import get_phenotype, get_computer
palette = ['gray', 'cornflowerblue', 'orange']
palette2 = ['gray', 'orange']
fig_di... |
c87271d88d41f25c6fabc0bacfc5a50dc5a05a2a3353a6c6e32b2e9a100801c9 | Python | 3,928 | 109 | import os
import random
import torch
from torch.utils.data.dataloader import DataLoader
# from torchsummary import summary
from hn_cnn.cnn import MODELS
from hn_cnn.constants import *
from hn_cnn.data_augmentation import get_training_augmentation, TRANSFORM_TO_TENSOR
from hn_cnn.fit import predict
from hn_cnn.parse_d... |
dfa7a2890be5fa10269ef65d58c0b55d5c63a083632d56005e8837f527fd0282 | Python | 3,928 | 84 | import sys
from robustness.datasets import jsinV3
from robustness.model_utils import make_and_restore_model
from model_analysis_folders.all_model_info import JSIN_PATH, MODEL_BASE_PATH
import os
def build_net(include_rep_in_model=True,
use_normalization_for_audio_rep=True,
ds_kwargs={}, ... |
7d68c2f8e5af501018f981bfb5fd79d157a8a2e2d5e660f809e9a628c126b7d3 | Python | 3,929 | 142 | #!/usr/bin/env python
"""
Input: Molecules in SDF, SMILES ...
Output: Moleculs filtered with specified substructures.
Copyright 2013, Bjoern Gruening and Xavier Lucas
"""
import argparse
import multiprocessing
import os
import shutil
import subprocess
import sys
import tempfile
from openbabel import openba... |
e14b86fe04f12754a6696d3b200ccc3de3ad5b017ee264c410282ccd6cfded2c | Python | 3,930 | 120 | import pathlib
import numpy as np
import pytest
from impose import flblend
data_path = pathlib.Path(__file__).parent / "data"
def test_flb_shape():
fb = flblend.FlBlend()
image = np.linspace(0, 1, 1000).reshape(10, 100)
fb.add_image(image, hue=150)
assert fb.shape == (10, 100)
def test_flb_blend... |
06f7523e5b6ed9b27cdac2f61dd9bc360dd4062df5d3eb10ff378a147608c397 | Python | 3,931 | 70 | """General-purpose test script for image-to-image translation.
Once you have trained your model with train.py, you can use this script to test the model.
It will load a saved model from --checkpoints_dir and save the results to --results_dir.
It first creates model and dataset given the option. It will hard-code some... |
36c574081a12e34f540bcdefdc265b5af2411fa0d7c57879990b636ef2842100 | Python | 3,931 | 96 | """A01 semantic-attention slice: GPT-2 SDPA per-head facets (reconstructed).
Fusedness is detected from the CAPTURED GRAPH (the real SDPA op), never from
class names -- the same assertions hold on transformers 4.x (per-backend
subclass) and 5.x (unified class). A plain capture serves actionable
needs_capture absences;... |
41b5f177542e3f5672d2bfdb2baf542f3e9ba8ca07a4f55b20bf8806023f1f80 | Python | 3,931 | 106 | # Run test with:
# torchrun --no_python --nproc_per_node=8 pytest -q -s tests/modules/test_embedding_parallel.py
import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
from apex.transformer import parallel_state
from einops import rearrange
from flash_attn.modules.embedding import GPT2Embeddi... |
51837687f97d6f2e8c3d7359ad13ddb5403604f22e72fceef4e14c1be1097d63 | Python | 3,931 | 88 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from typing import Any
import cv2
import numpy as np
from ultralytics.solutions.solutions import BaseSolution, SolutionAnnotator, SolutionResults
from ultralytics.utils.plotting import colors
class TrackZone(BaseSolution):
"""A class to manage... |
29ed56b6ab80b5f456c32cd0ca10f1643bd34976eadc4c0533e52d968bab264c | Python | 3,934 | 118 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Newselection(_BaseLayoutHierarchyType):
_parent_path_str = "layout"
_pa... |
716af4715017b7dc6df7c1cf27e5dadb3b7e8390439060b84e5d4d5434b121b2 | Python | 3,935 | 144 | """
Plot partial correlation between previous stimulus weights and individual
performance in each environment after factoring out the correlation of
both variables with perceptual sensitivity
"""
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pingouin as pg
import seab... |
28d3f62c3bb85d7ca359899f6e731b86f89fda3d7d7c05ae5caa9d18ccdb173a | Python | 3,936 | 118 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import numpy as np
from .. import fmtxt
from .. import plot
from .._data_obj import cellname
from .._text import ms
from ..fmtxt import Section
from ._source import cluster_timecourse
def sensor_results(res, ds, color):
report = Section("Results")
if r... |
7da20a4c611800c2e431b75c6aca91d84f67220f36d7fe444bb8a8adb33123e9 | Python | 3,936 | 158 | """
Plots baseline beta lateralization contra- vs. ipsilateral to
previous button-press separately for each environment.
"""
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from stats import permutation_test_two_tailed
from stats.stars import stars
matpl... |
9170a326121d9f95be057d4488fe0f6b642a9bbff68b2bea34d7071db918df02 | Python | 3,936 | 126 | from flask_login import login_user, login_required, logout_user, current_user
from werkzeug.security import generate_password_hash, check_password_hash
from flask_restplus import Namespace, Resource, reqparse
from database import UserModel
from config import Config
from ..util.query_util import fix_ids
import logging... |
a58381522f6a35c34cfeec84cc146dbc039905de1c421decae5d1a7c1bbd431b | Python | 3,938 | 130 | """Option-effectiveness witnesses (M(oracles) item 11; F36 oracle wave 1).
For each witnessed option: BOTH arms execute and the observable DIFFERS --
an option whose flip changes nothing is a silent no-op (the stop_after
class). The witness helper itself is red-capability-proven with a planted
no-op option (a dead che... |
ad366ba0f17f01ccd55f12fb060e8deb2ee6754dc8da360dd4aacf33785f06d6 | Python | 3,938 | 111 | # -*- coding: utf-8 -*-
import os
import glob
from Bio.SeqIO import parse
import pandas as pd
import argparse
from utils import create_dict, arrange_predict, separate_fasta, merge_pred_table, remove_files, clean_len_exaa
from preprocess import run_preprocess
from predict import run_predict
def get_parser():
par... |
b79973360d489fc2cfe9b29e4e7c9e322cf0aa3bf6ec919b27aca53dd1af6588 | Python | 3,939 | 135 | # Copied from https://github.com/mlcommons/training_results_v1.1/blob/main/NVIDIA/benchmarks/bert/implementations/pytorch/model/layers/activations.py
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
# 1/sqrt(2*pi)-> 0.3989423
# 1/sqrt(2) -> 0.70710678
# sqrt(2/pi) -> 0.79788456
# thi... |
e136de4036c300be657f5b992094fc9d244765b44c093d6f495ff3710657e44f | Python | 3,939 | 118 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class YAxis(_BaseLayoutHierarchyType):
_parent_path_str = "layout.xaxis.rangeslid... |
50bbf788fda10e52e76d3505c82a6f93a51633854ed14aabb2e63a7f0b16f1c4 | Python | 3,940 | 102 | """Runnable replay leaves every global its ambient context touches unchanged.
``trace.run()`` applies the capture's recorded ambient context (matmul
precision, deterministic mode, cuDNN and SDPA switches, ...) for the run and
must hand the caller back exactly the globals it found, on success and on
error. On torch >= ... |
77ecd42eead29476285ec8b0371d84a217fcfddacb0efa56d30ad18fd817d6d5 | Python | 3,941 | 124 | import torch
from torch import nn
from torch.nn import functional as F
class UNet(nn.Module):
"""
Paper: `U-Net: Convolutional Networks for Biomedical Image Segmentation
<https://arxiv.org/abs/1505.04597>`_
Paper authors: Olaf Ronneberger, Philipp Fischer, Thomas Brox
Implemented by:
- ... |
b778c9a5bf92470dec608d030843ba6d6883f74a462ab42b554c90ac13c8a4d6 | Python | 3,943 | 104 | """Regression tests for nested trace refusal."""
import pytest
import torch
from torch import nn
import torchlens as tl
class _NestedTraceModel(nn.Module):
"""Module that attempts to start a nested TorchLens trace."""
def __init__(self) -> None:
"""Initialize the inner module used by the nested tra... |
4a772b5b3c89707de768aac5998925aa46a62399f75dd20225501538d54bc300 | Python | 3,945 | 133 | # --- 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 Marker(_BaseTraceHierarchyType):
_parent_path_str = "pie"
_path_str = "pi... |
5ced3e0bebdb30e925f12ead7b39d2cae92cb6189667c039da77057960b46a21 | Python | 3,945 | 122 | #!/usr/bin/env python
# emulator.py - a simple BCI system emulator
# Copyright (C) 2007-2011 Bastian Venthur
#
# 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 2 of the License, ... |
8b9adf3a66e5c494a75624e315a65c74ff2e8cab8a460dfcd940a700d06116da | Python | 3,946 | 97 | """
Code here relates to modification and de-novo creation of ABF files.
Files are saved as ABF1 format ABFs, which are easy to create because their
headers are simpler than ABF2 files.
Many values (e.g., epoch waveform table) are left blank, so when they are read
by an ABF reader their values may not make sense (es... |
a80b0d1dac056f0bfd15483665afb14a53b5f5c70fb4bb0c06f95ec12bd998b5 | Python | 3,946 | 139 | """Test functions for specparam.sim.params."""
from pytest import raises
from numpy import array_equal
from specparam.modutils.errors import InconsistentDataError
from specparam.sim.params import *
###################################################################################################
#################... |
e9d121e94d864632c3a1fa027b99ba3a0bd1def6e995239c91c1779fd360d2f3 | Python | 3,946 | 135 | # --- 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 Line(_BaseTraceHierarchyType):
_parent_path_str = "scatterpolargl"
_path_... |
37133fa57ecfd6ba94fa47c0eb2e5cd52e205c798b89d6553a705edcc36ac0ef | Python | 3,947 | 99 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import seaborn as sns
# Plot aesthetics.
plt.style.use('seaborn-deep')
plt.rcParams['figure.dpi'] = 200
plt.rcParams['savefig.dpi'] = 300
plt.rcParams['lines.linewidth'] = 1.0
plt.rcParams['axes.grid'] = True
plt.rcParams['... |
0b3719d4bc55fa623f6eec73e8b713782cb7879a1f30b7cebb61d41f0352322f | Python | 3,948 | 85 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""""tests for structure.py"""
import unittest
import numpy as np
from scipy import sparse
from sknetwork.data import star_wars, house, cyclic_digraph, cyclic_graph, linear_digraph, linear_graph
from sknetwork.topology import get_connected_components, get_largest_connecte... |
336f292d635b40168ed0bf84de89fd6358082b317ace6c6885733980e102bb12 | Python | 3,948 | 130 | #!/usr/bin/env python
"""
classify.py is an out-of-the-box image classifer callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
"""
import numpy as np
import os
import sys
import argparse
import glob
import time
import caffe
def main(argv):
pycaffe_dir = os.path.... |
75b5a10f18e596dcb208d02b270831c1fdc27a08e102c3caa1e90ad4bccc7e14 | Python | 3,948 | 127 | # General imports
import argparse
import os
import sys
import torch
import numpy as np
import pandas as pd
from copy import deepcopy
import pytorch_lightning
from itertools import product
# EUGENe imports and settings
import eugene as eu
from eugene import dataload as dl
from eugene import models, train, evaluate
fro... |
7e7aff205113e935fb1368498bd590c16cc8ea6b76ce2bdba97ec12103977719 | Python | 3,948 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "cone.colorbar"
_path_... |
a3909b4d55d8ed8d7f4f2344324a7b3f6bdad872cb22afcc8273b167b3c64268 | Python | 3,948 | 109 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created in July 2022
@author: Simon Delarue <sdelarue@enst.fr>
"""
from typing import Optional, Union
import numpy as np
from sknetwork.gnn.activation import BaseActivation, get_activation
from sknetwork.gnn.loss import BaseLoss, get_loss
class BaseLayer:
"""Ba... |
6350d0eeb3c78250757d7d999179a48092f2e179b0c5eb036fb75c51a1514e77 | Python | 3,949 | 104 | import pandas as pd
import numpy as np
from skmob import TrajDataFrame
from skmob.utils import constants
from skmob.preprocessing import filtering
class TestFiltering:
def setup_method(self):
latitude = constants.LATITUDE
longitude = constants.LONGITUDE
date_time = constants.DATETIME
... |
79703f347aec571641d6d9e3b50f84dae71648e9a1844f52d9efd0b1f6bfd6e7 | Python | 3,950 | 105 | import numpy as np
import tensorflow as tf
class BinnedUniformDecayInitializer(tf.keras.initializers.Initializer):
def __init__(self, distribution_type, t_decay, bin_step_size=None, fastest_t_decay=0.015, longest_t_decay=0.48, show_distribution=False):
self.show_distribution = show_distribution
s... |
b20afa3a523deab6e6a78d79bb3a6580d68476e2d7bf319f2c1fa3db758fd9c1 | Python | 3,950 | 122 | """
Condor helper utilities.
"""
from subprocess import (
CalledProcessError,
check_call,
)
from galaxy.util import (
commands,
unicodify,
)
from ..external import parse_external_id
DEFAULT_QUERY_CLASSAD = dict(
universe="vanilla",
getenv="true",
notification="NEVER",
)
PROBLEM_PARSING_E... |
aa72f291d2e0d8c052ae8c02f44dbb9b6311ed9549c106ae6e041aff0be85c7e | Python | 3,951 | 96 | """Preview-backend replay-oracle comparison drift tests (R13-8b).
The tf/mlx/paddle validation oracles each own a payload comparison helper.
These pure-numpy tests pin the cross-backend doctrine without requiring the
preview frameworks: identical NaN patterns are agreement (``equal_nan=True``,
matching torch's ``tenso... |
ac55ca0c45ec1e8ddbbfb10e3861ad152c54c32b96e8d532372e33f915d1072e | Python | 3,952 | 117 | """Fixtures shared by the quantization tests.
`calibrate_layer` is the only place in the tests that constructs a
`Calibrator`, so a change to how a calibration mode quantizes one layer
is one edit here. `tiny_calibration_model` is the model the calibration
tests run `Model.quantize` on.
"""
import numpy as np
from k... |
2206ba6a76e6382babec6a87df2bd35241734551b03d122b62a52dd4e54d1be2 | Python | 3,953 | 127 | import numpy as np
from numpy.random import default_rng, SeedSequence
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from tqdm import tqdm
import multiprocessing
from multiprocessing import Pool, freeze_support, current_process, RLock
from functools import partial
import pathlib
from causal_... |
2d6c3060d7cc27e68a8fde0d72169139634cdbbd4a907830bbc86a2af29e35ce | Python | 3,953 | 154 | """
MetaData class
This file is a part of BdPy
"""
import numpy as np
class MetaData(object):
"""
MetaData class
'MetaData' is a list of dictionaries. Each element has three keys: 'key',
'value', and 'description'.
"""
def __init__(self, key=None, value=None, description=None):
i... |
4b2776d678fe6edb262d6124da025562785d913fa9be7d08d5e779ffd5ad5323 | Python | 3,953 | 104 | # Run test with:
# torchrun --no_python --nproc_per_node=2 pytest -q -s tests/losses/test_cross_entropy_parallel.py
import math
import pytest
import torch
from apex.transformer import parallel_state, tensor_parallel
from flash_attn.losses.cross_entropy import CrossEntropyLoss
is_sm8x = torch.cuda.get_device_capabili... |
8e6ab65066206c60bac5231c5f23a43679f8c9202a9ba4ced4587beecedbedd3 | Python | 3,953 | 90 | #!/usr/bin/env python
# coding: utf-8
"""
Source-level RSA using a searchlight on fMRI data
-------------------------------------------------
This example demonstrates how to perform representational similarity analysis (RSA) on
volumetric fMRI data, using a searchlight approach.
In the searchlight approach, represe... |
a56c450a88f3e66ddf1aebb6deabe8e5d7570a38f9afbbe9d0942cb9f2506aa5 | Python | 3,953 | 138 | """Tests for the Phase 11.0 intervention ``.tlspec`` transitional writer."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import torch
from example_models import TinyReluAdd as _ReluModel
import torchlens as tl
from torchlens._io import TLSPEC_VERSION
from torchlens... |
5fd30d02ea569e9a95ff73e97191232effa66cf47049b4215583cc2f1139257a | Python | 3,954 | 132 | # --- 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 Projection(_BaseTraceHierarchyType):
_parent_path_str = "scatter3d"
_path... |
e63c51deb02b6d19038be4eded5d62d7f1860be9755a7aa397c3ee1a5c9eeeff | Python | 3,954 | 118 | """Tests for ``Trace.input_preprocessor`` provenance."""
from __future__ import annotations
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.data_classes.trace import ResolvedPreprocessing
class _TinyModel(nn.Module):
"""Small model for summary provenance checks."""
de... |
7f6bc519ba7ea1c3b35abf74b2d2befddf321ccfd0be8bb5e8fcce303e3c161a | Python | 3,956 | 115 | import pandas as pd
import sys
from tqdm import tqdm
import argparse
import os
import time
from sqlalchemy import create_engine
def build_variants_table(
variant_fp,
db_url,
table):
"""Create a table of genotype.
genotype(snp, sample_id..)
Indexes:
"ix_genotype_snp" btree (s... |
12415a35b9a7ca51fde4e884b83f8b55288e37ac17d53187780fe65090dc8c3b | Python | 3,957 | 115 | """Regression tests for per-draw atomic-module sibling-count reuse."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.visualization import _render_nodes
class _SplitReuse(nn.Module)... |
b798cae7bea14c7d42f358e51998781fdc8fd5d96d5658e8d56aa0c79a0311ca | Python | 3,957 | 120 | # 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
import pytorch_li... |
2b756e7da88142082c5bac93b175457f030202d0c9e392a950b268e3f51dc809 | Python | 3,959 | 112 | import paddle
from paddle.io import Dataset
import numpy as np
class TrainDataset(Dataset):
def __init__(self, triples, params):
self.triples = triples
self.p = params
self.strategy = self.p.strategy
self.entities = np.arange(self.p.num_ent, dtype=np.int32)
def __len__(self):
... |
36d0c314c40a14c31df142027f2615385d0cf9be815c5a0638c564b3c295e04f | Python | 3,959 | 131 | import numpy as np
import tensorflow as tf
import random as python_random
import os
import tensorflow_datasets as tfds
from tensorflow.keras.models import load_model
from gradient_accumulator import GradientAccumulateModel
def normalize_img(image, label):
"""Normalizes images: `uint8` -> `float32`."""
return ... |
cef13f4cdb8c94dc4222e9087202482ce4ab92f6698845319137bacfcc5f7e00 | Python | 3,959 | 112 | import subprocess
import numpy as np
import os, sys, re
import pandas as pd
def getLongestORF(mRNA):
ORF_start = -1
ORF_end = -1
longestORF = 0
for startMatch in re.finditer('ATG',mRNA):
remaining = mRNA[startMatch.start():]
if re.search('TGA|TAG|TAA',remaining):
for... |
3e9371a94bb90b7d2a7b6d48a36c5bb7c6d8ae91a39a06f875033eb23f9ff3e8 | Python | 3,960 | 111 | """Utilities for finding Galaxy's configuration file.
This is for use by web framework code and scripts (e.g. scripts/galaxy_main.py).
"""
import os
from typing import (
NamedTuple,
)
from galaxy.util.properties import find_config_file
from galaxy.web_stack import get_app_kwds
DEFAULT_INI_APP = "main"
DEFAULT_C... |
a03bc44152be4b84ca5f9a93863d42f86bd5b039c91084904d2cb6f9f7ea7fe4 | Python | 3,960 | 110 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Base class to implement potential energy functions.
"""
# ====================================================... |
47eb3f4fc70b4e48787b52fff4eebb8c93ab87e2fe36eb659bcd9b1afec3b401 | Python | 3,961 | 101 | """
Predict tool usage to weigh the predicted tools
"""
import collections
import numpy as np
import utils
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.svm import SVR
class ToolPopularity:
def __init__(self):
""" Init method. """
def extract_t... |
670d1f8da670fb794197fe33536a89bcb8179fdc83248e29b5973a9cf3ca8c9a | Python | 3,961 | 108 | import torch
import math
class PenaltyBuilder(object):
"""Returns the Length and Coverage Penalty function for Beam Search.
Args:
length_pen (str): option name of length pen
cov_pen (str): option name of cov pen
Attributes:
has_cov_pen (bool): Whether coverage penalty is None (app... |
d0eb5b8dce9204372a16699b1039c9a9d7139515df1a2f6897ca3969f0ffa571 | Python | 3,961 | 98 | # validate cross correlations for a single set of mfov comparisons
# as dumped from mfov using the export_xcorr_comps_path hack.
import time
import tifffile
import dill
import os
import re
import numpy as np
#from rcc_xcorr.xcorr import BatchXCorr
from xcorr import BatchXCorr
#export_xcorr_comps_path = '/gpfs/soma_... |
0de287aee85fbbc1291fe64793ed572aec803ab50fe338e838d3650958d37503 | Python | 3,962 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "mesh3d.colorbar"
_pat... |
840c6536a6d078f18e66289df23a9554e26c5d7355d1dc751a5d1f35eb5dfa55 | Python | 3,962 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "volume.colorbar"
_pat... |
b7746104c18b67e516e4ff5bddfda06f79299877b1d3a88d7f647c99a051d227 | Python | 3,962 | 136 | # Copyright 2023 Blue Brain Project, EPFL.
# See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: Apache-2.0
import nmodl
from nmodl.dsl import ast, visitor
import pytest
def test_lookup_visitor(ch_ast):
lookup_visitor = visitor.AstLookupVisitor()
eqs = lookup_visitor.lookup(ch_ast, ast.A... |
47945e54c7421bfc5c263cce61cbef76d66724aff17d7c3f6352fc1d5a5460f8 | Python | 3,963 | 132 | from abc import ABC
from typing import Callable, Optional
import numpy as np
from pl_bolts.utils import _TORCHVISION_AVAILABLE
from pl_bolts.utils.warnings import warn_missing_pkg
if _TORCHVISION_AVAILABLE:
from torchvision.datasets import CIFAR10
else: # pragma: no cover
warn_missing_pkg("torchvision")
... |
65734b9f3ae94072be1ebc82fcccbff3a623b28b6ec3b3ff7669db1de6f62fa9 | Python | 3,963 | 114 | """
Integration tests for SchleyerGroup dataset imports.
Primary mode: import from raw data using the Schleyer lab format.
Fallback mode: when raw data is not available locally, verify that the
processed dataset(s) are present and loadable (no skip).
"""
from __future__ import annotations
from pathlib import Path
i... |
9cddfd0f68cd3a8c7daf986ef638f372d08f6767ceb276a22012bea96edefd6c | Python | 3,963 | 147 | import torch
import time
import torch.backends.cudnn as cudnn
import cv2
from utils import *
from model import *
from data_loader import *
from multiprocessing import Queue
import threading
from config import *
import argparse
import segmentation_models_pytorch as smp
cudnn.benchmark = True
# Ultrasound probe -> [fra... |
95e52dc0fc5fc21a9d179233e68ca01d30f071343b256dffbf21140e6eb30e9f | Python | 3,964 | 103 | import numpy as np
from fun_theta import fun_theta
from fun_dtheta import fun_dtheta
from fun_ddtheta import fun_ddtheta
def noiseless_obj_grad(P, Ui, x, r):
# calculate the objective value f, that is, ||Pi_x F(x)||_2^2
# and the gradient G of ||Pi_x F(x)||_2^2
#
# input variables
# P : p... |
e660aef479934d9a79eeae076c7c50b0e6451ac6245c37a80a33e6d794fadb3a | Python | 3,964 | 141 | """MelGAN generator for non-autoregressive waveform synthesis.
Kumar et al. (2019), "MelGAN: Generative Adversarial Networks for Conditional
Waveform Synthesis." The generator is a fully convolutional mel-to-waveform
network: a mel-spectrogram is projected to channels, repeatedly upsampled by
transposed convolutions,... |
831cf85368d8e3dc262a62fbfaa53323f92b130eae9ab0c84f3178e06d4932ad | Python | 3,965 | 114 | from __future__ import annotations
import json
from pathlib import Path
import pytest
from larvaworld.lib import reg, util
from larvaworld.portal.simulation.parameter_resolution import (
resolve_base_experiment_parameters,
)
from larvaworld.portal.simulation.single_experiment_app import (
_SingleExperimentCo... |
b90b3d0446c044e02df1e43b7b7ed05a9e30dd23c51593d8021018eabf4be136 | Python | 3,966 | 147 | import numpy as np
from numpy import testing as npt
from tns.astrocyte.point_cloud import PointCloud
def point_array():
return np.array([
[-10.0, -10.0, -10.0], # 0
[ -8.0, -8.0, -8.0], # 1
[ -6.0, -6.0, -6.0], # 2
[ -4.0, -4.0, -4.0], # 3
[ -2.0, -2.0, -2.0], # 4
... |
8aed6ae522d6a5705ecae4a3a5d0c7966887c80ffd35525123ed60c38b7266b2 | Python | 3,967 | 141 | """Tests for Phase 7 node overlays."""
from __future__ import annotations
from pathlib import Path
from typing import Any
import pytest
import torch
from torch import nn
import torchlens as tl
def _render_dot(log: tl.Trace, tmp_path: Path, **kwargs: Any) -> str:
"""Render a graph as DOT text for overlay asser... |
94f9b342eac4e188293752281b5a5726b55963978d48749ea40b25671ae8956d | Python | 3,967 | 97 |
#%%
import dataprocessing
from sklearn.metrics import accuracy_score,classification_report,confusion_matrix
import matplotlib.pyplot as plt
import seaborn as sn
import pandas as pd
import numpy as np
from datetime import datetime
import tensorflow as tf
import itertools
save_path_result = '../result'
... |
35dfeddaa9137bb4a500ad7d939cde63c7256dd2706476f9781c245cf08531e9 | Python | 3,968 | 130 | # 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
import torch
impo... |
737b885ac24e3b0087d0956dad2c21379a5294b26278ce2e426cadc6c5049939 | Python | 3,968 | 123 | import torch
from tqdm import tqdm
import csv
import pickle as pkl
from captum.attr import LayerIntegratedGradients, TokenReferenceBase
import numpy as np
import inspect
import os
from interpretability.utils import (
get_attentions_map_simple,
set_hook_to_get_attention_map,
load_sequences,
load_model_a... |
41acf7e91c36297412b887fc327b005ccb00606a0b235736641bdf4339ce7560 | Python | 3,969 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "surface.colorbar"
_pa... |
5c3022a09d44a263902b67e9f1d755f90703f3f01cad7013aa0811c34ffb668f | Python | 3,969 | 97 | from NICE import NICE
import argparse
from utils import *
import time
"""parsing and configuration"""
def parse_args():
desc = "Pytorch implementation of NICE-GAN"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--phase', type=str, default='train', help='[train / test]')
pars... |
836102d862edb0fb1939b8d1678abdc0ecf4805f8e63d628d250ec78fc6906fe | Python | 3,969 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "contour.colorbar"
_pa... |
c2637bbfa2ee55f1f5d48cd13db99c9587331fb44e24dbbcbb49d6e278c5cd15 | Python | 3,969 | 136 | # --- 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 Title(_BaseTraceHierarchyType):
_parent_path_str = "heatmap.colorbar"
_pa... |
f74c8a4eb5b5673c14e5fa07d25c9dfa15407f78aba7e77b35ca30da947581a3 | Python | 3,969 | 153 |
#!/usr/bin/env python
import glob, os, getopt, sys, tempfile
from doxy2swig import *
def usage():
print( "\ndoxyall.py [options] doxygen_xml_dir output.i|output_directory" )
print( "" )
print( " -h, --help This help message" )
print( " -j, --java Java style output" )
print( " ... |
1d69714d069c9916a21d606e1c3ea43f0691594add0ea950b0ec98b40a4d22f2 | Python | 3,970 | 139 | import math
import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
def init_weights(modules):
pass
class MeanShift(nn.Module):
def __init__(self, mean_rgb, sub):
super(MeanShift, self).__init__()
sign = -1 if sub else 1
r = mean_rgb[0] * si... |
612cbb57d02ac83dff2f181d16a5f41a24acadb5db163a4c25f64b7f9034e271 | Python | 3,970 | 105 | import cv2
import numpy as np
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
import logging
logger = logging.getLogger(__name__)
class OpenCVQImage(QtGui.QImage):
def __init__(self, opencv_bgr_img):
h, w, n_channels = opencv_bgr_img.shape
depth = opencv_bgr_img.dt... |
a349543250ded86546edb7da1a549b6fb7fa1951d6484c2fd98271dd31cb4cf7 | Python | 3,970 | 88 | """Data parallel task for Faster RCNN Model."""
from mxnet import autograd
from gluoncv.utils.parallel import Parallelizable
class ForwardBackwardTask(Parallelizable):
""" Faster R-CNN training task that can be scheduled concurrently using Parallel.
Parameters
----------
net : gluon.HybridBlock
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.