sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
ab9a0002dd3d848f6597d10728d6b6bb8ec73c12a0935edfa2c7e32562a1b549
Python
2,549
78
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
f5882752da84524716f0e8713795e6568de8eb535ab789bb07b52a48073eaf85
Python
2,549
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import GuidedBP #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import GCN_2...
9af62fa4c3d8eda8d37bbd8ce7a5471423e7a709849d3335221eefbb7836e08f
Python
2,550
97
""" Title ----- Other adaptive models Description ----------- Apart from the Adaptive Exponential integrate-and-fire model (AdEx), Dendrify also supports other types of adaptive models, that can be preferred in some cases. In this example, we compare the behavior of two different adaptive models: - The Adaptive IF mo...
7f549875df288d2a161d7f99d110eb81bd1515641e97b178ac20786f2cbb1440
Python
2,551
77
# Copyright 2022 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
c85f2471702a6a4e57c331628d51da4ded1330a3be7b81a453c08b83b5115c45
Python
2,551
88
import matplotlib as mpl mpl.rcParams['figure.dpi'] = 100 mpl.rcParams['font.family'] = 'serif' mpl.rcParams['font.sans-serif'] = ['Lucida Console'] import networkx as nx import matplotlib.pyplot as plt from read_edgeind import degdist, get_edge_index #plt.style.use('ggplot') # Use ggplot style from graphxai.datasets...
f445d1f01c3a2e7435799f324e38f935fa3e3d38bc7715d291d28fbfe05ca91b
Python
2,551
59
# Copyright 2020 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
2a81ad723be1f67db68229a3608e4895d28b4609bf96a14df55e8f4b83c6e437
Python
2,552
91
# Copyright 2021 Google Research. 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 applicable law...
e60e559e9409a8b6f432de46d6c3059cb5c7d20186b8ac1ac13f222573b8d599
Python
2,552
57
from builtins import super import numpy as np from .expectation_maximization_registration import expectation_maximization_registration class rigid_registration(expectation_maximization_registration): def __init__(self, R=None, t=None, s=None, only_t=False, *args, **kwargs): super().__init__(*args, **kwargs...
13a807d4aa9091540bccbd6bb020d299c5566a9546932541655ea6cc5872a695
Python
2,553
63
import os from chemproppred.utils import * from rdkit.Chem import PandasTools def screen_poly(data_path, save_path, preds_path): if not os.path.exists(save_path): os.makedirs(save_path) #load xgboost screen set and predictions from chemprop xgb_df = pd.read_csv('{}/xgb_screen.csv'.for...
3330bc63d23f164172513f5894ad23a76e037df2bc8f2eee3f68de680763fa53
Python
2,555
76
# Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de # Barcelona (UAB). # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. import time import carla from . import SmokeTest # The packaged build only ships Town10HD_Opt and...
36548d107eaf06f9410331ba6f1615cfc51814cbf215ee1078c6a44742f35640
Python
2,555
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import CAM, GradCAM #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import G...
8f03693f62e54d3d01bf4e8480284e68b87fa40167b18c34e0a2df833042c10d
Python
2,555
99
from os.path import basename from pathlib import Path import numpy as np import pandas as pd from joblib import Parallel, delayed from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left from graspy.utils import binarize, symmetrize, ...
c3c44cd3974163e61e57d7641c5fff37c21811d76f0533cf439ec6119cad5a0d
Python
2,555
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import CAM, GradCAM #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import G...
dd06690158f87af8336474d452e28ad1b653382ef47612b010259093240ac375
Python
2,555
75
## Utils.py -- Some utility functions ## ## Copyright (C) 2018, IBM Corp ## Chun-Chen Tu <timtu@umich.edu> ## PaiShun Ting <paishun@umich.edu> ## Pin-Yu Chen <Pin-Yu.Chen@ibm.com> ## ## Licensed under the Apache License, Version 2.0 (the "License"); #...
b90b5a492e579bba6fdbde7b7d547f3fa6c5ee80f41592f67f49c57b8ca2103c
Python
2,556
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import SubgraphX #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import GCN_...
c88881ace2789ffe9479af3e8f44de816ed2c93e57f87067b56879ba8e1b7a0d
Python
2,556
73
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
d0b8d1c0a95565d834a89e4fb0d3da1b014f9f87034e65607cfa6a4d996794c4
Python
2,556
65
# Copyright 2021 Huawei Technologies Co., Ltd # # 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 t...
5921003a6ddc001bf4c430d9947744e7fbab8cd93bbb62553c563ba55948fc4b
Python
2,558
98
from os.path import basename from pathlib import Path import numpy as np import pandas as pd from joblib import Parallel, delayed from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left from graspy.utils import binarize, symmetrize, ...
9b64e1e216fae2046103387cec52bde5e6b20b9ab005c91330f367cd51c7705a
Python
2,558
75
import torch import torch.nn as nn def get_loss_func(loss_name, reduction='mean'): """ Return the loss function. Parameters: loss_name (str) -- the name of the loss function: BCE | MSE | L1 | CE reduction (str) -- the reduction method applied to the loss function: sum | mean """ ...
f9080f50dfe2faad4749b89e74bd35a039f556cc1e54cc77454cdb5692544e1e
Python
2,558
68
#%% import sys sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/") import pymaid import pyoctree from pymaid_creds import url, name, password, token import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd rm = pymaid.CatmaidInstance(url, token, name, pas...
66c627bbaf5e65ad69d4a262a3e46ea997275b654407ad1f799eb0d0bd655693
Python
2,559
93
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import os, random, sys, math import numpy as np import matplotlib.pyplot as plt import networks device = 'cuda' batch_size = 1 Z = 128 T = 1 transform_train = transforms.Compose([ transforms.ToTensor(), ]) trainset ...
4f508b6862db26eebaf34e2748612913aacb0456bb53d93f6c9cdc3b9ee1b279
Python
2,561
93
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import os, random, sys, math import numpy as np import matplotlib.pyplot as plt import networks device = 'cuda' batch_size = 1 Z = 128 T = 1 transform_train = transforms.Compose([ transforms.ToTensor(), ]) trainset ...
d5ce883725d438110cf469dc1b7fc099f0bec03e0d79bd9bfd4b6812fdd619e2
Python
2,561
78
""" File: local_settings.py Created: 2020/10/08 Last Changed: Author: M.Vochteloo Copyright (C) 2020 M.Vochteloo This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 o...
fd67109aec9f276a8fba55c750b7546205107888b9f5f3f81c9c9b63a75265d2
Python
2,561
70
####### # This code was written by Nino Verwei and Niek van Hilten at Leiden University, The Netherlands (23 August 2022) # # When using this code, please cite: # Van Hilten, N.; Methorst, J.; Verwei, N.; Risselada, H.J., Science Advances. 2023, 9(11). DOI: 10.1126/sciadv.ade8839 ####### import numpy as np ...
3f3bf57fc9713d49e01a4880d39199d1c01d11c0d3adeb61fec99f1e81e2bfa2
Python
2,562
88
''' @author: Mahbub Ul Alam (mahbub@dsv.su.se) @version: 1.0+ @copyright: Copyright (c) Mahbub Ul Alam (mahbub@dsv.su.se) @license : MIT License ''' '''@file early_sepsis_detector.py run this file to go through the complete neural net training, testing and evaluating procedures, look at the 'early_sepsis_detector_con...
117267ea5d9c327b3c460598badf7c05a29d451e991d85c02846c240f179bcba
Python
2,563
66
from __future__ import division from math import sqrt as sqrt from itertools import product as product import torch class PriorBox(object): """Compute priorbox coordinates in center-offset form for each source feature map. """ def __init__(self, cfg): super(PriorBox, self).__init__() s...
51b906a010df0eed126d2255312cfdd4310cef9ef1dc4e60612d4132c5b45eb7
Python
2,563
68
# Copyright 2020 Google Research. 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 applicable law...
6197de1c34499e8aadf5bd38ac2cb48d6b702a205b5a47bbd87fc3fa2d9d02ca
Python
2,563
67
import random import torch import matplotlib.pyplot as plt from graphxai.explainers import GuidedBP from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train from graphxai.datasets.shape_graph import ShapeGGen from graphxai.utils import aggregate_explanations # Load ...
311983c5c32de30f7ad526e98c10f9c70c1243aa314ac12486d52fc7335c8953
Python
2,564
88
#!/usr/bin/env python # Read annotation file, print counts, plot transcript sizes; import os import sys import optparse import re # regular expressions import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import Annotations as anno VERSION = '20140930.01' DEF_OUTPUT = 'transcript_sizes.p...
fcef3d49f759623dd1e02b6bd45d8bf297a2a6ccc67a7b27c3cbf3a6edd0e11f
Python
2,564
77
import os.path as op import numpy as np import numpy.testing as npt import pytest from bids.layout import BIDSLayout import AFQ.definitions.image as afm from AFQ.definitions.image import * # interprets images from eval from AFQ.definitions.mapping import * # interprets mappings from eval from AFQ.tests.test_api imp...
0790e297527d314eeb1b4f51d6159c509c5244f4b56c680bd4a3f234bed1da7c
Python
2,565
67
# Copyright 2020-2022 Huawei Technologies Co., Ltd # # 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 agre...
509077c9161b72ed015a5c2fdfb094a92e7b8de3395ee95da1fb4a5860a7f4b2
Python
2,565
57
from spike2calcium_linear_ALS import * import os, sys import warnings warnings.filterwarnings('ignore') from glob import glob # get cell list information # flist = sorted(glob('GCaMP8_exported_ROIs_s2f_full/dff_v00/*.npz')) # new fit based on the clean-up data flist = sorted(glob('GCaMP8_exported_ROIs_s2f_full/dff_v03...
6882be55968de7ce21d00b4a1fa10125022a4f06632682aa364a7cdc025c8ea9
Python
2,566
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import GradExplainer #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import ...
cf611cb3423c507a92db5cf5ac528597318075370630b731062dc555d9dc022a
Python
2,567
88
""" Refer to https://github.com/rosinality/stylegan2-pytorch/blob/master/op/fused_act.py """ import os import torch from torch import nn from torch.autograd import Function from torch.utils.cpp_extension import load module_path = os.path.dirname(__file__) fused = load( "fused", sources=[ ...
3bf27ba327066a0e833f525f3cba3bc030eb629362368f677c2375fec10bc94e
Python
2,568
64
import random import pandas as pd import numpy as np import os def dir_check(thispath): if not os.path.exists(thispath): os.mkdir(thispath) def create_subfolders(savepath): # create classic subfolder structure (figures, DF, csv) in given folder savepath_fig = os.path.join(savepath, 'figures') ...
6c93b131b4f0d57e0caab4bfcba0b0b38229c7ff2d376397a92ee8f55e81bafa
Python
2,568
65
"""verify_cache.py <artifacts.lock> <HF_HOME> <artifact_id>... — sha256-check every lock file present in a local HF cache. Resolution follows prefetch.py: the pinned revision's snapshot first, then the sha256-named blob, then the same path under any other revision (NVIDIA re-tags the same weight file across commits, s...
21d97c2cade96fabfd5dbcd3f9736051cc5acca066acd5c3df9d43036a290d5c
Python
2,569
79
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Hang Zhang ## Email: zhanghang0704@gmail.com ## Copyright (c) 2018 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++++++++++++++...
549a799bf1d9478cba1b32d66bcc2083548f4b338b9ff19029ad5c352d2cae56
Python
2,569
71
import torch import networkx as nx from graphxai.utils.nx_conversion import khop_subgraph_nx def motif_id_label(G, num_hops): ''' Gets labels based on motif label in the neighborhood ''' def get_label(node_idx): nodes_in_khop = khop_subgraph_nx(node_idx, num_hops, G) # For now, sum mot...
67743d9c97f5dc908ff3785117adac4cb78c7a2a5f2dae657de423b8bd56c4a5
Python
2,569
66
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # Code is copy-pasted exactly as in torch.utils.data.distributed. # FIXME remove this once c10d fixes the bug it has import math import torch import torch.distributed as dist from torch.utils.data.sampler import Sampler class DistributedSampler(S...
82ab3629d3634663f6e252ed7d5558bd98feec20d898ba9b1759cc774d098ba1
Python
2,571
68
# # Introduction # This example illustrate a very simple linear regression couple with a cross validation mechanism.This example uses the only the first feature of the `diabetes` dataset, in order to illustrate a two-dimensional plot of this regression technique. The # straight line can be seen in the plot, showing how...
698f392189bda6415210d514613d9fc24307d052f8ff69f98d697c57db295fe5
Python
2,573
77
import numpy as np from mip.mip_nn import MIP_NN from globals import CONT, TARGET_ERROR, MARGIN class MIN_HINGE(MIP_NN): def __init__(self, data, architecture, bound, reg, fair): MIP_NN.__init__(self, data, architecture, bound, reg, fair) self.init_output() self.add_output_constraints() if reg: ...
dc99b7bd44d7154bd3809b58ab46791f443316ae357275fa2625e9dd96f1dc37
Python
2,573
70
"""Visualize atomic attention and save similarity map.""" from typing import Union import numpy as np from tqdm import tqdm from chemprop.args import PredictArgs, TrainArgs from chemprop.data import get_data, MoleculeDataLoader, MoleculeDataset from chemprop.utils import load_args, load_checkpoint, update_prediction_a...
ee69aba983728c8af1670d45332327e8bf7f9d4ee3bd66c4f2c9099555492eee
Python
2,573
52
from pathlib import Path from matplotlib import pyplot as plt from metrics import calculate_lateral_errors, read_frames_driving def draw_error_plot(ax, model_frames, expert_frames, title=None): lat_errors = calculate_lateral_errors(model_frames, expert_frames, only_autonomous=True) autonomous_df = model_fr...
17bdeab15db84d993c54cae8383efe3d3152bd7359d696f2ed159aaa712c40e2
Python
2,574
80
import gzip import sys import argparse parser = argparse.ArgumentParser(description='Merge (gzipped) matrices by column') parser.add_argument('outfile', help='File to write output to') parser.add_argument('type', help='type of event') parser.add_argument('input_files', help='files to merge', nargs='+') args = parser....
4360d8362f7b377b37a58f2640ff49a98ecc85bf3797e8e3baa1b730da534ad5
Python
2,574
77
import numpy as np from torch.utils.data import DataLoader from torch.utils.data.dataloader import default_collate from torch.utils.data.sampler import SubsetRandomSampler, WeightedRandomSampler import torch class BaseDataLoader(DataLoader): """ Base class for all data loaders """ def __init__(self, da...
987817d8dfadb76b5828c9c7708165d1392eb9a7faea9386bfaabed1ab1ff8f1
Python
2,576
82
import numpy as np import matplotlib.pyplot as plt from scipy import signal plt.style.use('seaborn-whitegrid') class Butterworth: """Creates an IIR Butterworth filter in second-order sections format. Attrs: order (int): filter order ftype (str): the type of filter, one of: ...
5771c308c4a5d9165e1badf1bc22bc379cf9af4425f756579ed5d00d7045227c
Python
2,577
74
# Copyright 2022 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
b54c4e61505c658c1cc331312252d53d7b40990453fcc557d982820c893ec446
Python
2,577
66
# Copyright 2022 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
f660ba9212227387c5f6ea092f5bd71fcb0d041705deb056ed2f0ac6b5c10ce0
Python
2,577
110
''' Simulates 200 trajectories in a chemical gradient. ''' from brian2 import * from behavior import * import imageio from plotting import cell_mask, cell_indices movie = True C = paramecium_constants()['C'] N = 200 duration = 50*second tau_noise = 20*ms sigma_noise = .009*nA # .09*nA size = 25000 # in um # observat...
017a7868cc0f6ae3eca8d0898e38523c46fb5659283e951396d0449694d0dc11
Python
2,578
76
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Hyper-parameters input_size = 28 * 28 # 784 num_classes = 10 num_epochs = 5 batch_size = 100 learning_rate = 0.001 # MNIST dataset (images and labels) train_dataset = torchvision.datasets.MNIST(root='../../data', ...
7553b3f17a59866991385abf07c5eeff7689c9956df893df87981a99ba76318e
Python
2,578
88
import argparse import datetime import os from pathlib import Path import tensorflow as tf import yaml from multi_phase.networks.models import get_model from multi_phase.trainingloops.build_training_loop import get_training_loop from multi_phase.utils.build_dataloader import get_train_dataloader # ------------------...
de0d17fbacf1653148b5c29730e16dea85e0a56776bf77b34ffbdc435aee7bc6
Python
2,578
72
# Copyright 2020 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
4990d37e910dc6f7736eaf93100a35e71f6df738be6e4e401ef2cecd42d885ba
Python
2,579
66
# Copyright 2020-21 Huawei Technologies Co., Ltd # # 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...
1eb6cf6103d8d07305c716bfc2729d3755acf1ade3a58004bf3aab47fd2c822a
Python
2,580
75
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import CAM, GradCAM #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import G...
3ca390fc3e2da67bdc8a0032a3dcc63dd466775e93d01eb2b8d31528d059b797
Python
2,580
68
import numpy as np from cenfind.core.structures import Centriole, Nucleus def test_centriole_centre_xy_swaps_row_col(make_field): field = make_field(shape=(2, 100, 100)) centriole = Centriole(field=field, channel=0, centre=(7, 3)) assert centriole.centre_xy == (3, 7) def test_centriole_intensity_sums_n...
0f0f8d8ff2358fdedaa7784c06180ff9e98e8a974097c90f915ce0efbb500f70
Python
2,581
68
# Taken from : https://github.com/jindongwang/transferlearning/blob/master/code/distance/mmd_pytorch.py # Compute MMD distance using pytorch import torch import torch.nn as nn class MMD_loss(nn.Module): def __init__( self, kernel_type="rbf", kernel_mul=2.0, kernel_num=5, fix_sigma: float = None ): ...
74f9450bbae8fa923e258d42798c769137a1be7f4b5a7388f154085ff4c48521
Python
2,583
77
import pandas as pd # from tqdm import tqdm # import os # import inspect # import AIS_parameters # import numpy as np # import AIS_harvest # import datetime # import AIS_description # import matplotlib.pyplot as plt # from skimage import data, util, measure # from scipy.ndimage.measurements import label imp...
bf5fe04075a5cf72cccd9ff298ac78719405427132e14830b4eba874f9a48edf
Python
2,583
74
import os.path as osp from mmcv.runner import Hook from torch.utils.data import DataLoader class EvalHook(Hook): """Evaluation hook. Attributes: dataloader (DataLoader): A PyTorch dataloader. interval (int): Evaluation interval (by epochs). Default: 1. """ def __init__(self, dataloa...
116d22a003d7263976cb4fa6c213eb2e4ea7be2c463b3568e40af8171ba2b5b8
Python
2,584
83
import unittest import numpy as np import numpy.testing as npt from grr import Trace class TestFilterTimesByROI(unittest.TestCase): def testIntegerTimes(self): unfilteredTimes = [1, 5, 7, 110, 111, 150] ROI = [5, 111] expectedFilteredTimes = [5, 7, 110] npt.assert_array_equal( ...
a3832e91c356d4aca3a181bc6b4eb6c296dedc8900a5e42799cfcb5a0e94bba0
Python
2,584
64
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. import torch import torch.distributed as dist import math class RASampler(torch.utils.data.Sampler): """Sampler that restricts data loading to a subset of the dataset for distributed, with repeated augmentation. It ensures that different ...
71aa5c3b712a71e836a4bce3885294e401251fc4cabdcc5cbf9bb6ae45c024d0
Python
2,586
82
""" Utilities for working with networkx ----------------------------------- NetworkX is a popular python package for working with graphs """ import logging from typing import Dict, Tuple, List import sssom from oaklib.types import PRED_CURIE, CURIE try: # Python <= 3.9 from collections import Iterable, defau...
e123cd9c2bc8a1acde3f988cd42e8f1d51aab1ed0cc0012969f122f7052269cd
Python
2,587
100
import argparse import json import os import os.path as op import sys from glob import glob from shutil import copyfile import matplotlib.image as mpimg import nibabel as nib import numpy as np import pandas as pd from matplotlib import pyplot from nilearn import image, masking, plotting def _get_parser(): parse...
1e1a53e6a9a6b993ab609a6a27ff033b1cbe2ea3278e0798f9ed43148a8d7178
Python
2,589
78
#!/usr/bin/env python3 """ File: diverging_cmap.py Created: 2020/06/19 Last Changed: Author: M.Vochteloo Copyright (C) 2020 M.Vochteloo This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Founda...
d58fa9ad1173645c9ac15ac23d7e677382615f0f0dcabae3457af29d77524423
Python
2,589
81
# Copyright (c) Open-MMLab. All rights reserved. import os import random import sys import time from getpass import getuser from socket import gethostname import numpy as np import torch import mmcv def get_host_info(): return f'{getuser()}@{gethostname()}' def get_time_str(): return time.strftime('%Y%m%d...
7b6396a485e5b62bb45050a8abfb92c89ec18a20ccb6196c5f9f8d88d1f2d934
Python
2,590
75
""" Generate data for testing the effects of linear and nonlinear models on data with the linear label signal removed """ import argparse import matplotlib.pyplot as plt import numpy as np import pandas as pd if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('out_file', help='T...
143b1d24a4697694567d6e7ab0ff30c78767bf638aa09c8ec708a5d5defb78de
Python
2,591
65
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
23cf767603481b3976cbe407d6fb3da2035910628019c64fea61c08bb8b53dce
Python
2,591
77
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
861b733e80df0558b89ad34d5b842ea1f1bc3cab8025bf37c280c16949071c73
Python
2,591
77
import os, glob import torch import argparse import numpy as np #def aggregate_results(exp_method, metric, level, path): # def aggregate_results(dataset, exp_method, metric, level): # ''' # Metrics should match: # {exp_method}_{metric}_{level} # Also performs filtering for None's # Assumes th...
54f41b0ca7cad02e2b9eaa49a3abed0f37722f1a9a721b5a38bc019a3a47ad40
Python
2,592
90
# -*- coding: utf-8 -*- #!/usr/bin/env python3 import tensorflow import numpy import unetsl.data import sys def getGaussianKernel(sigma, N=128): xi = numpy.repeat( numpy.arange(N).reshape( (1, N) ), axis=0, repeats = N ) yi = numpy.repeat( numpy.arange(N).resha...
635fe2ccb80876af0b8573202b80d1ec9f3f7f98d3efa5cc5f44c79483c22e0f
Python
2,592
67
import random import torch import matplotlib.pyplot as plt from graphxai.explainers import PGMExplainer from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train from graphxai.datasets.shape_graph import ShapeGGen from graphxai.utils import aggregate_explanations # L...
64ad49850e165c0c87eab2f9ed0d6638937e7ed8b7bcb109ebe10872bc022261
Python
2,593
74
# Copyright (c) Open-MMLab. All rights reserved. import torch from torch.nn.parallel._functions import _get_stream def scatter(input, devices, streams=None): """Scatters tensor across multiple GPUs.""" if streams is None: streams = [None] * len(devices) if isinstance(input, list): chunk_s...
7bdce9fae78175de83322a1d46e827f7af4809858fbf353d771a79850f6ef3ff
Python
2,594
71
import os import glob import argparse import pickle import numpy as np from openeye import oechem from utils import generate_esp_grids if __name__ == '__main__': parser = argparse.ArgumentParser( description='Generate PfAbNet ESP grid input') parser.add_argument('--input_mols_dir', type=str, default...
d2a95a0642244f97f08588e08efeb2c4a318deb04222e6caa444c4e75b0755f9
Python
2,594
87
import numpy as np import polychrom.forcekits import polychrom.forces import polychrom.polymerutils import polychrom.starting_conformations from polychrom.hdf5_format import HDF5Reporter, list_URIs, load_URI from polychrom.simulation import Simulation def test_basic_simulation_and_hdf5(tmp_path): data = polychro...
b9615e390fe2eaa77fe8d7f35d3a4320f64d16d42e6c969894f5edd27985f657
Python
2,595
95
import torch from torch.autograd import Function from torch.autograd.function import once_differentiable from maskrcnn_benchmark import _C class DeformRoIPoolingFunction(Function): @staticmethod def forward( ctx, data, rois, offset, spatial_scale, out_size, ...
c707304f118d1509f2683ddb5aacd1942e7421b65fe3a443fc3ec23c6b10c922
Python
2,595
80
#%% import numpy as np from src.data import load_maggot_graph from src.io import save_walks from src.traverse import RandomWalk, to_markov_matrix from tqdm import tqdm from graspologic.utils import remove_loops def get_nodes(meta, labels): nodes = [] for i, (node, row) in enumerate(meta.iterrows()): m...
0de17312eef7cca3bf2131a4f567a525fd20aef6a2e5aab65d91d55faecaf457
Python
2,596
70
# Copyright 2020 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
df60028eaebfe047c31ec7de7f075b7814e3d661318f47021187f0d9f6cec654
Python
2,596
54
# Copyright 2021 Google Research. 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 applicable law...
398613b8fc1232da0403084c8d706b5382d0fe10bac1f5550755eac8b25ba439
Python
2,597
74
############################################################################### # Language Modeling on Penn Tree Bank # # This file generates new sentences sampled from the language model # ############################################################################### import argparse import torch from torch.autograd...
e6ffc0d365cc3793e33c9df24758a4cff6dae25f13a1430fee373e00f55d7157
Python
2,599
91
""" Title ----- AdEx neuron + noise Description ----------- The Dendrify implementation of the Adaptive exponential integrate-and-fire model (adapted from `Brian's examples <https://brian2.readthedocs.io/en/stable/examples/frompapers.Brette_Gerstner_2005.html>`_). In this example, we also explore: - How to add gauss...
f040e211ddc5c02e9a2362a68a8188887aadebda9da8f1aefca6b392bbc804e9
Python
2,599
98
import torch import torch.nn as nn import torch.nn.functional as F class MFMLP(nn.Module): """ Multi-class Field Multi Layer Perceptron """ def __init__(self, d_in, c_in, dropout, n_c): super(MFMLP, self).__init__() self.d_in = d_in self.c_in = c_in self.seq1 = nn.Seq...
d758e487deb4809725843d429e8d888316f838ce82ec6dff382772bd324e6e88
Python
2,600
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import PGMExplainer #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.gcn import G...
1e31a841a1eaa2cce918661c70c0e806e4481355e8500b0fb8a26fce87646b48
Python
2,601
104
from os.path import basename from pathlib import Path import numpy as np import pandas as pd from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left from graspy.utils import binarize, symmetrize, is_fully_connected from graspy.plot i...
d958cbe48466f69d7620995e31216568ca276b3c4247a412c5c18e4cb5538861
Python
2,601
83
import numpy as np from mip.mip_nn import MIP_NN from globals import EPSILON, BIN, TARGET_ERROR class MAX_CORRECT(MIP_NN): def __init__(self, data, architecture, bound, reg, fair): MIP_NN.__init__(self, data, architecture, bound, reg, fair) self.init_output() self.add_output_constraints() self.cuto...
a785e4c5f8f91412820506f224b567ba458894e6be115c1efa5e9a356cfc7445
Python
2,602
97
#%% import os try: os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/') print(os.getcwd()) except: pass #%% import csv import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt import connectome_tools.process_matrix as promat from tqdm import tqdm from ...
7c6447dd86d9289dd84457f1f3b68709ce8e290706bf1c94f89d59747e4a80fc
Python
2,603
70
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
cbb41efb9eeed0d7b67a5b7facd64a3aa2b67126a236aab009d9ff4166fe7754
Python
2,603
94
import matplotlib.pyplot as plt def calc_acc(matrix): import numpy as np diag = np.diag(matrix) class_sample_sum = np.sum(matrix, axis=1) return diag / class_sample_sum def score_acc_each_class(y_true, y_pred): """ Parameters ---------- y_true : array-like y_pred : array-like ...
e46964cc2c71334392a58ec26d9cd7298ce7ff18187115975f55855e005d85f0
Python
2,604
64
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import os SET_DPI = 100 FIGSIZE = (18, 10) def plot_channel(table, channel, filename, figsize=FIGSIZE, dpi=SET_DPI): plt.figure(figsize=figsize, dpi=dpi) plt.title(channel) plt.plot(table.index.values, table[channel], '-') plt...
6b5dcca3eed26c480bef87167d4e3b70e10031fa755209fd911e0c14f27816ce
Python
2,605
74
import sys import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import IntegratedGradExplainer #from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import train, test from graphxai.gnn_models.graph_classification.g...
f80b81bdb978a0c8a50313829eee1ade508cb74c2ce32496f14dc1fb850c493d
Python
2,609
55
from pathlib import Path from matplotlib import pyplot as plt from metrics import calculate_lateral_errors, read_frames_driving def draw_error_plot(ax, model_frames, expert_frames, title=None): lat_errors = calculate_lateral_errors(model_frames, expert_frames, only_autonomous=True) autonomous_df = model_fr...
1c545e047fb54259394bbbd3f068b3508f169cb9d159e97fafe9748546bd6b92
Python
2,611
66
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
03642865655175768f83353da631ca9fbc7deb7f5fa1a7b06602053f671f3bf8
Python
2,612
104
# %% [markdown] # ## import os import time import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import scipy import seaborn as sns from joblib import Parallel, delayed import pandas as pd from graspy.match import GraphMatch from graspy.plot import heatmap from src.cluster import get_paired_inds...
2b8ed82e977547852c164273dd746eba47983c18cbaf2474cfc11cdb8cb2b816
Python
2,612
89
''' Selection of data ''' import yaml import os from brian2 import second import numpy as np from numpy import mean __all__ = ['trim_data', 'stimulus_time', 'amplitudes', 'select_trials', 'merge_data', 'align_traces', 'subsample'] def subsample(data, n): ''' Subsamples the data n times. ''' data['t'] ...
617dda2a957a2d9417733950abe9c0c34c0f5fd0e0714ffa173306bd8c824a40
Python
2,613
67
# Copyright 2021 Huawei Technologies Co., Ltd # # 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 a...
7d7eaf69116aa59740731d175dd2ee0a42899a2352a9a92e05d04921afbc6d30
Python
2,613
64
""" Closure ("multi-hot") encoding of ontology terms. Each term is encoded as a binary vector over a vocabulary of terms, with a 1 at the position of each of its reflexive ancestors. Under this encoding, classic set-based semantic similarity measures become vector comparisons; e.g. Jaccard over closure vectors is iden...
59ec94cc3eaef709545aa68696a2116cb29da9daee681ae785cd9c47b03d039f
Python
2,614
82
import functools import numpy as np import scipy.stats import sklearn.metrics as metrics # Metric helpers which convert float values to binary (0/1). # Regression metrics helper functions. def _to_binary(x: np.ndarray, threshold=0.5) -> np.ndarray: return np.where(x > threshold, 1, 0).astype(int) def binary_i...
1d0db3306c027bb2bbbbaadc5232837f8dd04a6cf15ddb0c24ea4cb1d3793754
Python
2,617
62
# Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de # Barcelona (UAB). # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. import carla import random import time from . import SyncSmokeTest class TestSnapshot(SyncSmokeTe...
3e3bc58623281ed5bfc1878c58b0612d79b558bc81c34fb65734bc4c0edc5226
Python
2,617
77
# python 3.7 """Utility functions for logging.""" import os import sys import logging __all__ = ['setup_logger'] DEFAULT_WORK_DIR = 'results' def setup_logger(work_dir=None, logfile_name='log.txt', logger_name='logger'): """Sets up logger from target work directory. The function will sets up a logger with `DEB...
2a4432726d0aa0968b81dca4156d692979bf86d4c47d869af973d007ba6da374
Python
2,618
66
# Copyright 2020 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
101eabdb08217ed01334240264d1fe61aa9f80873510efa1812c0ddcc8d9fad3
Python
2,620
78
''' Experiment with current pulses. ''' from __future__ import print_function from clampy import * #from .utils import * from init_rig import * import utils import current_pulses_analysis from numpy.random import shuffle from os.path import join default_parameters = dict( name = 'current pulses', ntrials = 10,...
86d969bb2f64d1115a71f9b637bdecdeb86953cc8956f1585613551fc4c1b822
Python
2,620
82
import numpy as np import time import carpet import carpet.lattice.triangular as lattice import carpet.visualize as vis ## Parameters # Geometry nx = 6 ny = 6 # even number N = nx * ny a = 18 # [um] lattice spacing ## Initialize # Geometry L1, L2 = lattice.get_domain_sizes(nx, ny, a) coords, lattice_ids = lattice....