sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
b8865080ddd404311949c5406bf513d2ae5cad85a9accaa8c7f59fb54c3af09f
Python
7,781
205
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import logging import os import sy...
4af0ce46c9b7af8e93864902f12d48c316394ff1e31ade40ca261387a15eab91
Python
7,782
196
# 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. from typing import Dict, List, Optional, Tuple import torch import torch.nn as nn from torch import Tensor from fairseq import utils from fa...
40a8699e2f9e4d46728f040c2aded4f6b5bba729cd907d5d75c4d1ce825bb8d4
Python
7,788
266
import torch import utils import numpy as np import torch.nn.functional as F from torch.utils.data import DataLoader from torch.nn.modules.loss import _WeightedLoss from sklearn.metrics import roc_auc_score def collate(batch): protein_list = [] label_list = [] info_list = [] id_list = [] device ...
7388b1a2bc3477c8b9121451c1677aa3d0affa882bd02280175904bf0135b6aa
Python
7,790
229
# Copyright (C) 2020-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import sys from openfl.experimental.workflow.interface import FLSpec, Aggregator, Collaborator from openfl.experimental.workflow.runtime import LocalRuntime from openfl.experimental.workflow.placement import aggregator, collaborator cl...
73332cb43f16f9814ca2d7fe725d67fe762dca863f857cd6e772febec43c6570
Python
7,796
209
""" Created on Tue Jun 15 16:14:39 2021 @author: Mathieu Scheltienne """ from abc import ABC, abstractmethod import cv2 import numpy as np from matplotlib import colors from screeninfo import get_monitors from ... import logger class _Visual(ABC): """ Base visual class. Parameters ---------- ...
83485d69a9c4e0a9bd95e47b6644e7a8ca0e4c09d586315c70ecb039124fbc10
Python
7,797
213
from configuration import * from spikeinterface.sortingcomponents.benchmark.benchmark_motion_interpolation import BenchmarkMotionInterpolationMearec from spikeinterface import compute_sparsity import MEArec as mr import numpy as np from plotting_tools import removeaxis, label_panel from figure_estimation import dri...
945bbaa70aead8bfad0fc6876e3daa46d302afa7a13dc864b7652ed662bd6df4
Python
7,797
238
import numpy as np import matplotlib.pyplot as plt import torch import torch.nn as nn from torch.optim.lr_scheduler import StepLR,MultiStepLR import math import torch.nn.functional as F from torch.utils import data from sklearn.model_selection import train_test_split from torch.utils.data import Dataset from ssc_datase...
39bf283ff6cc2bd34acf75925eb902489133dd4698140531e2792a493684ca2e
Python
7,799
238
"""Unit tests for mace/tools/arg_parser.py. We test the *contract* of the parsers, not every one of the ~200 flags: * ``build_default_arg_parser`` builds and parses a minimal valid command line (only ``--name`` is required). * Critical defaults the rest of the codebase relies on (dtype, device, model, loss, cutof...
006a3eb5db67fc3b61bc32281e172e4306efb4fe57a140088137b99575c0a08e
Python
7,801
231
# -*- coding: utf-8 -*- """ Created on Fri Jul 23 11:25:14 2021 @author: nicol """ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 12 15:25:17 2018 @author: ngritti """ import time, os, glob from tqdm import tqdm import numpy as np from skimage.io import imread import seaborn as sns import pand...
7c8190070640c53be26cdc95e682bad5e4258fa5b41f7b4da1f423b5adffc131
Python
7,801
189
""" This is the data preprocessing that should return the .pt with the data to run the model TO BE EXECUTED FROM MAIN FOLDER (relative paths) """ import os import pandas as pd from scipy.sparse import csr_matrix import json import argparse from rdkit import Chem from rdkit.Chem import Descriptors import torch fro...
508410736011a8d611e771b21248649e91b1becb1cdcff0dd931b69f5bc7fc2d
Python
7,809
234
from functools import partial from PyQt5 import QtWidgets, QtGui, QtCore from sanpy.sanpyLogger import get_logger logger = get_logger(__name__) EDITABLE_SPIKE_RESULTS = ("spike_condition", "userType", "spike_include") import sanpy from sanpy.interface.plugins import sanpyPlugin class ComboBox(QtWidgets.QComboBox...
66a6b3b1610e66198392c1d351a421691d5dfe78dd62168379d05d3d58834e2a
Python
7,813
204
""" Non-linear Oscillator Entrainment ================================= In this tutorial, we will examine entrainment of a `Van der Pol oscillator (VPO) <https://en.wikipedia.org/wiki/Van_der_Pol_oscillator>`_ that receives oscillatory input from a simple `Kuramoto oscillator (KO) <https://en.wikipedia.org/wiki/Kuramo...
e7274118159c4e4df45e3baf9c5b067cba00f9407e93b1f5e3d9f46fb2d71c82
Python
7,823
222
"""Tests for runtime-owned detection and analysis-result definitions.""" import uuid import pytest from pydantic import ValidationError from sanpy.bAnalysisResults import ( AnalysisResults, get_analysis_result_definitions, get_plot_result_definitions, new_result_values, ) from sanpy.bDetection import...
e3dbca8284afc90002b71da8854d5860c58707da6b4ec80c32275349de2375f8
Python
7,826
237
"""Create and reopen local-only DANDI Dandisets of SanPy NWB files.""" from __future__ import annotations from collections.abc import Mapping, Sequence from dataclasses import dataclass import os from pathlib import Path import re import tempfile from typing import Any from pydantic import BaseModel, ConfigDict, fie...
1b50a0ca02a30fab1dace169d5ab494b2d708fc3d5a9944413d86f898418760a
Python
7,827
204
""" Non-linear Oscillator Entrainment ================================= In this tutorial, we will examine entrainment of a `Van der Pol oscillator (VPO) <https://en.wikipedia.org/wiki/Van_der_Pol_oscillator>`_ that receives oscillatory input from a simple `Kuramoto oscillator (KO) <https://en.wikipedia.org/wiki/Kuramo...
552ee22adc869a6c61e89d5c7b2813c865bca80a5901418e40526345f2e1051e
Python
7,827
209
# 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...
b85574cf67d4e1bd9aa382dc56f8705445e5e921de1c2c83fab5f8fc7b97ba0f
Python
7,830
235
########################################################################################### # Checkpointing # Authors: Gregor Simm # This program is distributed under the MIT License (see MIT.md) ########################################################################################### import dataclasses import loggi...
ad832258b2e1598fe1546200e23f9a0be45d154af8e3c2f10cb3e802a74848d9
Python
7,835
229
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as np import scipy.signal as sig import matplotlib.pyplot as plt import matplotlib.colors as colors from matplotlib import cm # main program if __name__ == "__main__": # Define paths to compare datapath = "/home/nikos/Documents/projects/Python/memstim-hh/...
c4d82452a1004c439ee928f4281ccdc6ea7714a5e9b33d0ea80d468454e4d4b9
Python
7,837
180
"""The published MACE-Polar model reproduces its committed reference. ELEC-2 rebuilds ``PolarMACE`` on the new architecture and converts this checkpoint onto it; this file is the number it has to land on. What is pinned is the whole surface the calculator exposes -- the energy/force/stress side *and* the electrostatic...
25dd248d40a183e83c3db1c94e199a41fb27db82a13ce27d96a2cecc1507c813
Python
7,838
196
# -*- coding: utf-8 -*- import os import argparse import logging import glob import numpy as np from data_functions import load_data, TwoPopAlignmentFormatter, load_data_slim, read_slim_out from mpi4py import MPI import h5py import matplotlib.pyplot as plt # use this format to tell the parsers # where to insert ce...
53d1b347bbc6f2fd26769956549e504b040ed94ac5adb6ad63ee1589b45f94ff
Python
7,840
178
import os import tensorflow as tf import multiprocessing as mp # from https://github.com/oxpig/kasearch/blob/main/kasearch/canonical_alignment.py CANONICAL_NUMBERING = ["1 ", "2 ", "3 ", "3A", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10 ", "11 ", "12 ", "13 ", "14 ", "15 ", ...
67cbf2b87737d7d1326df1f0ae56471dd1344e0884c2bbc36053925b59374831
Python
7,840
177
import pandas as pd import torch from torch.utils.data import DataLoader, TensorDataset from sklearn.metrics import confusion_matrix, classification_report, precision_recall_fscore_support from scipy.interpolate import interp1d import math from modelClasses import * from utilityFunctions import * os.environ['CUDA_LAUNC...
1c07f89e55f0958a0bccbf9ae041d0ff60632df28825e0bcfd31f43cc17db143
Python
7,844
194
import chromadb import chromadb.test.property.invariants as invariants import chromadb.test.property.strategies as strategies import copy import hypothesis.strategies as hyst import logging import pytest from chromadb.api.models.Collection import Collection from chromadb.test.conftest import ( reset, skip_if_n...
995e89fe2287f942b2b9ba683c50d1136158615db0848ba5e294d3df4508f93b
Python
7,844
201
"""Spatial RSA computes ordinary stacks with explicit external mapping.""" from __future__ import annotations import nibabel as nib import numpy as np import pytest from nltools.data import Adjacency, BrainData def _atlas_for(bd, n_rois=2): """Return a labeled atlas Nifti aligned with bd.mask, partitioning the...
523e9ff6f10665efa1cf908bdee7be57b37fcea535694656f085b288896a8e19
Python
7,845
162
import dill as pickle import pandas as pd from sklearn import model_selection from sklearn.utils import resample import numpy as np import logging, coloredlogs from collagen.data import Splitter coloredlogs.install() class HiarFoldSplit(Splitter): def __init__(self, ds: pd.DataFrame, train_size_per_class: int, ...
5ed78a6191e0f739beb7e8d3b035e494748417ac267dca3f98ce18e3c3d65f13
Python
7,848
191
import torch import torch.nn as nn import torch.nn.functional as F from torch_scatter import scatter from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GINConv class Readout(nn.Module): def __init__(self, node_feat_dim, node_hiddens, graph_hiddens, use_gate=True, pool_type='add'): ...
ce8c09b8d318ae367c424faa4d6a9fb798f2ae48af4fef2a3370ab4342fcf050
Python
7,848
191
# /usr/bin/env python3 # coding: utf-8 # # This software and supporting documentation are distributed by # Institut Federatif de Recherche 49 # CEA/NeuroSpin, Batiment 145, # 91191 Gif-sur-Yvette cedex # France # # This software is governed by the CeCILL license version 2 under # French law and abi...
0fbfd97081a01780407c2042b1377541bef78c283268d80b1ccae549f7c29ed5
Python
7,852
249
""" Implementation of dFC methods. Created on Jun 29 2023 @author: Mohammad Torabi """ import time import numpy as np from joblib import Parallel, delayed from scipy import signal from sklearn.covariance import GraphicalLasso, GraphicalLassoCV from ..dfc import DFC from ..time_series import TIME_SERIES from .base_d...
be5b6e9adc03ae1341f20b762348acbe92697a01c18794deb0c0e6f0a7da92c4
Python
7,853
222
"""Visualise the uncertainty of the empirical Fréchet mean on the sphere. The variance of the Fréchet mean FM_n of a sample of n IID random variables of variance Var is decreasing more slowly in a sphere than in a Euclidean space. This example computes the modulation factor alpha = Var( FM_n) / ( n * Var) for is...
019457c97a3b9176a34a696de2baf4399087bd7cb6e1f012877350621f61bb56
Python
7,854
223
import torch import torch.nn as nn import torch.nn.functional as F from .df_utils import one_hot_argmax class ST_Net_Sigmoid(nn.Module): def __init__(self, input_dim, output_dim, hid_dim=64, num_layers=2, bias=True, scale_weight_norm=False, sigmoid_shift=2., apply_batch_norm=False): super(ST_Net_Sigmoid, s...
67fe197015f62507918f744834df950c8a11143c8e4ddb1a64fd5af7e542eaf2
Python
7,854
188
"""Dataclasses to hold transformed and aggregated result from components.""" from __future__ import annotations __all__ = ["ComponentResults", "SmilesAssociatedComponentResults"] from dataclasses import dataclass, field from typing import List, Dict, Optional, Set import numpy as np @dataclass class SmilesResult: ...
456c6a42a72fb4ecd10da1783b00bb6036fe27f8ca59957189ab6e53b4d6fc70
Python
7,856
217
# bi-directional srnn within pkg import numpy as np import matplotlib.pyplot as plt import torch import torch.nn as nn from torch.optim.lr_scheduler import StepLR,MultiStepLR import math import torch.nn.functional as F from torch.utils import data from SNN_layers.spike_dense import *#spike_dense,readout_integrator fr...
1174b6459012875f42d9148338334db7efd7203958a6c0586ed24d8c0a9a373a
Python
7,860
205
# ============================================================================== # Copyright 2025 Technical University of Denmark # Author: Nikolas Borrel-Jensen # # All Rights Reserved. # # Licensed under the MIT License. # # Convert 2D data (generated with Matlab) to 3D data format (separate H5 files per source) imp...
7de0c239b0e0bb5f68b9ffd30acab38d1d732f0ff8c502e12a9673415d400feb
Python
7,864
228
"""`mace_plot_train` against a real results log. The plotting CLI had no test at all, and the results log format it parses had none either, so nothing connected the two: `mace_run_train` is free to rename a column and the only symptom is a plot nobody generates in CI. That absence was hiding a CLI that could not run....
8ef154709b7770eb065798c061f08b5eaf8855aabc6043efdfbf007a34cd9d02
Python
7,867
266
# 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 appli...
9cecfcbee219be7d435390513f5f6c699b2b869744e10fa298899fe66c90cd33
Python
7,872
173
from __future__ import print_function import os import sys from argparse import ArgumentParser, RawDescriptionHelpFormatter from argparse import ArgumentTypeError from .core import process_file def run(filename, output=None, model_capacity='full', viterbi=False, save_activation=False, save_plot=False, plot_...
ccfe97a7229302a783acf07f853eaf28b690bd5ea64cad07d851b2f666995dd5
Python
7,872
211
"""Multi-stage learning with RL""" from __future__ import annotations import logging import torch from reinvent.utils import setup_logger, CsvFormatter, config_parse, get_tokens_from_vocabulary from reinvent.runmodes import Handler, RL, create_adapter from reinvent.runmodes.setup_sampler import setup_sampler from re...
67368310391d5011b3e0da9963ad40a32b5009c5b8dfd5869656ddb560a6bba5
Python
7,877
136
import os import torch from pytorch_lightning import Trainer from pytorch_lightning.callbacks.early_stopping import EarlyStopping from pytorch_lightning.loggers import TensorBoardLogger from metrics import Metrics from models.lightning_rnn import LITGRU from modules.data_module import FireflyDataModule, RealFireflyDa...
571f07b291d47337d171203dd00a6fd58010b5aa3b7825ca19ba486eddad9bfa
Python
7,879
190
""" gathering the accuracy as a function of time (changing due to memristive drift) """ from SHIP import TensorHauler,network,liN,inputN from braille_task_utils import (load_braille_dataset, delta_encoding, select_datasets) from torch import (tens...
cc2b6d1f12bac7460ac63b7d0ee13bad13864d00e7bbf651d1510eda49d1459b
Python
7,879
234
import numpy as np import matplotlib.pyplot as plt import torch import torch.nn as nn from torch.optim.lr_scheduler import StepLR,MultiStepLR import math import torch.nn.functional as F from torch.utils import data from sklearn.model_selection import train_test_split from torch.utils.data import Dataset from ssc_datase...
44792e9f2759aa82a4fd3ff268e0da63d7219c39bc0b7968f265d981302fcbc4
Python
7,882
231
""" Benchmark: legacy scalar-edge API vs. new PopulationTemplate + Connectivity API. Network: N Wilson-Cowan excitatory nodes, all-to-all coupled with a random weight matrix W (diagonal = 15.0, off-diagonal ~ N(0, 1/sqrt(N))). Run with: conda run -n sbi python examples/benchmark_population_connectivity.py """ im...
fb77e3d5756f704d5e208efdce36978f724a6ce6eb92a7eee924cd38bda5cfee
Python
7,889
256
import torch import torch.nn as nn import torchvision.transforms as transforms import torchvision.datasets as dsets import torch.nn.functional as F import numpy as np from torch.autograd import Variable from torch.optim.lr_scheduler import StepLR,MultiStepLR import matplotlib.pyplot as plt import math from sklearn.util...
43fbd2f53e024c2bfafef99fa59ad5883d7a2f0538a890b416cc893165c50bb9
Python
7,899
246
"""The manifold of positive reals. This manifold is a particular case in dimension 1 of the SPD matrices endowed with the SPD affine-invariant metric with a power affine coefficient equal to one. This manifold is used as part of a product manifold involving complex Poincare disks to classify complex stationary centere...
8a1166a0b98e7757712d16068c002e6434e561715d9a0869681edae4bc1b76bb
Python
7,901
262
""" Data logging processes Author: Tal Eisenberg, 2021 """ import csv from datetime import datetime from pathlib import Path import multiprocessing as mp import rl_logging import database as db from video_stream import ImageObserver import managed_state from configure import get_config class DataLogger(mp.Process):...
928f68bd3850aaf7b5a38e0eedc84168e6ae553457d821c35e83e005865e9ebe
Python
7,902
251
from __future__ import annotations import re import sys from typing import ( TYPE_CHECKING, Any, AnyStr, Container, Dict, Generic, Hashable, Iterable, Iterator, Sequence, SupportsIndex, TypeVar, overload, ) from typing_extensions import Self, override _T = TypeVar(...
a893564bf0acdd027c390db9c6502f6a3c206928a9ef7cc07a8018a672de6e61
Python
7,903
201
# ############################################################## # This file is received from # https://github.com/DmitryUlyanov/deep-image-prior/blob/master/models/unet.py # It is the implementation of the following study: # https://arxiv.org/abs/1505.04597 # The code is licenced under Apache 2.0 licence # https://git...
a178b5c270c4608b7a3c90681b63a2af2b770c8a53a2dab85de7c25e54214808
Python
7,905
235
import os import torch import matplotlib.pyplot as plt # torch.multiprocessing.set_start_method('spawn') os.environ['CUDA_VISIBLE_DEVICES'] = "2" print('todo 0502: benchmark for pretrained_models') # to maintain the same parameter configuration saving_name = 'tiny_snn_room_epoch100_origin_exp4_seq5_time5ms_3layer_test...
dc92fc9fca1aa8ef9a2bb86af4a66dd981195c4167cb1d20a86059eb83c20709
Python
7,906
264
import os import pickle import random from collections import OrderedDict from glob import glob import numpy as np import torch LEADSETS = { 12: ["I", "II", "III", "aVR", "aVL", "aVF", "V1", "V2", "V3", "V4", "V5", "V6"], 8: ["I", "II", "V1", "V2", "V3", "V4", "V5", "V6"], 6: ["I", "II", "III", "aVR", "aV...
e7f705b52e3f88bdcdb9a00a9e6233c915a4dd9467068deea3a62c9fe8f678d4
Python
7,912
239
"""Vocabulary helper class""" import re import numpy as np class Vocabulary: """Stores the tokens and their conversion to one-hot vectors.""" def __init__( self, tokens=None, starting_id=0, pad_token=0, bos_token=1, eos_token=2, unk_token=None ): self._tokens = {} self._current_...
ec0e10c71a51ed11099772b32fdbdce0893d1e36641c40532cbaad736e03653c
Python
7,912
198
""" Sliding-window module Sliding-window analysis. The code is a python adaptation from the code used by Vasa et al. (2018). It outputs a spreadsheet for each window, where the IDs of that window and the sorting variable are output. It also outputs some descriptive stats for the sorting variable in each window. """ ...
e0932b72c55c2393f1df708a6aaabbfaf252fc247ff2cec394e625cd47ca2951
Python
7,913
246
# Copyright 2020-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """STCPipelinemodule.""" import copy import gzip as gz import numpy as np from openfl.pipelines.pipeline import TransformationPipeline, Transformer class SparsityTransformer(Transformer): """A transformer class to sparsify input dat...
b99f70579120a583bb8acbc359c4f2508f78e20254b48d6a220628a32a357ee4
Python
7,919
205
#### pyClusterROI_test.py # Copyright (C) 2010 R. Cameron Craddock (cameron.craddock@gmail.com) # # This script is a part of the pyClusterROI python toolbox for the spatially # constrained clustering of fMRI data. It is a demonstration of how to use the # toolbox and a regression test to make sure that the toolbox code...
2a4399c43a9641f4c9fb8e4a6fec54bac5ad1a01a1dae782f339f10b71efc68c
Python
7,923
157
# %% import os import numpy as np import time import h5py import sys from scipy.io import savemat, loadmat import multiprocessing as mp sys.path.insert(1, '../..') # the path containing "suns" folder os.environ['KERAS_BACKEND'] = 'tensorflow' # os.environ['CUDA_VISIBLE_DEVICES'] = '0' # Set which GPU to use. '-1' use...
c33bfe5383eb45e91478a7cb1a0de3a99e119373a0a61c5324c135f22aaa7957
Python
7,927
263
""" Data logging processes Author: Tal Eisenberg, 2021 """ import csv from datetime import datetime from pathlib import Path import multiprocessing as mp import rl_logging import database as db from video_stream import ImageObserver import managed_state from configure import get_config class DataLogger(mp.Process)...
0916a0dc139e2e5bd392ef5d998806ad05b38575675a1ef9d896bfab7a8d3fa6
Python
7,936
247
"""Module exposing the GeneralLinear group class.""" import geomstats.algebra_utils as utils import geomstats.backend as gs from geomstats.geometry.base import VectorSpaceOpenSet from geomstats.geometry.lie_algebra import MatrixLieAlgebra from geomstats.geometry.lie_group import MatrixLieGroup from geomstats.geometry....
9827e679de4da0c62311708eabce886cd0c649530da39cf95e07d5c25715f326
Python
7,946
194
""" ICC subject and task """ from argparse import ArgumentParser import warnings import re import os import numpy as np import pandas as pd import pingouin as pg def main(): """ Launching ICC analysis """ print('---------------------------------------------') print('-------Edge-wise Intraclass Correla...
6f2c2ed5981601f6b0a29ae1611108589af5ac75f0a650a47880542c91acea45
Python
7,950
242
""" Count secondary structures in a PDB file as determined by p-sea https://www.biotite-python.org/apidoc/biotite.structure.annotate_sse.html """ # Examples: # python ~/projects/protdiff/bin/annot_secondary_structures.py sampled_pdb/*.pdb plots/ss_cooccurrence_sampled.pdf # python ~/projects/protdiff/bin/annot_second...
3170de7de568f9f72bae5feb0af21f3c37a31a7dcf7038f75a42e7a424ec2284
Python
7,952
215
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as N import os from sklearn.linear_model import LinearRegression from sklearn.metrics import explained_variance_score from sklearn.model_selection import KFold from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from s...
d8611e3bd34613f694ed45448fdacefab0bd9af79a6485ebf45115ccd96e730c
Python
7,953
167
"""Derived identifiers for the levels above and below a curated record. A record is a receptor against a presented peptide, and both halves recur across records, so each half needs a name of its own. Four levels do, and all four key on content that has no separate existence: there is no such thing as a clonotype apart...
93ebaa4940585fb676ee1e56ab2cbae65cd5c8b85911936b16efa2861752bed5
Python
7,956
229
from pathlib import Path import imageio.v2 as imageio import matplotlib.pyplot as plt import numpy as np import ppafm.ml.AuxMap as aux import ppafm.ocl.field as FFcl import ppafm.ocl.oclUtils as oclu import ppafm.ocl.relax as oclr import torch from matplotlib import cm from ppafm.ml.Generator import InverseAFMtrainer...
66ce0a5d4e84e2b06b5da423d6adea3733f7926c018f3575eb5ceeaa623096ba
Python
7,957
201
# -*- coding: utf-8 -*- # # # PyRates software framework for flexible implementation of neural # network models and simulations. See also: # https://github.com/pyrates-neuroscience/PyRates # # Copyright (C) 2017-2018 the original authors (Richard Gast and # Daniel Rose), the Max-Planck-Institute for Human Cognitiv...
4cee0caa44cf510e6291e4e8d9f4e056d69bda37d2b8b88c3560b1e59c1e76ad
Python
7,960
250
# 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...
8675dec900130e81a8f158620059393bfa0cb7d2b4a6e7f05295b7ae032409ba
Python
7,966
268
"""Code to construct the VLAAI network. Code was extrcted from https://github.com/exporl/vlaai """ import tensorflow as tf def extractor( filters=(256, 256, 256, 128, 128), kernels=(64,) * 5, dilation_rate = 1, input_channels=64, normalization_fn=lambda x: tf.keras.layers.LayerNormalization()(x), ...
4193780384d88a3d75134b4bfbe781a9e4facdcbcbbd3ac1d8037fcbbbcd43d9
Python
7,967
257
import community import markov_clustering as mc import networkx as nx from scipy.sparse import csr_matrix import torch from torch_scatter import scatter_max, scatter_mean from torch_geometric.nn.pool.pool import pool_edge, pool_batch, pool_pos from torch_geometric.nn.pool.consecutive import consecutive_cluster from to...
d3b537785cd9fcd1d85dd97008ce6a03a7826fa18e46648090b7db073100b2e5
Python
7,968
179
import math import json from openpyxl.worksheet.table import Table, TableStyleInfo from openpyxl.styles import Alignment from nilearn import plotting,image,surface,datasets from utilityFunctions import * import collections bn_atlas_file = 'PROJECT_DIR/scripts/features/bnatlas_tree.json' parent_substitutions={ 'Am...
7cbf0d1c101372e689be74f56d64c4645076c61b345812422fd3465cda5e9255
Python
7,969
220
# 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. from dataclasses import dataclass, field import torch from fairseq import metrics, utils from fairseq.criterions import register_criterion fro...
3d7b0ca22d6971d5a6c5eb2648f13c818eb4621817c50e680ea78a34db9e6607
Python
7,972
209
from torchvision.datasets import ImageFolder from typing import Optional, Tuple, Dict, List, Union import torch import argparse from utils import logger from .. import register_dataset from ..dataset_base import BaseImageDataset from ...transforms import image_pil as T from ...collate_fns import register_co...
75105a25694f1aeb386f3a17a17934ad76b1948abe8eb71a638ff7aab38d5fff
Python
7,974
195
""" Pyramidal CAN """ """ ------------------------------------------------------------------------ """ py_CAN_inp_eqs = ''' dv/dt = (- I_CAN - I_M - I_leak - I_K - I_Na - I_Ca - I_SynE - I_SynExt - I_SynI - I_SynHipp + r_drive*I_exc + rin*I_tonic + r*I_stim) / ((1.*ufarad*cm**-2) * (size)) + noise : volt I_CAN ...
b3ed13a2237f14fc0c6aa6069f5b23e28edfd6607fc289abea88a1c96bd573b4
Python
7,977
216
"""The `--wandb` flags, exercised without a Weights and Biases account. Nothing exercised any of the six. They are the flags whose failure mode is a run that trains fine and logs nowhere, or logs under the wrong project, and neither shows up as an error. Two levels. `setup_wandb` is where five of the flags become arg...
12c97d0e8b0bf024ce24e4de8d99c4446b26db4e4bc8ecb5c2bc936cd633a22c
Python
7,978
195
import copy import numpy as np import struct def fill_pul_with_data(pul, fh, group_idx, series_idx): """ Fill the ["data"] field of all pulse tree records for the specified group and series with raw data from file. The record header contains the starting bit of the raw data, and parameters for its reconst...
58dfcb22053664d80f654dfc9d483e7e0ebe68b06e5cfd39d1d642334fa47fe5
Python
7,981
144
"""Produce record confidence v3 from completed tables and a frozen Bayesian model.""" from __future__ import annotations import gzip import hashlib import json from importlib.resources import files from pathlib import Path import polars as pl from ..emit.vdjdb3 import read_table from .bayes import score_records from...
f8b387963f37d55ef551c5e95808356c16289ce9917b8dd541a4cdd27b220a11
Python
7,989
183
# -*- coding: utf-8 -*- # /usr/bin/env python3 # # This software and supporting documentation are distributed by # Institut Federatif de Recherche 49 # CEA/NeuroSpin, Batiment 145, # 91191 Gif-sur-Yvette cedex # France # # This software is governed by the CeCILL license version 2 under # French law...
1c01afe6cff778aa6381b83273ed615d7b8ff7e2368b6875853a5906f2c2af4e
Python
7,990
182
import torch from torch import nn import torch.utils.data as Data import torch.nn.functional as F from torch.autograd import Variable import numpy as np import copy import math import collections # torch.manual_seed(1) # np.random.seed(1) class LayerNorm(nn.Module): def __init__(self, hidden_size, variance_epsilo...
95cd1d2fb2db27b0c501d4913429ecc1bb21e50c090bab02044aa35c090a64ee
Python
7,999
140
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this sof...
25c1968fb1684a2579a217914d6f3459cd36bacfcebd4c0db46764c3ae4e2739
Python
8,000
201
import statistics import os.path import numpy as np from common.common import load_pickle from safe_msmt.configuration import DATA_FOLDER, OUTPUT_FOLDER from common.evaluation.measures import get_binary_classification_measures, get_multitask_classification_measures iucn_status = \ { 0: ("little spiderhunter", "least ...
c18e3048062ef39a978f18064ff9d7961fcda2ead5a70641b33fb310fabbe287
Python
8,002
231
# 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 applic...
cc6beb3444c38d9051655fe4a041f030d84bd7b74dc5c2b4b56db56d5c532fb1
Python
8,002
206
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import numpy as N import os from sklearn.linear_model import LinearRegression from sklearn.metrics import explained_variance_score from sklearn.model_selection import KFold from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from s...
9bdae09d1b68b283f980fbad0fa3510844de179ab98e90216e027efc7dae6135
Python
8,003
183
# 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 ...
04e1440dcef5a46cfdd84b0feaa381b87e25c4e933f7afa1e2a2249c0c70e014
Python
8,004
159
# %% import os import numpy as np import time import h5py import sys from scipy.io import savemat, loadmat import multiprocessing as mp sys.path.insert(1, '../..') # the path containing "suns" folder os.environ['KERAS_BACKEND'] = 'tensorflow' # os.environ['CUDA_VISIBLE_DEVICES'] = '0' # Set which GPU to use. '-1' use...
fc7ce809beeb8478847f91d8df2fe557601d5c8f720f1097a5ca0277c25707ed
Python
8,008
252
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QLineEdit, QDialogButtonBox, QDialog, QMessageBox from PyQt5.QtWidgets import QHBoxLayout, QGroupBox, QWidget, QComboBox, QStackedWidget, QLabel class PreprocessingView(QDialog): def __init__(self, app, control): """The view corresponding to co...
f355b6ce39509880e6acd7c65ba2b5f938225d2347cfcdcd940bf1448793fbcd
Python
8,011
223
import tensorflow as tf class TransformerBlock(tf.keras.layers.Layer): def __init__(self, embed_dim, num_heads, d_hid, rate=0.5, use_bias=False, **kwargs): super(TransformerBlock, self).__init__(**kwargs) self.att = tf.keras.layers.MultiHeadAttention(num_heads=num_heads, key_dim=embed_dim, use_bias...
85393095e3e6ea22d7564e45a520a96d42f6124749e88d2310d602de01738126
Python
8,017
181
# Partial copy of the tensorflow python file image_ops_impl.py because loading this function per tf.image.psnr didn't # work at the time. import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.py...
9b2d18886fd61090438ae2a2ff5478ddfcdc6bff56bfea1edf43dfba9ad66155
Python
8,017
203
from ..abstract_dataset import AbstractDataset import os import numpy as np import matplotlib import matplotlib.pyplot as plt import matplotlib.tri as tri from mpl_toolkits.axes_grid1 import make_axes_locatable from scipy.interpolate import CubicSpline class AirfoilTransonicDataset(AbstractDataset): parametric =...
eb48a6f6dc3c5a693d249b43f44e86436162ce040294043e007ad5889f31c0ed
Python
8,018
206
"""`--fixedpoint_update_config` and `--field_readout_config`. Two CLI flags that choose which block PolarMACE builds and how, written as dict literals in a string. They travel a path nothing tested: the string is parsed by `_parse_literal_or_none`, handed to the constructor, and there a `type` key is looked up in a re...
91a090ecea466e09d320d4f55d8eeb25d9254c9c2affc5e8cb4dcf6e49c35ec7
Python
8,019
331
import abc import logging from scipy.optimize import OptimizeResult from torch.optim import LBFGS, SGD, Adam, RMSprop import geomstats.backend as gs from geomstats.numerics._common import params_to_kwargs from ._optimization import Minimizer class TorchMinimizer(Minimizer, abc.ABC): """Base class for torch.opt...
a924c56d21ba7f06de07f236efe90ab061edcdf0ba141846313eafd34315387c
Python
8,021
199
# Copyright 2025 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """This module contains the VerifiableDatasetInfo class.""" import json from hashlib import sha384 from typing import List from openfl.federated.data.sources.azure_blob_data_source import AzureBlobDataSource from openfl.federated.data.sources.d...
07c061af19802fafc6ebaa542d24a3eb99db4c1db477d6e0a09560e9ed2b814f
Python
8,022
251
import torch from pymonntorch.NetworkCore.Behavior import Behavior from pymonntorch.utils import check_is_torch_tensor class InstantHomeostasis(Behavior): def __init__( self, *args, min_th=None, max_th=None, threshold=None, gap_percent=None, distance_sensit...
141684cc226f267ebeda519f56a022e9fe3d95c51431806e1b76cfd9d5aa8681
Python
8,026
179
import math import json from openpyxl.worksheet.table import Table, TableStyleInfo from openpyxl.styles import Alignment from nilearn import plotting,image,surface,datasets from utilityFunctions import * import collections bn_atlas_file = 'PROJECT_DIR/scripts/features/bnatlas_tree.json' parent_substitutions={ 'Am...
5aa48f815920c445cd18917f97fb7c9280a728baaf8660e41ea142102f533c43
Python
8,035
200
import torch def shift_by_int(img, x_shift, y_shift, is_res=False): if is_res: img = img.permute(0, 3, 1, 2) x_shifted = torch.zeros_like(img) if x_shift > 0: x_shifted[..., x_shift:, :] = img[..., :-x_shift, :] elif x_shift < 0: x_shifted[..., :x_shift, :] = img[..., -x_shif...
8bec06051984b16cd83608a977300ad84875e0c402c5aee8a1f1c40e57f5d900
Python
8,035
286
from interval import interval import numpy as np # get usable segments from available interval lists def seg_available(available, clip_length, neg = False): seg = [] for a1, a2 in available: length = a2 - a1 if length <= clip_length: if neg == False: seg.append([a1, ...
51acf5f8be2277d0c77fff65718fc7eef2d9e345f86505c68a4673fb0666e1ce
Python
8,037
209
#### make_local_connectivity_scorr.py # Copyright (C) 2010 R. Cameron Craddock (cameron.craddock@gmail.com) # # This script is a part of the pyClusterROI python toolbox for the spatially # constrained clustering of fMRI data. It constructs a spatially constrained # Coefficient between the whole brain FC maps generaged ...
50c5b5752abeb83a943f1adbd2a9395fb00b534496bb700f83fd17ce0245dbe8
Python
8,045
237
import scanpy as sc import pandas as pd import numpy as np from scipy.spatial import * from sklearn.preprocessing import * import numpy as np def res_search(adata,target_k = 7, res_start = 0.1, res_step = 0.05, res_epochs = 10,random_state=666): print(f"searching resolution to k={target_k}") res = res_start ...
cd064cd4b31fe53bf3358d6c599b0ffd88fc3b2e208c9db91e3a4b6883493548
Python
8,045
222
import torch from pymonntorch.NetworkCore.Base import TaggableObject from pymonntorch.utils import is_number class Behavior(TaggableObject): """Base class for behaviors. All behaviors all `TaggableObject`s. Attributes: tag (str): Tag of the behavior. device (str): Device of the behavior. Thi...
6e067c34d51c45aad987a577b7dac85ec77a7ac68ed49e474016a7164866ca41
Python
8,047
260
import community import markov_clustering as mc import networkx as nx from scipy.sparse import csr_matrix import torch from torch_scatter import scatter_max, scatter_mean from torch_geometric.nn.pool.pool import pool_edge, pool_batch, pool_pos from torch_geometric.nn.pool.consecutive import consecutive_cluster from to...
020467e17c14729ab8f66677d388287fd258cafe9b8076831368ff4527dd4012
Python
8,050
271
#!/usr/bin/env python3 import argparse import matplotlib.pyplot as plt import numpy as np import odil from odil import printlog def u_init_smooth(x, y): r = x**2 + y**2 res = np.exp(1 - 1 / (1 - r)) res = np.where(r < 1, res, 0) return res def u_init_blob(x, y, t): # Single blob advected by u...
95d414c64f557a25b91e08d1f1c47e210d2dab03c4d90bf4bfa1dc1571898613
Python
8,050
179
"""The committed training regression set is what it claims to be. ``datasets/regression_train.xyz`` is the dataset the legacy-versus-rewrite training comparison runs on, and it is committed, so nothing regenerates it between runs -- which means nothing would notice if it drifted, went stale against its own recipe, or ...
e14f3d45352069984489c254950185613dd625cfcd9604f67b1a8a5b0d1adfb4
Python
8,054
272
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 """ Helpers for parsing protein structure files and generating contact maps. """ import gzip import boto3 import numpy as np import pandas as pd from io import StringIO from Bio.PDB.Polypeptide import three_to_one, i...
2371b95e0a789bb624bfef872f57004550c3e5332be451885309d2b61073411f
Python
8,056
159
"""Synthetic release checks, without private assay rows.""" import importlib.util import os import subprocess import sys from pathlib import Path import numpy as np import polars as pl import pytest from vdjdb.score.pipeline import load_model def test_v32_default_and_both_legacy_versions(): model, _ = load_mode...
7e8e0738ce969e7dfd51751eaabe7dcc739f5ca4fb48a8239c4a3b8ef890db6d
Python
8,057
246
import argparse import json import os import time import warnings import numpy as np from pydfc import data_loader, multi_analysis_utils warnings.simplefilter("ignore") os.environ["MKL_NUM_THREADS"] = "16" os.environ["NUMEXPR_NUM_THREADS"] = "16" os.environ["OMP_NUM_THREADS"] = "16" ###############################...
fc311836948aa02d8fd1362d9b553be281186c9b1a03cb26867253c38961415b
Python
8,057
236
"""Input validation for `BrainData`. Helpers that validate constructor inputs, array shapes, and operand compatibility between `BrainData` objects and other data types. """ from pathlib import Path import nibabel as nib import numpy as np def _validate_brain_data_shapes(brain1, brain2, operation="operation"): ...