sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
fc91005dd348d8fbf842ffa419b01b7d7072a9cc8f92a71b7053743c99e5fc3a | Python | 4,286 | 132 | #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc.
#
# 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 a... |
a3d1acd204768bdef499df8ba3bca15bfbaaa64d1f7abae68289e914efd7e7e2 | Python | 4,289 | 128 | #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc.
#
# 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 a... |
a8f7e14d607fc0882e3cd256255c0f2a2408770f15643e186e9efd5d47a64430 | Python | 4,290 | 103 | from typing import Optional, Set
from ray._private.accelerators.accelerator import (
RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO_ENV_VAR,
AcceleratorManager,
)
from ray._private.accelerators.amd_gpu import AMDGPUAcceleratorManager
from ray._private.accelerators.apple_gpu import AppleGPUAcceleratorManager
from ray._priv... |
6adaba898e107de17fde6ea000f0af0544de1746292f2b7a4e370cc15635f730 | Python | 4,291 | 114 | #!/usr/bin/python
"""Plotting functions for modules."""
import logging
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
# For graphs
import textwrap
def plot_cell_umap(umat, c, plotname=None, ax=None, title=None,
s=1, width=8, axlab=False, cmap='viridis'):
"""Plot ... |
d637a09501c7652051ddcdaa65589ff9eae34588317bfe200bd196de4b813fae | Python | 4,291 | 104 | """Ridge regression with a row-permutation null (R SecAct ``.ridge_pureR``).
``beta = (X'X + lambda I)^-1 X' Y``; for each of ``nrand`` permutations the
rows (genes) of ``Y`` are shuffled with the SecAct permutation table, giving
``se = sd(beta_rand)``, ``zscore = (beta - mean(beta_rand)) / se`` and
``pvalue = (#{|bet... |
7377795dd631bfcaf611c6785435d57d03d9a9e39c6f55a2674d51140db0cb7b | Python | 4,292 | 144 | import argparse
import os
import shutil
import numpy as np
import cv2
import time
import pickle
from Xavier_SpeedTest_folder_function import imageProcessor
import os
def processResult(imgProcessor,img_folder,row_segmentation,output_dir,mask_output_dir,effectiveImgList=None):
isOutput = mask_output_dir != 'No... |
ff39541a4e78a7987a11ef5223ca1dce730ea4c229bb6d9515758922692912ec | Python | 4,292 | 101 | # Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
ded25321488732686154630e941b23da950a3e2c25aed8962920591466ef80f3 | Python | 4,295 | 138 | """Test LEF fingerprint"""
import unittest
from rdkit import Chem
from lefshift.fp import LEFFingerprint
class LEFFingerprintTests(unittest.TestCase):
"""Test LEF Fingerprint"""
def test_generate(self):
"""Test generation of LEF fingerprints"""
smiles = "S(=O)(=O)(N(CC)C)c1cncc(F)c1 Z118830... |
2ac79dc97d59fa1c7075a781ba94d3efb20ba725f22304c0b1bf0acb5b247629 | Python | 4,296 | 120 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 3 10:08:00 2022
Make an example figure comparing the predictions for multiple methods at
different noise levels
To reproduce the paper figure, run this 2x, changing the boolean in the if statement
@author: pbolan
"""
from utility_functions imp... |
0f9974d2ba6db627a74846d5e7fcb87f18a386b54ae98a89f8b972757697742e | Python | 4,297 | 172 | import base64
import io
import logging
import os
import subprocess
import sys
import tempfile
from math import ceil
from typing import List
import boto3
import ci.ray_ci.bazel_sharding as bazel_sharding
from ray_release.bazel import bazel_runfile
from ray_release.configs.global_config import init_global_config
from ... |
b4a5d0e21df2dee11e45ec52dd3b2b0ed21da9443f66a594138953b9c5cbcdc2 | Python | 4,298 | 169 | import numpy as np
import pandas as pd
import pytest
import torch
import torchvision.transforms.functional as tf
from torchvision import transforms
from aisegcell.utils.datamodule import Dataset, Dataset_predict, Dataset_test
@pytest.fixture(scope="session")
def csv_file(tmp_path_factory):
"""
Create tempora... |
e039187a221409fd3b32abc4b2f90518d2f72e0825fc32e24c3e1490def1455a | Python | 4,298 | 118 | from typing import Any, Dict, List, Optional
import aiohttp.web
from ray._private.ray_constants import RAY_DASHBOARD_REDACT_RUNTIME_ENV
from ray._private.runtime_env.redaction import ( # noqa: F401
REDACTED_PLACEHOLDER,
redact_runtime_env,
redact_serialized_runtime_env,
)
from ray.dashboard.optional_util... |
56000cc40687bff9600fcc7f2d974f353868cc9aa156da0b4fe4abd3e4c0f251 | Python | 4,301 | 126 | import logging
import requests
from agent.data.entities.config import ROOT_LOGGER_ID
from agent.data.sql.sql_mgmt import get_connection, execute_read_query
logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.DEBUG)
logger = logging.getLogger(ROOT_LOGGER_ID)
logger.setLevel(logging.DEBUG)
KG_DATA... |
96609f43cc9b2922947ab7d8bb9d2184d00ebf73946f0d54f7f759582147bab3 | Python | 4,301 | 124 | import logging
import os
import subprocess
import sys
import uuid
from contextlib import contextmanager
import pytest
from ray.job_submission import JobStatus, JobSubmissionClient
logger = logging.getLogger(__name__)
@contextmanager
def conda_env(env_name):
# Set env name for shell script
os.environ["JOB_C... |
b6fb08fafe7ca9f25a338c30ba554c94a14d39b707feea7dc18d672d34a0e8b5 | Python | 4,303 | 122 | import numpy as np
from scipy.sparse import issparse
from sklearn.linear_model import Lasso
from sklearn.metrics.pairwise import cosine_similarity
def v_delta_regress_score(X, V, nbrs, alpha=1.0):
P = np.zeros((X.shape[0], X.shape[0]))
for i, x in enumerate(X):
v = V[i]
idx = nbrs[i]
... |
7a9718ac505d7608d1a5b1c04288cfed398d77b2f5d9903e1db67504dde3a2b1 | Python | 4,305 | 103 | import os
import cv2
import numpy as np
import torch
# from https://github.com/ultralytics/yolov5
def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleFill=False, scaleup=True, stride=32):
# Resize and pad image while meeting stride-multiple constraints
shape = im.shape[:2] # curre... |
e182ebe59bfdd68e2c601a3393df69fe7ecd72d46c0676885daeb30b82a2c156 | Python | 4,306 | 92 | #!/usr/bin/env python
import numpy as np
import tensorflow as tf
def target_list_to_sparse_tensor(targetList):
'''make tensorflow SparseTensor from list of targets, with each element
in the list being a list or array with the values of the target sequence
(e.g., the integer values of a character map for an A... |
1d1a4044c293dd596a5161502fcf067cf3b664cd424f5606aceac3fdb30949a8 | Python | 4,307 | 83 | # Copyright 2021 Division of Medical Image Computing, German Cancer Research Center (DKFZ)
# and Applied Computer Vision Lab, Helmholtz Imaging Platform
#
# 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 L... |
a3563119d0ccda0e7ba0ddd6af33942abe120024422cb9ff8083f0aa619b13bb | Python | 4,307 | 121 | #!/usr/bin/env python3
"""UMAP plotting - grid of modules."""
import logging
import numpy as np
from matplotlib import pyplot as plt
def _plot_cell_umap(umat, c, plotname=None, ax=None, title=None,
s=1, width=8, axlab=False, cmap='viridis'):
"""Plot single umap with given scores as colors."""
... |
0654cf4a4e8ce30228977527835b1873b73eb87970f7726775c70035fe458680 | Python | 4,309 | 146 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Merge variants that were linked by per-sample bedtools merge
"""
import argparse
import sys
from collections import deque
import numpy as np
from scipy import sparse
from scipy.sparse import csgraph
import pysam
import svtk.utils as svu
def samples_overlap(recordA... |
572c02d2fac6cf83c24c045ba68d4816abcefb94329fd28ee510e62200583a63 | Python | 4,309 | 143 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""RPU configurations presets used for the composer interface."""
# pylint: disable=too-many-instance-attributes
from dataclasses import dataclass, field
from ... |
b96dc283a5b0d80bad362aecb201b2b9949062c2695dfb8aab280ff758f7ed69 | Python | 4,313 | 127 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
74e1f18de318265b01e14be3a67e07a9ee5d75d8ea02bd3c17c288151c556df3 | Python | 4,314 | 109 |
print("Loading modules")
import argparse
import gzip
import pandas as pd
import math
import subprocess
def parse_specific_peaks(file_object):
columns = ['chr', 'start', 'stop']
specific_peaks = []
for line in file_object:
entries = line.strip().split('\t')
entry_dict = dict(zip(columns,... |
990e51eb9596ba2b39437ce86616778abc53ee8dcf3a1b8f661a52452bcd08a5 | Python | 4,314 | 77 | import math
import torch
import pytest
from einops import rearrange
from cauchy import cauchy_mult_torch, cauchy_mult_keops, cauchy_mult
def generate_data(batch_size, N, L, symmetric=True, device='cuda'):
if not symmetric:
v = torch.randn(batch_size, N, dtype=torch.complex64, device=device, requires_gr... |
755749c2cea41a8b538b0af9e86cc787c0fe8311253ee2c685c0378e1d991082 | Python | 4,315 | 131 | import logging
import os
import sys
import pytest
from ray.autoscaler.v2.event_logger import AutoscalerEventLogger
from ray.autoscaler.v2.tests.util import MockEventLogger
from ray.autoscaler.v2.utils import ResourceRequestUtil
from ray.core.generated.autoscaler_pb2 import (
ClusterResourceConstraint,
GangRes... |
f10f265dc1ead923f75cd9916a44cf2279210a5f7c594865be39ff617ce64103 | Python | 4,315 | 111 | import numpy as np
import mrcfile
def normalize(x, percentile = True, pmin=4.0, pmax=96.0, axis=None, clip=False, eps=1e-20):
"""Percentile-based image normalization."""
if percentile:
mi = np.percentile(x,pmin,axis=axis,keepdims=True)
ma = np.percentile(x,pmax,axis=axis,keepdims=True)
... |
13e9ae2e135930f86ba3904a478be72dcde0cf03e0a2e6724bfee249c18ba09d | Python | 4,317 | 101 | # Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
9bb9469cb4d4e006ad4e515789434a8b4cdfbeb5c18609d2ec3712a393426d52 | Python | 4,321 | 132 | import warnings
import random
from neuron_morphology.morphology import Morphology
from neuron_morphology.constants import (
SOMA, AXON, APICAL_DENDRITE, BASAL_DENDRITE)
class MorphologyBuilder:
@property
def next_id(self):
result = self._id
self._id += 1
return result
... |
263d357e4f5ae9c4a27da6589c051c17d6c516d341fee7fd201c081cbff3003a | Python | 4,323 | 74 | """Historical probabilities and explicit runtime mode must survive archiving."""
import argparse
import json
from pathlib import Path
import sys
import tempfile
import unittest
import numpy as np
import tensorflow as tf
import keras
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT));sys.path.insert(0... |
cbea6370a4f25b87bf722bc3e505b5e116ea3dc59ee45b385f1de38ad992ed6f | Python | 4,323 | 122 | import numpy as np
import tensorflow.keras as keras
import os
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import *
from tensorflow.keras import backend as K
import tensorflow as tf
import pdb
os.environ['TF_XLA_FLAGS'] = '--tf_xla_enable_xla_devices'
gpus = tf.config.experimental.... |
fc0e8c232146660add4a2322a2b79d4e0c93b71d9f80885d720ae33921ad5dba | Python | 4,325 | 158 | from __future__ import absolute_import, division, print_function
from typing import Any
from ray import Language
from ray._raylet import CppFunctionDescriptor, JavaFunctionDescriptor
from ray.util.annotations import PublicAPI
__all__ = [
"java_function",
"java_actor_class",
"cpp_function",
]
@PublicAPI... |
4e85f9e54d0b31efbadcb947adc4314f423aea2e61c4874379d8dffefc948043 | Python | 4,326 | 128 | #!/usr/bin/env python
"""A simple speech classifer AND autoencoder
1st step : classify+encode the spectogram of 10 spoken digits into one-hot-vector + 'flavor'-vector of size 10
The 'flavor' vector is meant to hold voice characteristics orthogonal to the 'number' information: gender, speed, pitch, ...
INPUT: spectogr... |
6bd665bc24d6a2793aa7ba0842eaa0e4f57b9152ee7259b6c8cfcba000738bdb | Python | 4,328 | 122 | """
From https://raw.githubusercontent.com/arneschneuing/DiffSBDD/
"""
import torch
import numpy as np
import src.datamodules.components.edm.constants as edm_constants
from typing import Any, Dict, List, Tuple, Union
from torchtyping import TensorType, patch_typeguard
from typeguard import typechecked
from src.ut... |
8c8bb428e55ef50ce3fa9cef24303b39dcd10ffbf6678e3911f35fec96af65e3 | Python | 4,331 | 196 | """Contains shared fixtures, hooks, etc."""
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.datasets import make_regression
from sklearn.preprocessing import StandardScaler
import torch
from torch import nn
F = nn.functional
INFERENCE_METHODS = ['predict', 'predict_prob... |
2f653017cea69c300aec75c57c9f7ac423e01f814ef4c2b0a001ba2c07e2a17f | Python | 4,332 | 92 | from typing import List, Dict, Tuple, Any
import numpy as np
from lib.data_utils.matched_cells_struct import OrderedMatchedCellsStruct
from lib.data_utils.interaction_graph import InteractionGraph
from lib.data_utils.interaction_hashable import CellInteraction
class AllInteractionsOrdering:
'''
Data structu... |
33f2258ad008b3ec9804445a315d2a40ea392d3f9c4b32962a6c107fdf4e00c8 | Python | 4,332 | 131 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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... |
93f248fe7578343bab222f95ce5bf5a5461cfb2d29c65620f93856c9cfeb6c92 | Python | 4,332 | 115 | import logging
from typing import Callable, Optional, Set
default_logger = logging.getLogger(__name__)
DEFAULT_MAX_URI_CACHE_SIZE_BYTES = (1024**3) * 10 # 10 GB
class URICache:
"""Caches URIs up to a specified total size limit.
URIs are represented by strings. Each URI has an associated size on disk.
... |
9cda7aaa1e0b1501d8e45ad7aa2ab4a21a935b3844944e4332639a51453a2217 | Python | 4,332 | 107 | import logging
import aiohttp.web
import ray
import ray.dashboard.optional_utils as dashboard_optional_utils
import ray.dashboard.utils as dashboard_utils
from ray.core.generated import (
events_event_aggregator_service_pb2,
gcs_service_pb2,
)
from ray.dashboard.modules.task_events import task_event_query
fro... |
c7e6a5a2734329ec6298eb7cdb143c7aa271421cb905800b2ecd620776f6ff86 | Python | 4,332 | 162 | # flake8: noqa
# __ft_initial_run_start__
import json
import os
import tempfile
from ray import tune
def trainable(config):
# Checkpoint loading
checkpoint = tune.get_checkpoint()
start = 1
if checkpoint:
with checkpoint.as_directory() as checkpoint_dir:
with open(os.path.join(ch... |
d754c0a72770cf3ee649e12770dda18047d8e42d2cc38301bf742ee50bedd765 | Python | 4,333 | 154 | import PIL.Image
import numpy as np
import cv2
import json
import os
import argparse
import shutil
class IMAGE:
pass
class TILE:
pass
class BBOX:
pass
class ImageMask2Tiles():
def __init__(self,imgShape,tileSize):
self.imgShape = imgShape
self.tileSize = tileSize
self.ho... |
1ff3fd8cf32c1ba7b5a05899edb5bfc181ee44e1acd726dec25506f144cb958c | Python | 4,334 | 151 | import cupy as cp
import cupyx as cpx
import numpy as np
import matplotlib.pyplot as plt
import time
from pyJoules.energy_meter import EnergyContext
from pyJoules.device.rapl_device import RaplPackageDomain, RaplDramDomain
from pyJoules.device.nvidia_device import NvidiaGPUDomain
from pyJoules.handler.pandas_handler ... |
552ae38758f58a28bbccb8814f3a96e2d4650c123b4ad3410470a60fd88647e8 | Python | 4,334 | 134 | import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Iterable, Iterator, Optional
from siapy.core.exceptions import InvalidInputError
from .shape import Shape
if TYPE_CHECKING:
from siapy.entities import SpectralImage
__all__ = [
"GeometricShapes",
]
@dataclass
class Geomet... |
0bb4a27f779b173f8ec8a8f2c8f2e4f5067a543f2e924e15fd7369d77a74cc37 | Python | 4,337 | 120 | # Copyright 2023 Google LLC
# 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
467f525e32f92ecdf6e2a6883d19b96e526cb1f92e9d39274a9aefc9318462fc | Python | 4,337 | 109 | import os
import cv2
import ast
import torch
import numpy as np
import random
from torch.utils.data import DataLoader, Dataset
cv2.setNumThreads(1)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class VimeoDataset(Dataset):
def __init__(self, dataset_name, batch_size=32):
self.batch_... |
9465e56ad53a0a44935bb07aed46d0666a13e8d74038f287cd8bd8b980b6d547 | Python | 4,337 | 152 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Tests for analog presets."""
from torch import Tensor, randn
from aihwkit.simulator.tiles.analog import AnalogTile
from aihwkit.simulator.presets import (
... |
df1a973f79ad2a351b37a84e565698857e4172c4a8d291460f05b6f291ba737b | Python | 4,339 | 122 | import numpy as np
import json
import copy
from spinnaker2 import snn, hardware
import helper
np.random.seed(42)
# parameters of convolution layer
in_width = 32
in_height = 32
in_channels = 1
out_channels = 4
filter_height = 3
filter_width = 3
stride_y = 1
stride_x = 1
n_hidden_nrns = 20
n_output_nrns = 12
timesteps ... |
1e3d8f6a219915920c9e767a8f744b0327e22d8174c59292142c7f8f066fb4b8 | Python | 4,343 | 102 | #!/usr/bin/env python
"""
Converts external sample IDs to safe GATK-SV IDs
"""
import argparse
import hashlib
import re
import sys
DEFAULT_HASH_LENGTH = 6
ID_FORMAT = "__{id_name:s}__{id_hash:s}"
def convert_id(sample_id, hash_input, hash_length):
if sample_id is None or sample_id == "":
raise ValueE... |
626d3f24b2822e5924caa9f459028365dc231ac475d3bc05c47df152458bf89f | Python | 4,343 | 103 | """
The main idea for this code is to provide a way for users to not need to bother with the hassle of multiple tokens for a concept by typing
a photo of <concept>_0 <concept>_1 ... and so on
and instead just do
a photo of <concept>
which gets translated to the above. This needs to work for both inference and training.... |
95d2ab6461b77f2f3cd3c50e36289030e0efc69a4f6ffe09328f4fa51b890701 | Python | 4,343 | 133 | import numpy as np
from scipy import linalg
from scipy.stats import norm, entropy
from sklearn.cluster import KMeans
def fid(feat_data, feat_gen):
"""
Calculate Frechet Inception Distance
"""
# Means
mu_data = np.mean(feat_data, axis=0)
mu_gen = np.mean(feat_gen, axis=0)
# Covariances
... |
1c380dce1a5b39d2de3b732cd7bd71c9479ea718ef66f55456f429ccfdc15580 | Python | 4,346 | 125 | from typing import Callable, Optional
from jaxtyping import Key
import numpy as np
import jax
import jax.numpy as jnp
import equinox as eqx
from .modules import Conv, Sequential
from .initializers import lecun_normal, he_normal
from .activation import ScaleFn, Prod, ExpSum
from .nqs_layers import ReshapeConv
from ..glo... |
dcfa18cf05b5af339ccb13c27d1af451ebd13acb65b3fe4efd155d5f4a317b63 | Python | 4,346 | 133 | _base_ = [
'../_base_/datasets/rtts_coco.py', '../_base_/schedules/schedule_1x.py',
'../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],... |
12963872643e85da6aa149e38424ab25a3261eea82fd0f86e5612ddc825ca5c5 | Python | 4,347 | 106 | import string
from pickle import load
import numpy as np
import matplotlib.pyplot as plt
import string
from plot_funcs import label_axes
from matplotlib import animation
figsize = 7.086614, 8.858268
# %%
lgca1 = load(open('r_d_0.0_theta_0.5_lgca.pkl', 'rb'))
# %%
capacity = lgca1.interaction_params['capacity']
resti... |
18cba20b4e0f4d11a21d38135c1085f158a060aa939601f503d2d857c5bdd1fa | Python | 4,347 | 134 |
import numpy
import random
import sys
sys.path.insert(0, "..")
from scipy import stats, special
from sklearn.preprocessing import PolynomialFeatures
from matplotlib import pyplot
import matplotlib; matplotlib.use("MacOSX")
from banditopt import algorithms
# numpy.random.seed(42)
# random.seed(42)
class Sampler:
... |
7e08b598f46700cace78f451a4f1f4fbe412812163fc9cc2db6e9fbcad711229 | Python | 4,349 | 134 | from logging import getLogger
import numpy as np
from pfrl import explorer
def select_action_epsilon_greedily(epsilon, random_action_func, greedy_action_func):
if np.random.rand() < epsilon:
return random_action_func(), False
else:
return greedy_action_func(), True
class ConstantEpsilonGre... |
555cc696324ed0fbe6b84a9059bf33cf3cdee0db0fccfe5975c1f960a63acf45 | Python | 4,351 | 128 | import concurrent.futures
from functools import partial
from gzip import decompress
from typing import Tuple
import numpy as np
import pandas as pd
import pytest
import requests
from data_profiling.model.summary import describe_1d
def mock_multiprocess_1d(args, config, summarizer, typeset) -> Tuple[str, dict]:
... |
bbc47ab3abe22cdc4a3d47bf87dff080761a15606151d56746ea626c8b4e8619 | Python | 4,351 | 101 | # Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
10d5ef2de7838d1f348a752ef8ae56272cb961a26d09de388ca479ad1a1b6a28 | Python | 4,353 | 133 | _base_ = [
'../_base_/datasets/duo_coco_detection.py',
'../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12,... |
210eee0081118e4a66bf9ab7e03fe620c9b52b4b52d2967f24fa6f567737df62 | Python | 4,353 | 133 | _base_ = [
'../_base_/datasets/duo_coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12,... |
5a2e6777e2dff4c52af628a977ac2015ac2b80c40a39ac5dbf65b74378b25dc3 | Python | 4,353 | 123 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
if TYPE_CHECKING:
from fairchem.core... |
8c220b246029fa5458b858cf4de7fa2a8f6a80e636bac7e940848afc17ae2e64 | Python | 4,353 | 129 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import os
from glob import glob
import numpy as np
import pandas as pd
from fairchem.core.components.... |
059bb1acfac013d8b7fcd5f41f9538a10adaf7d74b6999c93a4fe5b1536c0d6f | Python | 4,354 | 144 | #!/usr/bin/env python
"""
Collect metric file metrics. Writes stats to stdout.
Metrics:
metrics_<common>_num_records : Number of records
metrics_<common>_mean_<metric> : Mean metric value
metrics_<common>_num_empty_<metric> : Number of metric N/A entries
"""
import argparse
import math
import sys
from matp... |
1904471e233eb913340820558e4344af39ea9d7c89ec53cad556468975fb9d3b | Python | 4,354 | 172 | """Documentation to be injected into docstrings."""
import sys
###################################
# Standard documentation entries
docdict = dict()
docdict[
"selector"
] = """
selector : :obj:`tedana.selection.component_selector.ComponentSelector`
The selector to perform decision tree-based component selecti... |
a6dd5ec911bc459cf901014101914d3ca6c30e77bad971ff543374ffca56d2c0 | Python | 4,355 | 133 | _base_ = [
'../../_base_/datasets/rtts_coco.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12,... |
c4da5957cd1a2306ce51547bdc1352a8874d02f87bbfabc5dddb5f4a59ab20ff | Python | 4,355 | 150 | import io
import subprocess
import sys
import pytest
from stl import main, mesh
def test_main(ascii_file, binary_file, tmpdir, speedups):
original_argv = sys.argv[:]
args_pre = ['stl']
args_post = [str(tmpdir.join('output.stl'))]
if not speedups:
args_pre.append('-s')
try:
sys.... |
0567d86c0b89aa9405e460ce67e70837f5705f7039be1c0618cff368bbfdfb12 | Python | 4,357 | 133 | _base_ = [
'../_base_/datasets/ruod_coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12... |
82c919136226909d4ab86c72e951a5a5d9ceec4f049f04046deb81603b6ff540 | Python | 4,357 | 133 | _base_ = [
'../_base_/datasets/ruod_coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12... |
a060fe62960bd7b718ead3411ab3cdf80fa1d833aecbea1595582aa7be79c5d8 | Python | 4,357 | 125 | """Animations of neural activations."""
from typing import List, Optional, Union
import numpy as np
from matplotlib import colormaps as cm
from flyvis import utils
from ..visualization import figsize_utils
from .animations import AnimationCollector
from .hexscatter import HexScatter
__all__ = ["StimulusResponse"]
... |
5869c663ca16ed849657455bc875557ecab9e27bb4354a4865483889a797a368 | Python | 4,358 | 134 | # built-in dependencies
from typing import List, Any
from enum import IntEnum
# 3rd party dependencies
import cv2
import numpy as np
from numpy.typing import NDArray
# project dependencies
from deepface.commons import weight_utils
from deepface.models.Detector import Detector, FacialAreaRegion
from deepface.commons.l... |
9d4d2a13bd7c1dc56898e345d12672efcfa1f1fcd1e10fcaa0335dd6459e682c | Python | 4,358 | 84 | import ast
import glob
import hydra
import numpy as np
import pandas as pd
import scipy.stats as st
from omegaconf import DictConfig
from typing import Iterable
def calculate_mean_and_conf_int(data: Iterable, alpha: float = 0.95) -> tuple[float, tuple[float, float]]:
"""
Calculate and report the mean and co... |
e87c4f581554ce9348b92ecad7f72260b14bae2d53811824bbc73bc6286bee42 | Python | 4,359 | 125 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING, Any, Callable
import torch
if TYPE_CHECKIN... |
17b10095aa733d5a8ba48b380525d933feb3e6c395952f943829976cc420bc3a | Python | 4,360 | 116 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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... |
96228a7cd5f68e4362693ce9dba620103294999d6404b3b863d6a850ce582a17 | Python | 4,360 | 121 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 27 14:42:00 2019
@author: ju-bar
Array data plotting wrapper
This code is part of the 'emilys' repository
https://github.com/ju-bar/emilys
published under the GNU General Publishing License, version 3
"""
# %%
import matplotlib.pyplot as plt # include mathematic plottin... |
f5e0fa1b09cb27cb0d2b6fec619a6e9c4bada5c5cb5b83b238ccefd12bac133c | Python | 4,360 | 103 | from collections import defaultdict
from typing import Dict, List
from ray.autoscaler._private.prom_metrics import AutoscalerPrometheusMetrics
from ray.autoscaler.v2.instance_manager.common import InstanceUtil
from ray.autoscaler.v2.instance_manager.config import NodeTypeConfig
from ray.autoscaler.v2.schema import Nod... |
61a71736f0abaf59b8ce07b19321eaf0e7b8732382691495e94400fb334e4b29 | Python | 4,362 | 144 | from abc import ABC, abstractmethod
from typing import Dict, List
import samna
from .dynapcnn_layer import DynapcnnLayer
from .mapping import LayerConstraints, get_valid_mapping
class ConfigBuilder(ABC):
@classmethod
@abstractmethod
def get_samna_module(self):
"""Get the samna parent module that... |
be7d17be2fe334097e155fd3a759c107fca9e2f31a7adef200f2ca392adb10a1 | Python | 4,365 | 120 | #%%
import torch
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.functional as F
import pickle
import itertools
import random
import os
from src.encoders_decoders import *
from src.losses import *
from src.useful_functions import *
from torch.utils.data import DataLoader
from joblib import Parallel,d... |
86b2c8fcca6b68b62aa7ce8b85b7ff87ade63f42b49c6e9d6712ac7a58752b49 | Python | 4,366 | 112 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Tests for the AIHW Composer cloud runner."""
import os
from unittest import SkipTest
from aihwkit.cloud.client.entities import CloudExperiment, CloudJobStat... |
9a966cffb9a4e3b552e6ee3e588203a04465655b9a4fbc87c0d762c8f17abadd | Python | 4,366 | 129 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
33201331aac7a1cf1569aaff78024dd08595ea942b224e1def36693f3c0f7d36 | Python | 4,367 | 112 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
a5b4b06cd33296b0a68ae8603b4f8da33a3e845a11903e493e72161abe5c94cf | Python | 4,367 | 159 | import logging
from typing import Optional
from ray._private import ray_constants
from ray.core.generated.common_pb2 import ErrorType, JobConfig
from ray.core.generated.gcs_pb2 import (
ActorTableData,
AvailableResources,
ErrorTableData,
GcsEntry,
GcsNodeInfo,
JobTableData,
PlacementGroupTa... |
27699cc0195ff9d7b335bf2c3218cad3beb3a6a567f4d4d55e6333d62d1464f1 | Python | 4,368 | 132 | import argparse
import time
import numpy as np
import torch
import torch.optim as optim
from models import GNN
from pretrain_JOAO import graphcl
from torch_geometric.data import DataLoader
from datasets import MoleculeDataset_graphcl
def train(loader, model, optimizer, device):
model.train()
train_loss_acc... |
6d0f2a47ac9795866df05bf8bbdeb9667cd0fd7967598225cb4945dd09dbf790 | Python | 4,368 | 132 | from typing import List
from data_profiling.config import Settings
from data_profiling.report.formatters import fmt, fmt_bytesize, fmt_percent
from data_profiling.report.presentation.core import (
Container,
FrequencyTable,
FrequencyTableSmall,
Image,
Table,
VariableInfo,
)
from data_profiling.... |
fad018e8a4b45a0beccedea6251b339ded06b148a87a7e379c0dc24137d8b410 | Python | 4,370 | 107 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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... |
4d3dafe34dd07b7c202f3e33fc8c234135cf81a2494c0611da015b2879fcbb99 | Python | 4,372 | 131 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
a54b38bf6a3dc3fd37c4d70ebcd90a25bf057195845a97976899ae0126eaa670 | Python | 4,372 | 116 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import torch
from fairchem.core.models.uma.nn.embedding import DatasetEmbedding
class TestDatasetEmb... |
99692477a8198e5c26a408137d71368c15bfa099e20e7b903319e427bfc4064c | Python | 4,374 | 104 | import gc
import unittest
from parameterized import parameterized
from diffusers import FlaxUNet2DConditionModel
from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow
if is_flax_available():
import jax
import jax.numpy as jnp
@slow
@requi... |
c5b5f14ffce5b703580fccc1a8b8f37259b400939f98d1c78669bfdf1c2ca530 | Python | 4,374 | 100 | # Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
2a882b72a161b77857ff9799157b5afa3d922ec14a3e6a6c57cec1e9c0893ac2 | Python | 4,376 | 102 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import os
import sys
import zipfile
from datetime import datetime
import ase.io
def extract_file(zipname, file_to_unzip, extract_to):
... |
aed302f86fd36c593eb172ff8ef2985c371e8337ed24c82289defd96be925429 | Python | 4,377 | 160 | """
Implementing "a network with a merge and a split" in https://github.com/synsense/sinabs/issues/181
"""
import torch
import torch.nn as nn
from sinabs.activation.surrogate_gradient_fn import PeriodicExponential
from sinabs.layers import IAFSqueeze, Merge, SumPool2d
class SNN(nn.Module):
def __init__(self, ba... |
0735a0a9bae5aad77ce5d9c1b8b91372906430d56c22f76dc4b75a5947f5bf05 | Python | 4,379 | 146 | #!/usr/bin/env python
from bin import __version__
import os
import re
import argparse
import gzip
import logging
from functools import partial
from pathlib import Path
from tqdm import tqdm
from tqdm.contrib.concurrent import thread_map
# argparse
desc = "Create Sequence accession to TAXID mapping file"
epi = """DESC... |
95fa33963e8aa33a8e5150b37db922b836f0c075beaec086aaf56457d6c85d15 | Python | 4,379 | 132 | #!/usr/bin/env python
#%%
import ca_source_extraction as cse
import glob
from ipyparallel import Client
import matplotlib as mpl
mpl.use('TKAgg')
from matplotlib import pyplot as plt
import numpy as np
import os
import psutil
import pylab as pl
from scipy.sparse import coo_matrix
import shutil
import subprocess
import... |
c5d1be0c277822efc0540df7ace1cae7ac8e721dc5dd58335cb0bd663a0ab2dd | Python | 4,379 | 141 | """Render the ``viz`` specs that each provenance entry declares.
The report system is a dumb executor: it takes ``{"function":
"ov.pl.<fn>", "kwargs": {...}}`` specs stored by the dispatcher, resolves
them against the installed ``omicverse.pl``, runs the call, and
base64-encodes the resulting figure. There is no hardc... |
9dab9380376098c1351e426e98bcd995b29769f3440034b2963741704adb68cf | Python | 4,380 | 124 | import warnings
from typing import Optional, Union
import numpy as np
import numpy.typing as npt
import sklearn.utils.validation as sklearn_utils_validation
import torch
import cebra
import cebra.integrations.sklearn.utils as sklearn_utils
import cebra.models
#NOTE(celia): Deprecated: transform is now handled in th... |
418c084ed437e4648f9f9bd85b8835793e96822f73df52044555d85e49da9dce | Python | 4,381 | 144 | from __future__ import annotations
"""
Simple documentation scraper for building OmicVerse skills from a base URL.
Design goals:
- Minimal dependencies: requests + beautifulsoup4 (optional)
- Conservative: same-domain crawl with a max_pages cap
- Extracts headings, text, and code blocks into lightweight markdown
- Se... |
6ee7b9dfefb4b663f66c4f4acc7ce1666facbd0e8c4c272e4d01a3f8e9ac5dab | Python | 4,382 | 132 | import os
import pickle
import shutil
import tempfile
import unittest
from unittest.mock import Mock
import dill
import numpy as np
from torch.multiprocessing import Pool
from rising.loading.dataset import AsyncDataset, dill_helper, load_async
class LoadDummySample:
def __call__(self, path, *args, **kwargs):
... |
c0721a91f125bf19f6e0c403ae11a602cd195695fda9f9c69b08a4e7737ff397 | Python | 4,386 | 154 | import inspect
import logging
import numpy as np
import torch
from torch.utils.data import DataLoader
from tqdm.auto import tqdm
import flyvis
from flyvis.datasets import MultiTaskDataset
from flyvis.network import Network, NetworkView
from flyvis.task.objectives import epe, l2norm
from flyvis.utils.class_utils impor... |
382fc700e94732f60d0be58664704c45b73f646de11902e274cdd1db6e08f6f0 | Python | 4,390 | 123 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import inspect
import math
from bisect import bisect
import torch.optim.lr_scheduler as lr_scheduler
... |
6c3db9dff03735abb0f1499fe42d42a48c11c140aefdb9c465cf114ecece90fd | Python | 4,390 | 157 | """
Plot a syllable projection with spectrograms appearing as tooltips.
"""
__date__ = "March 2019 - December 2020"
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import HoverTool
from bokeh.models.glyphs import ImageURL
import matplotlib.pyplot as plt
plt.switch_backend('agg... |
9b8ead1cc3233bd25c473bdacf96430e36d441e7d61f0d86c05e6cc368a967ce | Python | 4,390 | 137 | import errno
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import os
import sys
np.random.seed(0)
def dispersion(X):
mean = X.mean(0)
dispersion = np.zeros(mean.shape)
nonzero_idx = np.nonzero(mean > 1e-10)[1]
X_nonzero = X[:, nonzero_idx]
nonzero_mean = X_nonzero.m... |
a703ab3afaf122209ddcdf22eb9e902924bfb8bd35a0823a75d90377ce155c0b | Python | 4,390 | 170 | from pathlib import Path
import pandas as pd
import numpy as np
from collections import defaultdict
import random
from scipy.stats import multivariate_normal
from scipy.stats import wasserstein_distance
from scipy.stats import pearsonr
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mat... |
10a661ff8fbdb543259f68671c3073072869a049cf3eb3f28ec8d974dfce4145 | Python | 4,392 | 131 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 7 13:29:49 2017
@author: agiovann
"""
#%%
try:
get_ipython().magic(u'load_ext autoreload')
get_ipython().magic(u'autoreload 2')
except:
print('Not launched under iPython')
import numpy as np
import matplotlib.pyplot as pl
from matplot... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.