sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
ae97e864da4f47ee455e185d691aa331b6aa33c167a9525421d8adbc0b834452 | Python | 2,047 | 60 | # This file is a part of the `nequip` package. Please see LICENSE and README
# at the root for information on using it.
import torch
from pathlib import Path
from typing import Union, Tuple, List, Optional
from .torchscript import load_torchscript_model
from .aotinductor import load_aotinductor_model
from nequip.util... |
d9d6fd337abc7c3ffad7cb1d405b1aa04cc99e40ac9325c565fe34a7f5e6135e | Python | 2,047 | 68 | """Perform tangent PCA at the mean on the sphere."""
import logging
import matplotlib.pyplot as plt
import numpy as np
import geomstats.visualization as visualization
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.learning.frechet_mean import FrechetMean
from geomstats.learning.pca import Tang... |
a5e71b5ba028e0d0f92adf1c1781da656ee429989f1734175d0ef99a8a0be8bb | Python | 2,049 | 64 | import os
import time
import hdf5storage
import numpy as np
import scipy.io as sio
from functions.dFC_funcs import *
os.environ["MKL_NUM_THREADS"] = "64"
os.environ["NUMEXPR_NUM_THREADS"] = "64"
os.environ["OMP_NUM_THREADS"] = "64"
print(
"################################# subject-level similarity measurement CO... |
17cac38b7337f953a213810918f16e415a210d50bed979ea362493cbe6554be5 | Python | 2,052 | 55 | # Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""You may copy this file as the starting point of your own model."""
from src.runner_fa import FederatedAnalyticsTaskRunner
import numpy as np
class IrisHistogram(FederatedAnalyticsTaskRunner):
"""
Taskrunner class used to perform... |
8156d43b22d48cfc3b448210c68bd1e57a0abe4c61034117d3189c4690940d80 | Python | 2,053 | 74 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def create_var(tensor, requires_grad=None):
if requires_grad is None:
return Variable(tensor).cuda()
else:
return Variable(tensor, requires_grad=requires_grad).cuda()
def index_select_ND(so... |
c463ad10b80fe6c5d6e568e0a0482a0f5aef3e345f1e88c15a763166aec634b8 | Python | 2,053 | 87 | # -*- coding: utf-8 -*-
import os
import argparse
import logging
import numpy as np
import pickle
from scipy.special import softmax
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
# use this format to tell the parsers
# where to insert certain parts of the script
# ${imports}
def parse_args(... |
f25ed22887d5e1f56af85862475223371ab43e3a511e8bff9de5657f953f5891 | Python | 2,053 | 71 |
'''
the preprocessing code refers to the work(Yin, B., Corradi, F. & Bohté, S. M. Accurate and efficient time-domain classification with adaptive spiking recurrent neural
networks. Nat. Mach. Intell. 3, 905–913 (2021)).
'''
"""
The dataset is 48kHZ with 24bits precision
* 700 channels
* longest 1.s
* shortest 0.21s
""... |
827a2db3f97bbe51b4c6a9e9bd361a2b6a7f5b5c2a7d0ca54fc039f0caa4ca0c | Python | 2,054 | 76 | import pytest
import geomstats.backend as gs
from geomstats.test.data import TestData
class GroupActionTestData(TestData):
def identity_action_test_data(self):
return self.generate_random_data()
def action_vec_test_data(self):
return self.generate_vec_data()
def inverse_action_test_data... |
4e5254698cb336e1b1a0d45d4a655ff477c3740158be5e19fc76e44ad2a1d911 | Python | 2,055 | 49 | import scvi
import networkx as nx
import numpy as np
import pickle as pkl
import scipy.sparse as sp
import sys
import pandas as pd
import torch
import anndata as ad
import scanpy as sc
feature="Adult-Brain_Lake_dge.txt"
raw_fea = pd.read_csv(feature,sep=",",header=0,index_col=0)
df_t = raw_fea.T
var = pd... |
3efcf0c39d8629ba8ed553b85b9492fd5f7750a0bb37f5f70ce2cdaf211448f3 | Python | 2,057 | 48 | import os, numpy as np, subprocess, shutil, pandas as pd
hannover_repo_link = "https://github.com/ml-workgroup/covid-19-image-repository.git"
hannover_repo_name = hannover_repo_link[hannover_repo_link.rfind("/")+1:hannover_repo_link.rfind(".")]
# create folder by cloning, or upgrade previously created folder by pull... |
f39d71583e20cd745008d84c5b2ad23e396832ff24b3f700e4ca525498a727d0 | Python | 2,057 | 63 | #!python
__doc__="""\n
the script is used to calculate the Rsq between mutant and coverage as
INPUT:
wide mutant matrix
wide coverage matrix
OUTPUT:
Rsq of each nucleotide (windows)
"""
import argparse
import glob
import re
import numpy as np
import pandas as pd
import matplotli... |
fb6ee6d86e725b25a98717a64e9d6cf519de7f2e5e7952b32be9449f196d8685 | Python | 2,057 | 61 | """Adapter for Mol2Mol"""
from __future__ import annotations
__all__ = ["TransformerAdapter"]
from abc import ABC
from typing import List, Tuple
import torch
import torch.utils.data as tud
from .sample_batch import SampleBatch
from reinvent.models.model_factory.model_adapter import (
ModelAdapter,
SampledS... |
516768a84e40227e64d93cc87d9207d5c6e5e48a1293af5ef3d8963e04d12685 | Python | 2,059 | 77 | #!/usr/bin/env python
import os
directory = "."
# All files in directory
allFiles = os.listdir(directory)
# Only the files we care about
files = []
for i in allFiles:
if i.startswith("snpCounts") and "chimp" in i:
files.append(i)
print(files)
snp_dict = {}
counter = 1
total = str(len(files))
for i in ... |
124381b79253f8ce65e94ce36c6bcaefdf6d932c3c70b05798c38e90a4c20e87 | Python | 2,060 | 68 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""StaticGroupedAssigner tests."""
import pytest
from openfl.component.assigner import StaticGroupedAssigner
ROUNDS_TO_TRAIN = 10
@pytest.fixture
def authorized_cols():
"""Initialize authorized collaborator list."""
return ['... |
23fe5c818cea66f8a5c91de06e5913b297e1b2a9412a39ddd544ab7e6e49fd89 | Python | 2,061 | 66 | # Copyright (C) 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""You may copy this file as the starting point of your own model."""
from openfl.federated import KerasDataLoader
from src.mnist_utils import load_mnist_shard
class JAXMNISTInMemory(KerasDataLoader):
"""Data Loader for MNIST Data... |
f0339d536d303be53c1ae1df11a2d7e75d077d5054fd316fdb01b9c6c3651a7a | Python | 2,062 | 57 | import pytest
import geomstats.backend as gs
from geomstats.geometry.matrices import Matrices
from geomstats.test.vectorization import generate_vectorization_data
from geomstats.test_cases.geometry.base import LevelSetTestCase
class FullRankCorrelationMatricesTestCase(LevelSetTestCase):
def test_from_covariance(... |
3d8110687f897065e5e7e5cd2a89cb4e7c3f603968ae66ccee0c193281c2e773 | Python | 2,063 | 70 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 15:33:56 2020
@author: Tom
"""
import tensorflow as tf
from tensorflow import keras as k
import numpy as np
class TSCallback(tf.keras.callbacks.Callback):
def __init__(self, image_flow_val,
validation_rounds = 1):
super().__init__()
... |
ba36efd010dd747f68a90e8327b8842a8cd57fd0e84186456c4cfcf3d10bc552 | Python | 2,063 | 66 | # Copyright (C) 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""You may copy this file as the starting point of your own model."""
from openfl.federated import KerasDataLoader
from src.mnist_utils import load_mnist_shard
class KerasMNISTInMemory(KerasDataLoader):
"""Data Loader for MNIST Da... |
841d0966fd5952df65561a0172846695b9b94d42e37313a86b0eaaf64b4344a5 | Python | 2,065 | 67 | import fastdeploy as fd
import cv2
import os
def parse_arguments():
import argparse
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_dir",
required=True,
help="path of PP-TinyPose model directory")
parser.add_argument(
"--image_file", requ... |
c0b98ef299cc92c7cc280311dab37ea0e3049ff4f7b472f6c63883d4953f8612 | Python | 2,066 | 60 | import numpy as np
import pandas as pd
from rdkit import Chem
input_file = "kkb_chembl_standardizedAggregation.csv.gz"
output_file = "chembl_kkb_multi_task_data.csv.gz"
class DataProcessor:
def __init__(self, input_file, output_file):
self.input_file = input_file
self.output_file = output_file
... |
d482a30548296badf37100c2bc07a2d1f6f458d7c590c560348d58287fa37507 | Python | 2,068 | 65 | import geomstats.backend as gs
from geomstats.test.data import TestData
class WrapperTestData(TestData):
def wrap_attr_test_data(self):
def example_fnc():
return 2.0
data = [dict(func=example_fnc, scale=3)]
return self.generate_tests(data)
def scaling_factor_test_data(se... |
7776470dcd395914685782fcbe20cc5a21bb22035a319222cd9c824fa2263103 | Python | 2,069 | 59 | import pytest
import geomstats.backend as gs
from geomstats.geometry.base import DiffeomorphicManifold
from geomstats.geometry.diffeo import ReversedDiffeo
from geomstats.information_geometry.gamma import (
GammaDistributions,
NaturalToStandardDiffeo,
)
from geomstats.test_cases.geometry.base import VectorSpac... |
c1936fedee191b73c91728c1e8b631a3dd58067885c4a69da326a937476bbe5d | Python | 2,069 | 51 | import ants
import numpy as np
import pandas as pd
import os
from tqdm import tqdm
from scipy.io import savemat, loadmat
tmp_dir = '../data/tmp/'
path_raw = '../data/test/'
path_recon_lr = '../data/recon_lr/'
path_recon_rl = '../data/recon_rl/'
path_J_lr = '../data/J_lr/'
path_J_rl = '../data/J_rl/'
image... |
5b4fc715f7c8997db7da11a58e6e53613925dc8532d896d2b5974782d2957db8 | Python | 2,070 | 50 | """Permutation tests, bootstrap resampling, and intersubject statistics.
Every test here runs on plain numpy arrays and returns a dict of results. The
one-, two-sample, correlation, matrix, and timeseries permutation tests share
one execution model: permutations run on joblib workers, `n_jobs` sets how
many, and a giv... |
7f770996996acd9a9967421069f479878d4f09bb926c847f4ed55656709133d5 | Python | 2,070 | 76 | import random
from random import randint
import pytest
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.matrices import Matrices
from geomstats.learning.euclidean import LinearRegression
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test.random import RandomDa... |
c37742041530ce59b3df5e04b0bc0368e75399c4ceda5b8482f4bd5e6ee2b382 | Python | 2,072 | 55 | import torch
import torch.nn as nn
from .GMNET import GMNet
class GraphMatching(torch.nn.Module):
def __init__(self, in_dim, num_layers, hidden, pool_type='sum', model_type='gmnet', fuse_type='abs_diff', ogb = False, **kwargs):
super(GraphMatching, self).__init__()
self.dis_encoder = GMNet(in_dim, ... |
cbb76162caaa881697f5c08b8c351e267d6a35abcf2650fdc8c12ce0cb700840 | Python | 2,072 | 38 |
import argparse
from hyper_dti.experiment import reproduce_hyperpcm, reproduce_deeppcm, reproduce_tabular
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Benchmark PCM models on Lenselink dataset.')
parser.add_argument("--model", default='HyperPCM', type=str, help='Model to benchmar... |
cc1495c0e4f92bd1e51458489a90ea638a083a0957de604afa8e4c5a516cd2a5 | Python | 2,072 | 52 | from unittest import TestCase
import torch
import torch.nn as nn
from torch.utils.data import TensorDataset, DataLoader
from smithers.ml.models.netadapter import NetAdapter
from smithers.ml.utils_rednet import get_seq_model
from smithers.ml.models.vgg import VGG
inps = torch.arange(100 * 3 * 224 * 224,
... |
e8bfb1821e9a1cf2510077d0e84b574ef422fff10b82f3c00982a1771cd3bcdb | Python | 2,072 | 66 | from live2p.workers import RealTimeQueue, Worker
import pytest
import sys
from glob import glob
from live2p.utils import get_true_mm3d_range
from live2p.offline import prepare_init
from queue import Queue
from pathlib import Path
if sys.platform == 'linux':
tiff_folder = '/mnt/e/caiman_scratch/test_data/ori/data... |
1396ca529e08927831230a60903521b2888a00b2d86c7ce83cc1f9086c548071 | Python | 2,073 | 73 | from numba import njit, jit, objmode
from numba.experimental import jitclass
from numba import int32, int64, float32, float64, boolean
from numba import typed, types
from numba.types import pyobject
import numpy as np
spec = [
('maxSeqLen', int32),
('D', float64[:,:]),
('distCompu... |
c198398706f3c8aba6bd18e40cb9c24f186a86af12c155e47338c1b369b101c2 | Python | 2,075 | 62 | from typing import List, Tuple
import torch
from torch import Tensor
from torch.nn.utils.rnn import pad_sequence
from torch.utils import data as tud
from reinvent.models.linkinvent.model_vocabulary.paired_model_vocabulary import (
PairedModelVocabulary,
)
class PairedDataset(tud.Dataset):
"""Dataset that ta... |
eb0218d14cb3184a038ddd2524e650a33a12be7cd4f1a24e08e87a73a3155ac6 | Python | 2,076 | 82 | from Bio import SeqIO
import numpy as np
import yaml
import get_protparam_parser
from sklearn.utils import class_weight
def load_protein_data(file_list):
proteins = []
for file_ in file_list:
for record in SeqIO.parse(file_, "fasta"):
proteins.append((str(record.id), str(record.seq)))
... |
06a736a268a9466f0d6a9e3a588d96e2573917e4afd545567b0c90d51959eebf | Python | 2,077 | 53 | """
Calculate the wave directions per wave and channel,
based on the optical flow at wave trigger times and locations.
"""
import argparse
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentPa... |
4d7ab972e1d8604aca62cf636b970398e044158909a60b9429ddd03c7efd3e3a | Python | 2,077 | 53 | import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from data.data_loader import testDataset
from models.models import Brainmodels
from transform import transform_test
import argparse
# 设置命令行参数
parser = argparse.ArgumentParser(description='Test the trained DNN model')
parser.add_argument('--m_na... |
e13135bb17946e8bb6f4a71f71b97649122dde93f743756e521c5234da4f019e | Python | 2,078 | 52 | import numpy as np
import pandas as pd
import sys
import NaiveDE
import SpatialDE
def Spatial_DE(filterd_exprs, coordinates):
if(filterd_exprs.shape[0] != coordinates.shape[0]):
sys.exit("The number of cells in expression file and location file don't match\n")
else:
## results and ms_results
... |
08a26ee4e05d66baed480ac093bed7f28470d71128be46f3c3af369a1ff2e238 | Python | 2,079 | 55 | import scvi
import networkx as nx
import numpy as np
import pickle as pkl
import scipy.sparse as sp
import sys
import pandas as pd
import torch
import anndata as ad
import scanpy as sc
#data load
feature="Adult-Brain_Lake_dge.txt"
raw_fea = pd.read_csv(feature,sep=",",header=0,index_col=0)
df_t = raw_fea... |
625c5c24714195ded394e74d6406ea0ce44ad4bbdea0db2b87e8b8fd86cf8dd2 | Python | 2,079 | 67 | import random
import pytest
from geomstats.geometry.discrete_curves import DiscreteCurvesStartingAtOrigin
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.special_euclidean import SpecialEuclidean
from geomstats.learning.geodesic_regress... |
b9918849f59ce83abc6d565ffffc8041ca864285a765cf54f177b9df97de1695 | Python | 2,080 | 63 | import unittest
import pytest
import torch
import torch.utils.data as tud
from reinvent.models import LinkinventAdapter
from reinvent.models.linkinvent.dataset.dataset import Dataset
from reinvent.models.linkinvent.link_invent_model import LinkInventModel
from reinvent.runmodes.utils.helpers import set_torch_device
f... |
54470dc3b8e691ef9009d9a1cf1361632d67748892ff95c4a9bdb084095623f1 | Python | 2,081 | 58 | import pytest
from types import SimpleNamespace
from reinvent.datapipeline.filters import RegexFilter
from reinvent.datapipeline.filters import elements as elements_module
SMILES = [
"CC(=O)O[Cl+][O-]",
"CC(C)(C)[PH+]([BH2-][P+]([BH2-][ClH+2])(C(C)(C)C)C(C)(C)C)C(C)(C)C",
"[O-][Br+3]([O-])(O)Oc1cccnc1Br",... |
825d0acc0ed8bc3d73104e0ca3781d9aa835647bf77df0a8cab984b35a61c510 | Python | 2,081 | 88 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
import os
import importlib
import argparse
SUPPORTED_ACT_FNS = []
def register_act_fn(name):
def register_fn(fn):
if name in SUPPORTED_ACT_FNS:
raise ValueError(
"Cannot re... |
abe3750405f04961f0e7d153c8eab58a5185ab1d11e4e9d869a1e95c5c9f0535 | Python | 2,081 | 63 | import subprocess
from collections import namedtuple
import re
import argparse
import getpass
Job = namedtuple("Job", "id state name")
def parse_squeue(sq_output):
jobs = []
for line in sq_output.split("\n"):
if len(line) < 10:
continue
jobs.append(Job(
id=int(line[:10]... |
a2ce885452088eb5e2620415e5e37e96b80c620d01addc82f032e3166ac02265 | Python | 2,083 | 66 | import geomstats.backend as gs
from geomstats.test.data import TestData
from .base import VectorSpaceTestData
from .lie_group import LieGroupTestData
class HeisenbergVectorsTestData(LieGroupTestData, VectorSpaceTestData):
fail_for_not_implemented_errors = False
def upper_triangular_matrix_from_vector_vec_te... |
1059166c53eb574a490eb00802f042132529da9435a33e415e456d63ae1e945e | Python | 2,084 | 67 | #!/usr/bin/env python3
"""Strips the license notices from the bundled igraph examples so they are
not visible in the documentation.
"""
import argparse
import sys
from pathlib import Path
from typing import IO
def strip_license_notice(infp: IO[str], outfp: IO[str]) -> None:
seen_code = False
for line in in... |
58417ef531f19fa77ab84522daae21b2f03433b976e4fcd318bfecf8f6254b16 | Python | 2,084 | 88 | from pathlib import Path
import click
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from nnunetpaper._utils import get_multi_method_dataframe
@click.group()
def main():
pass
@main.command()
@click.option(
"-m",
"--method",
"methods",
multiple=True,
type=click.Tu... |
49be7100320235a9941cb865e377d1377b98a85e3a16154f23867972a4ee01bf | Python | 2,085 | 62 | # Tests that various combinations of numpy and python lists work as expected as inputs
# to add/query/update/upsert operations
from typing import Any, Dict, List
import numpy as np
from chromadb.api import ClientAPI
from chromadb.api.models.Collection import Collection
from chromadb.test.conftest import reset
def ad... |
56f29cf45fa434cd01ae93aee648af82dfe52f0d84191514f16bb887033f4bf0 | Python | 2,088 | 67 | from typing import Optional, Tuple
import torch
from torch import Tensor
import torch.nn.functional as F
from torch_sparse import SparseTensor
def compute_micro_f1(logits: Tensor, y: Tensor,
mask: Optional[Tensor] = None) -> float:
if mask is not None:
logits, y = logits[mask], y[ma... |
6306812f6ebcc7dee77dc6a30cb7d82bf290756e6d0ac75f6a5b7c6c11f9b655 | Python | 2,088 | 70 | import json
import numpy as np
import tensorflow as tf
import shutil, glob, sys
def copy_code(model_path):
tf.io.gfile.mkdir(model_path + 'code')
file_names = glob.glob('*.py')
for file_name in file_names:
try:
shutil.copy(file_name, model_path + 'code')
except:
... |
8bf41d5eca7a1903a63709e3a46781ffd80b6bb930a926f2b121b9a968c8e1a9 | Python | 2,088 | 41 | """Curated parent labels and completed class-II pairs remain consistent across the built corpus."""
from __future__ import annotations
import os
from pathlib import Path
import polars as pl
import pytest
from vdjdb.emit.vdjdb3 import read_table
pytestmark = pytest.mark.release
def test_curated_metadata_is_complet... |
cd68f0efae64a423172d47e8b7ed9804d8b326d0d045c7097d00a9b087596027 | Python | 2,089 | 82 | """Sample sizes for stable univariate correlatinons."""
import numpy as np
import scipy.stats
import scipy.optimize
__all__ = ['pearson_sample_size']
def pearson_sample_size(
rs=(.1, .3, .5),
criterion='power',
# target_error=0.1,
target_power=0.9,
alpha=.05,
):
"""Calcu... |
4a8ce058c857e77f25c61df2d9c5237710a7de3a4ac66e5165ead5b06260ebec | Python | 2,090 | 53 | """
Calculate the wave directions per wave and channel,
based on the optical flow at wave trigger times and locations.
"""
import argparse
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentP... |
398507495569a7274c96bd375178947c0b09ba54eee5eac0caf36f0124806be9 | Python | 2,091 | 64 | """LinkInvent transfer learning
Train a given model with new data. The data comes from a file with SMILES
strings. The file is assumed to be in multi-column format separated by commas
(CSV) or spaces. The SMILES strings are taken from the first two columns.
The two SMILES in each row correspond to two pipe-symbol ... |
5f8715c05e4808acf8ef7f234b5aa92bd4b8653edad7b8badc2402ba8279f538 | Python | 2,091 | 65 | import socket
import threading
PORT = 45350
#HOST = "127.0.0.1" # Standard loopback interface address (localhost)
def socket_send(ip, data_str):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((ip, PORT))
s.sendall(str.encode(data_str))#b"Hello, world"
#print("cli... |
61ff87b59279449d4c3b6e6efed5709828b2f7d8773ef031d3605b9234f7f1d6 | Python | 2,092 | 57 | import os
import re
from pathlib import Path
from deeperwin.checkpoints import load_run
from deeperwin.configuration import RestartConfig, to_prettified_yaml
from ruamel.yaml import YAML
from deeperwin.cli import main
def _get_last_checkpoint(directory):
directory = Path(directory)
latest_chkpt = None
lat... |
c275b14a6a11008fd42645f815a21e2c59711116a4da595d9396278f81641d69 | Python | 2,092 | 72 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""AggregatorClientInterface module."""
from abc import ABC, abstractmethod
from typing import Any, List, Tuple
class AggregatorClientInterface(ABC):
@abstractmethod
def ping(self):
"""
Ping the aggregator ... |
d4e328fddcb217a8f6159f0d6971e8a51d994c98117585c2db0fcf6d411c96ef | Python | 2,092 | 54 | """
This script generates the data shown in Figure 8b.
"""
# import classes and functions
from SHIP import (network, # network class
inputN, # input neuron class
lS_1o, # 1st order leaky synapse class
lifN, # LIF neuron class
refractory) ... |
da6b0fcc20a69c0ab9e1168a905abf925fedbc3b893b5b0f77348687fb5a1ea3 | Python | 2,092 | 66 | from concurrent.futures import ThreadPoolExecutor
import os
import multiprocessing
from typing import List, Any, Dict
from tqdm import tqdm
from chromadb import Collection
def collection_add_in_batches(
collection: Collection,
ids: List[str],
texts: List[str],
embeddings: List[List[float]],
met... |
da323f86694c00ed4c7b43ba6ce1f241319af56fd175939de9440d6ef0f5e521 | Python | 2,094 | 52 | import argparse
class BaseLRScheduler(object):
def __init__(self, opts) -> None:
warmup_iterations = getattr(opts, "scheduler.warmup_iterations", None)
super().__init__()
self.opts = opts
self.round_places = 8
self.lr_multipliers = getattr(opts, "optim.lr_multipliers", None... |
27f5b8c6f3c187e7656fe61b0f84d0da12d7842231571fb9377a9fdf7001e3d1 | Python | 2,097 | 67 | #!/usr/bin/python
from smfishHmrf.HMRFInstance import HMRFInstance
from smfishHmrf.DatasetMatrix import DatasetMatrix, DatasetMatrixSingleField, DatasetMatrixMultiField
from smfishHmrf.spatial import rank_transform_matrix, calc_silhouette_per_gene
import sys
import os
import math
import numpy as np
import scipy
import ... |
bd5bb772b1ce9ea6eed540ff8670200270a6a16ac32f35653a7db88f42b1fc8f | Python | 2,099 | 34 | from brainscore.benchmarks._neural_common import NeuralBenchmark
from brainscore.benchmarks.majajhong2015 import load_assembly, VISUAL_DEGREES, NUMBER_OF_TRIALS, BIBTEX
from brainscore.metrics.ceiling import RDMConsistency
from brainscore.metrics.rdm import RDMCrossValidated
from brainscore.utils import LazyLoad
def ... |
06f4d3f010b8a3124bcce344b2573c4fad2cc2a453e267c7be03954ae6b60217 | Python | 2,100 | 64 | import os
import shutil
import pytest
import unittest
import torch
from reinvent.runmodes.create_model.create_linkinvent import create_model
@pytest.mark.integration
@pytest.mark.usefixtures("json_config")
class TestCreateModel(unittest.TestCase):
def setUp(self):
self.workdir = self.json_config["MAIN_T... |
3dc6d1f27423a74768291c3ae1bcfd6b58223c7b9682073f3427fdedc7c96c56 | Python | 2,103 | 65 | # -*- coding: utf-8 -*-
import logging
import argparse
import os
def parse_args():
# Argument Parser
parser = argparse.ArgumentParser()
# my args
parser.add_argument("--verbose", action = "store_true", help = "display messages")
parser.add_argument("--idir", default = "None")
parser.add_a... |
9e5b0e7131bf6246e0fda1f2e52e94cada144bda65a1b4a15492bdaff559efb0 | Python | 2,103 | 69 | # Copyright (c) 2021 PaddlePaddle Authors. 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 app... |
fd08a3002afa74e24fa900392774a45ee652bb83e34b1aac2d9e228a33022b58 | Python | 2,105 | 54 | """
Calculate the wave directions per wave and channel,
based on the optical flow at wave trigger times and locations.
"""
import argparse
from pathlib import Path
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_path
... |
b1a31a439b482c9e17a494a4f8600d9413c903c74e00ce2208a81cc8cdf1a445 | Python | 2,106 | 54 | """
Calculate the wave directions per wave and channel,
based on the optical flow at wave trigger times and locations.
"""
import argparse
from pathlib import Path
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_path
... |
d1f14eda9e7e337ac7f1fb44af9e4b16cf94537aeb8582b5fe93a31bdb7acd76 | Python | 2,106 | 68 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... |
21df30e925597432a6fa06dff3bb471b54d3e241b7e438ffaea709822ab0e0bc | Python | 2,107 | 67 | """
Visualize the wave detection by means of clustering the detected trigger
in (time,x,y) space.
"""
import numpy as np
import quantities as pq
import argparse
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
import seaborn as sns
import random
import warnings
from utils.io_utils import lo... |
86593fda648b38ca02b1c30983d624676478afa302bea2c98b7d321530e8382e | Python | 2,109 | 70 | # Copyright (c) 2021 PaddlePaddle Authors. 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
#
# Unle... |
db321173ac8e9c507486e9f38cc79cdc7315ebde5f28c902a4daa990ba54ef70 | Python | 2,109 | 61 | import tensorflow as tf
import numpy as np
from PIL import Image
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
import lattice_filter_op_loader
from crf_rnn_layer import crf_rnn_layer
module = lattice_filter_op_loader.module
rgb = np.array(Image.open('image.jpg'))
gt =... |
866b7e14696f151eea1cbd65195d2e92d4fe2d7f16af6b8a9b6628cc90b2660e | Python | 2,110 | 51 | import unittest
from rdkit import Chem
from reinvent.chemistry.library_design import bond_maker, attachment_points
from reinvent.chemistry.library_design.reaction_filters import ReactionFiltersEnum
from reinvent.chemistry.library_design.reaction_filters.reaction_filter import ReactionFilter
from reinvent.chemistry.li... |
14000b7e419b29f26edb324b8bfcd9720cc7d30f20117c054e83069f2753f8ac | Python | 2,113 | 69 | import predictive_coding as pc
import torch
def create_model(predictive_coding, acf, model_type_order, cnn_layers, linear_layers, loss_fn=''):
model_type_order = eval(model_type_order)
model = []
for cnn_key, cnn_layer in cnn_layers.items():
for model_type in model_type_order:
if mo... |
196e4a10593f9222510b30159b11b3bd20a8848b557c2cafae8fde674b95557c | Python | 2,114 | 69 | import os
import sys
import numpy as np
project_root = ".."
sys.path.append(project_root)
DATASETS_PATH = os.path.join(project_root, "resources", "datasets", "nsrr")
if __name__ == "__main__":
dataset_name_list = [
"shhs1",
]
top_k = 40
epoch_samples = int(200 * 30)
for dataset_name i... |
86dfd3d34c137ba95789abd98bf1191adc1708e5476738b9e15975569acc4683 | Python | 2,115 | 64 | import numpy as np
import torch
from torch_geometric.data import Data
from sklearn.preprocessing import StandardScaler
def select_target_id(ds_geometric, target_id):
geom_data = []
for data in ds_geometric:
data_obj = Data(
z=data.z,
pos=data.pos,
y=data.y[target_id... |
cb37e5918cabc8f80d815e23cec5b902438e53da767a53e35c5201a81230c14d | Python | 2,116 | 59 | """Reconstruct a bundled image using Proj2Proj without external data or weights."""
import argparse
from pathlib import Path
import numpy as np
from skimage.transform import iradon
from sparse_ct.data import image_to_sparse_sinogram
from sparse_ct.reconstructor_2d import Proj2ProjReconstructor
from sparse_ct.tool im... |
652fada23ca7b18cdc17a1e11d6a03b8d4ed6f0af6f5b5f37a8fdbf2883e1c86 | Python | 2,117 | 72 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import numpy as np
from . import BaseWrapperDataset
logger = logging.getLogger(__name__)
class SubsampleDataset(BaseWrapp... |
7cc21de7d72f2d98cd5725430d21ebe27ca0e91c7933a07978638bd4f48d2e57 | Python | 2,117 | 71 | """Perform tangent PCA at the mean on H2."""
import logging
import matplotlib.pyplot as plt
import numpy as np
import geomstats.visualization as visualization
from geomstats.geometry.hyperboloid import Hyperboloid
from geomstats.learning.frechet_mean import FrechetMean
from geomstats.learning.pca import TangentPCA
... |
72508ed6652e4f7e291b49351df3bc79e9a52995da2bee32658fb0cca86de7ef | Python | 2,118 | 62 | import torch
import math
import torch.nn as nn
class BERTEmbedding(nn.Module):
"""
BERT Embedding which is consisted with under features
1. TokenEmbedding : normal embedding matrix
2. PositionalEmbedding : adding positional information using sin, cos
2. SegmentEmbedding : adding senten... |
9e16bd28d8eb8c0dab780e2764491d793cc5728aba6bb45b07fc605145819b01 | Python | 2,118 | 59 | class Dataset(BaseDataset):
"""CamVid Dataset. Read images, apply augmentation and preprocessing transformations.
Args:
images_dir (str): path to images folder
masks_dir (str): path to segmentation masks folder
class_values (list): values of classes to extract from segmentation mask... |
870194b9cffb53222dc5f147e924a242932500958c735a89b0cf512210a6278b | Python | 2,119 | 60 | import pytest
import geomstats.backend as gs
from geomstats.datasets.prepare_emg_data import TimeSeriesCovariance
from geomstats.datasets.utils import load_emg
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test.test_case import TestCase, np_and_autograd_only, pytorch_backend
from .data... |
9d9606e24c4b3a0ab7a20558534a30233bfaaa018bcd1b95765fc4eb32c1c2e8 | Python | 2,119 | 63 | """Pytest module-wide configuration file.
Adds a ``--backends`` CLI option that lets users select which PyRates
backend(s) the per-backend test suites should run against. Tests that take a
``backend`` fixture argument are automatically parametrized over the selected
list.
Examples:
pytest tests/ ... |
bd91a29813061ffe0e90107cd5d1254bb771313cc5103fd9dc5e087183107699 | Python | 2,120 | 87 |
from sleepy.gui.tagging.model.event import Event
import pdb
class PointEvent(Event):
def __init__(self, point, dataSource, applicationSettings):
super().__init__(dataSource, applicationSettings)
self.point = point
@property
def label(self):
return self.point
... |
bfae57bcf1b56e7121f3b4bd046b890b840ef359d57a9dce4c817215ab7eb57b | Python | 2,120 | 41 | """
This test function has been furnished by Lvtongxuan BGI:28650
If you have any Question
please chat with me by using
Wechat : lvtongxuan666
or Email : lvtongxuan@genomics.cn
if you want to make it better
please check the README.md and set parameter by yourself
"""
import warnings
from EAGS.EAGS_function impor... |
6907572e9f583a79c9048a7fac05c8243297e67da1378b91c716f78a6831b438 | Python | 2,121 | 69 | import geomstats.backend as gs
from geomstats.test.data import TestData
from ...test_geometry.data.base import VectorSpaceOpenSetTestData
from ...test_geometry.data.riemannian_metric import RiemannianMetricTestData
from .base import InformationManifoldMixinTestData
class PoissonDistributionsTestData(
Information... |
70c2bdda27c9be131f6b4cf387efe25208f5124a5f9f899207d9843de16f891d | Python | 2,123 | 59 | class Dataset(BaseDataset):
"""Ulstrasound Dataset. Read images, apply augmentation and preprocessing transformations.
Args:
images_dir (str): path to images folder
masks_dir (str): path to segmentation masks folder
class_values (list): values of classes to extract from segmentation... |
db20a36ca5f0e9eac58efe870800db4d4f6df93b9725884e100380d76a463a2c | Python | 2,123 | 54 | import argparse
import pandas as pd
import numpy as np
import sys
from pathlib import Path
sys.path.append(str(Path.cwd().parents[0] / 'plot_figures' / 'scripts'))
from plotting_utils import df_dtypes, int_types, float_types
def load_df(path, usecols=[]):
df = pd.read_csv(path,
usecols=lambda... |
b66af36565cd61b830c72babf9c24a4ed37adcc373755c54fa1be9112583a451 | Python | 2,124 | 68 | from numpy import zeros
from .butter_bandpass_filter import butter_bandpass_filter
from .doKuramoto import doKuramoto
from .doHilbert import doHilbert
def run_multiPatKOP(RSsig, base=2, nBits=8, delt = 0.392, flp=.04, fhi=.07, k=2):
"""Run KOP Routine for BOLD signal.
Args:
RSsig (ndarray): BOLD sign... |
be2270dccd987e43b2c6d0b2989685b80c360297cba548107f133e0dcc6ec786 | Python | 2,124 | 84 | #!/usr/bin/env python
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from infomap import infomap
"""
Generate and draw a network with NetworkX, colored
according to the community structure found by Infomap.
"""
def findCommunities(G):
"""
Partition network with the Infoma... |
95223b2b3d0f599f870a9780611db0298474e2760fab19982b2f999b68a1296c | Python | 2,127 | 67 | # Copyright (C) 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""You may copy this file as the starting point of your own model."""
from openfl.federated import KerasDataLoader
from src.mnist_utils import load_mnist_shard
class MNISTInMemory(KerasDataLoader):
"""Data Loader for MNIST Dataset... |
9699adcde854012dce156a48f24c4154766fa54f1468999fad6bd33c0acd3c03 | Python | 2,127 | 84 | """Create a Lbinvent model from a list of SMILES strings"""
from __future__ import annotations
import time
import uuid
from reinvent.models.libinvent.models.model import DecoratorModel
from reinvent.models.libinvent.models.vocabulary import DecoratorVocabulary
from reinvent.models.libinvent.models.decorator import De... |
e83d6c56a78cc3d755051b235f791cb063b6593712086db5fcd10eeb412ce94d | Python | 2,127 | 67 | import fastdeploy as fd
import cv2
import os
def parse_arguments():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"--tinypose_model_dir",
required=True,
help="path of paddletinypose model directory")
parser.add_argument(
"--det_model_dir", help... |
9ec5a75706ea2806b3dd4f2004e95d20674d0bf725836f8be51a588665fd9e16 | Python | 2,131 | 57 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Numpy optimizers tests module."""
import numpy as np
import pytest
from openfl.utilities.optimizers.numpy.adagrad_optimizer import NumPyAdagrad
from openfl.utilities.optimizers.numpy.adam_optimizer import NumPyAdam
from openfl.utilit... |
c78430b982c00819c67f6cfcba75a2cd9d04e86022934785b2e1b54e8f14c84d | Python | 2,133 | 44 | from .contrastive import Contrastive
from dig.sslgraph.method.contrastive.views_fn import NodeAttrMask, EdgePerturbation, Sequential
class GRACE(Contrastive):
r"""
Contrastive learning method proposed in the paper `Deep Graph Contrastive Representation
Learning <https://arxiv.org/abs/2006.04131>`_. You c... |
d272794be5a10a117d663c9cd925fed323104b01187b4310f4fd1cf11196ba3a | Python | 2,133 | 66 | import pytest
import unittest
import torch
import torch.utils.data as tud
from reinvent.models.linkinvent.dataset.dataset import Dataset
from reinvent.runmodes.utils.helpers import set_torch_device
from tests.test_data import WARHEAD_PAIR
from tests.models.unit_tests.linkinvent.RNN.fixtures import mocked_linkinvent... |
dc50639eedcdc410f8a3df92e36a1b4aea3d7ce18b1893d13e6f43b7b4268786 | Python | 2,133 | 57 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Yogi adaptive aggregation module."""
from typing import Dict, Optional, Tuple
import numpy as np
from openfl.interface.aggregation_functions.core import AdaptiveAggregation, AggregationFunction
from openfl.interface.aggregation_functi... |
1b08fac68ce6c495c0dec1f2424fb09672af87ac534a6c0f1b4c65e79eecdd27 | Python | 2,134 | 68 | from __future__ import annotations
from typing import List
import logging
from . import terminators
from .terminators import terminator_callable
from reinvent.runmodes import RL
from reinvent.runmodes.RL.data_classes import WorkPackage
from reinvent.runmodes.RL.setup.diversity_filter import setup_diversity_filter
fro... |
4d862f785937d0413388a6f0d46ea77c669c9c4359852926fe669da6baa4e83e | Python | 2,134 | 57 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Adam adaptive aggregation module."""
from typing import Dict, Optional, Tuple
import numpy as np
from openfl.interface.aggregation_functions.core import AdaptiveAggregation, AggregationFunction
from openfl.interface.aggregation_functi... |
23260053594e1b314725238ef08285516b1673e478f42c62831492619acf5f21 | Python | 2,135 | 63 | from PymoNNto.Exploration.Network_UI.TabBase import *
import pyqtgraph.opengl as gl
class OpenGLTab(TabBase):
def __init__(self, variable='voltage', title='OpenGL Neurons'):
super().__init__(title)
self.variable = variable
def add_recorder_variables(self, net_obj, Network_UI):
return
... |
71bb0e8f59e47d4210df223de33740700a13bfb596abb29517ce0a1093bb2bc1 | Python | 2,137 | 71 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 15:25:17 2018
@author: ngritti
"""
import sys
sys.path.append('..')
from deeprest.rawDataClass import rawData
import time, glob, os, shutil
from tifffile import imread, imsave
from skimage.filters import threshold_otsu
import numpy as np
from sci... |
7b4022e679d073d2da305604926fff13bdb9c0069afc941a855b5c6ec83e2042 | Python | 2,137 | 60 | import numpy as np
import pandas as pd
import sys
import os
dirname = './'
train_dirname = './training_data/'
test_dirname = "./testing_data/"
meta_train = pd.read_csv(dirname + 'training_metadata.csv')
meta_test = pd.read_csv(dirname + 'testing_metadata.csv')
train_gene_fileName = meta_train[meta_train['OmicsTy... |
6669db96846a02453b8d544d06f5015e2b80e3ca2304988f3f1efc0590cc3433 | Python | 2,139 | 51 | import pytest
import geomstats.backend as gs
from geomstats.geometry.klein_bottle import KleinBottle
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test.random import RandomDataGenerator
from geomstats.test.vectorization import generate_vectorization_data
from geomstats.test_cases.geomet... |
2809cc376e48846902899f6fd3093e1b880249ce018bd2189f60c5e2aade1190 | Python | 2,140 | 67 |
import torch
import torch.nn as nn
from functools import partial
from hflayers import Hopfield
from .utils.initialization import get_initializer
def init_lecun(m):
nn.init.normal_(m.weight, mean=0.0, std=torch.sqrt(torch.tensor([1.0]) / m.in_features).numpy()[0])
nn.init.zeros_(m.bias)
def init_kaiming(m,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.