sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
62d19c536916e200abd7f668570dc4cdd6591ba7fc1798bda334cffedc2cec02 | Python | 5,998 | 166 | # 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... |
1574420e3684d676a19d7a1a615cc926688b9493b0bf8db52d065bb672dc3cf6 | Python | 6,001 | 145 | import argparse
import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from tqdm import tqdm
import numpy as np
from optparse import OptionParser
from gnn_model i... |
fd1be6c2efe7e2bed9a323f62e6e42bab788d0735aff46cd81244023acd32832 | Python | 6,001 | 147 | import os
import collections
from os.path import join
import numpy as np
import pandas as pd
from itertools import chain
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import ShuffleSplit, GridSearchCV
from sklearn.metrics import (me... |
cf51262886a125706e27a45ccd1248b183b3f8a1727ed02b876bf86f6576134e | Python | 6,002 | 130 | # %%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
from data_settings import data_date, pairs_path
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
from contools import Celltype, Celltype_Analyzer, P... |
b0d7df5b3ec1e513fd849bedf63c32d88f73d1309341a454e2d5bd6bcae112ed | Python | 6,003 | 178 | import numpy as np
import pandas as pd
import anndata
def simulate_network(network="Gaus",n_group=1,**network_kwargs):
"""
Input
Network parameters
network:
Output
anndata of sample x feature
"""
if network == "Gaus":
simulate_ntwrk = simulate_network_gaus
elif ... |
c9e3180217d5860ffd8fbd00d8629e5c025d8cc62ee7eabd39de85256332da9e | Python | 6,004 | 162 | import argparse
import os, pickle, shutil
# Don't log the TensorFlow info messages on imports
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "1"
import tensorflow as tf
for gpu in tf.config.experimental.list_physical_devices("GPU"):
tf.config.experimental.set_memory_growth(gpu, True)
from lfads_tf2.models import LFADS
from ... |
b88826c7397752d763c3c05d435a159e30e6efcc1190b1b5209482dc54f2cf14 | Python | 6,005 | 132 | # -*- coding: utf-8 -*-
import argparse
from phys2bids import __version__
def _get_parser():
"""
Parses command line inputs for this function
Returns
-------
parser.parse_args() : argparse dict
"""
parser = argparse.ArgumentParser()
# Argument parser follow template provided by Ral... |
c8bcf570da088c63c7bb673e22dedaecda8f356dd4b46b6022aaf2c7eae12fc0 | Python | 6,008 | 165 | #!/usr/bin/env python3
"""
File: gradient_plot.py
Created: 2020/04/15
Last Changed: 2020/06/02
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 Softw... |
1c7e2bbc2e1f420480800b5719e568647626b9f1bdcb3319ed40c868a000d82e | Python | 6,009 | 219 | #! /usr/bin/python
# -*- coding: utf8 -*-
import tensorflow as tf
import os
import sys
from sys import platform as _platform
def exit_tf(sess=None):
"""Close tensorboard and nvidia-process if available
Parameters
----------
sess : a session instance of TensorFlow
TensorFlow session
""... |
216ad409410bc8bd5fcb7edc6a5882e2c9deb6366622452b066ced9ceddbdea7 | Python | 6,009 | 210 | # 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... |
c5efa62c09daaa342d1a45daea46cb9eca404ce1e1d42c4d04b8e55f97aa1194 | Python | 6,010 | 129 | #!/usr/bin/env python3
# encoding: utf-8
# @Time : 2017/12/16 下午8:41
# @Author : yuchangqian
# @Contact : changqian_yu@163.com
# @File : ade.py
import os.path as osp
import numpy as np
import scipy.io as sio
import time
import cv2
import torch
from datasets.BaseDataset import BaseDataset
class ADE(BaseDatas... |
cf4cc032c3d7a6fd9f61889ade478f1092b7c4724f356154fa303f60598b450b | Python | 6,011 | 165 | from __future__ import annotations
from palm_tools.data_structure.trackset import TrackSet
from .ts_post_processing import PostProcessingStep
from .post_processing_params import EmptyPostProcessingParameters
from typing import TYPE_CHECKING, List
import numpy as np
import pandas as pd
from scipy.spatial import ConvexH... |
feb1cabba2bf83d75dca0b7a708bc75df4087e438ca56cb7a944237d456b554f | Python | 6,013 | 144 | import datetime
import matplotlib.pyplot as plt
import os
import pandas as pd
import seaborn as sns
import torch
from scipy import stats
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
from benchnirs.load import load_dataset
from benchnirs.process import process_epochs, extract_... |
cd022725c667d14108d3d977bd8553f733ba1455695e72a921771cef3febc050 | Python | 6,014 | 164 | # Copyright 2021-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... |
3098f8a2c192d4d38158216aee8266dc26ea8d183b4f97f9061ca5897ba759dc | Python | 6,017 | 210 | #!/usr/bin/env python
# encoding: utf-8
"""
@author: johnny
@time: 2018/12/4 22:21
"""
import torch
import torch.nn as nn
from torch.utils import checkpoint as cp
from collections import OrderedDict
class FRRN(nn.Module):
"""
implementation table A of Full-Resolution Residual Networks
"""
def __init__... |
fa3914c5f1114926fcad32222aac68b6f68e1a99c9e9c3fce92590380bac8350 | Python | 6,017 | 182 | import logging
import time
from dataclasses import dataclass
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional
import requests_cache
from oaklib.datamodels import obograph
from oaklib.datamodels.association import Association
from oaklib.interfaces import OboGraphInterface, SearchInterface
fro... |
2259a60fe43334dfecd7caa88514a77bd19c8f98977c9dfed15396feba5f3c6e | Python | 6,020 | 179 | #!/usr/bin/env python
# Copyright (c) 2018 Intel Labs.
# authors: German Ros (german.ros@intel.com)
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
""" Module with auxiliary functions. """
import math
import numpy as np
import carla
_EPS = np.fi... |
7e5916eeb07e9d9fac76ff16ddc1f20eee65f0fe6d4ba575b86e61165a801d72 | Python | 6,020 | 154 | import json
import csv
import pickle
import pandas
import pandas as pd
import xlsxwriter
from skfuzzy import cluster as fc
import numpy as np
import re
from fuzzysets import FUZZY_SETS
from writer import write_csv, write_fuzzy
from cleaner import is_number
from reader import AttributeReader
from abc import ABC, abstr... |
d10400f706dd3322a816e46f540f8c826a217778a1bb1707ec0aa1de3fa4e007 | Python | 6,020 | 171 | import pandas as pd
import os
from FBEM.various import path_to_string, subdirs, Path
class LogData:
def __init__(self, info1, numIter, bePRE, beUNPRE, time_cpu):
self.info1 = info1 # info1 = -4 if the algorithm failed in converge in maximum number of iterations; else 0
self.numIter = numIter
... |
51862ac8376a629059ca062cc82116c90efd4f20087a12db97d193aead3f8721 | Python | 6,022 | 130 | """Phase 3 — the discriminating experiment.
Train RPE and AIF on CS+/CS- conditioning, then probe with:
1. Familiar odors (CS+/CS-) without reward — both models should be calm.
2. Novel odors never seen during training — AIF DAN should spike; RPE flat.
3. Mixtures of CS+ and CS- across the full ratio space... |
cb201fa01a2cad0994a22d229a681e610ed8bd0c4d50f0620aa07235feecfc0f | Python | 6,023 | 132 | """Depth decoding/normalisation, segmentation palettes, edge masking, encoders."""
import numpy as np
import pytest
from carla_cosmos import controls
def _encode_depth_bgra(metres: np.ndarray) -> np.ndarray:
"""Inverse of CARLA's 24-bit depth encoding, for test fixtures."""
code = np.round(metres / 1000.0 *... |
c4fabb2f99d20b74cf402bc2317d9ceb96cf6cd3660b175b51bfa73f2ae97f07 | Python | 6,024 | 167 | """
File: data_comparitor.py
Created: 2020/06/30
Last Changed: 2020/11/22
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... |
17f53be8af3f6c03c43d2ea2e660c279c82ac4f1288692e27536b92426981763 | Python | 6,026 | 150 | import os
import collections
from os.path import join
import numpy as np
import pandas as pd
from itertools import chain
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import ShuffleSplit, GridSearchCV
from sklearn.metrics import (me... |
136283bc778f95512ced4e7bc364f4bd2fe4c5bff47b57b6894ec2487dd44ae5 | Python | 6,027 | 161 | import os
import sys
import mne
from types import ModuleType
from typing import Optional, Tuple
import numpy as np
from ..base import DatabaseBase, ALL, load_fids
########################################################################
class Database(DatabaseBase):
""""""
fids = load_fids(os.path.join(os.pa... |
99fd75cadfca6bccbfa59d71eada451a6c463fb86ff753620d547163a1c1988f | Python | 6,029 | 152 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms
from maskrcnn_benchmark.structures.boxlist_ops impor... |
020ad842bda768b11625a1217e79740ad265c847c7a39efe53b501e5852cfc97 | Python | 6,030 | 141 | from pathlib import Path
from os import chdir
import unittest
from nipype.interfaces.base import CommandLine
from qipype.commands import NewImage, Diff
from qipype.fitting import DESPOT1, DESPOT1Sim, DESPOT2, DESPOT2Sim, HIFI, HIFISim, FM, FMSim
vb = True
CommandLine.terminal_output = 'allatonce'
class DESPOT_SC(uni... |
194311c73c02423b8e24cb7481a54b8bb0e66a45283b239da1e8a4499045bdee | Python | 6,031 | 154 | import os
from PIL import Image
import torch.utils.data as data
import torchvision.transforms as transforms
import numpy as np
import random
import torch
class PolypDataset(data.Dataset):
"""
dataloader for polyp segmentation tasks
"""
def __init__(self, image_root, gt_root, trainsize, augmentations):... |
d874ad56f5f1d1e10f4756a0cca8c85cca9d5f299e25ee2806102dcd09be3964 | Python | 6,031 | 136 | __author__ = 'duarte'
import sys
from preset import *
import numpy as np
"""
spike_noise_input
- standard network setup, driven with noisy, Poissonian input
- quantify and set population state
- run with noise_driven_dynamics in computations
- debug with noise_driven_dynamics script
"""
run = 'local'
data_label = 'po... |
1da38f0532383556a5287c81e0da7f814eebc0a8f69402386a644d3751866d1b | Python | 6,032 | 88 | # 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... |
8791a3f8f75266ed197e132160c6b934dd0bfffab8f2d0dcbcda8945966ad42a | Python | 6,032 | 152 | """
File: FastICA_wrapper.py
Created: 2020-04-29
Last Changed: 2021-01-08
Author(s): H.H.Wiersma
Code to create distribution plot and a mask image used in the research plan
Copyright (C) 2019 H.H.Wiersma
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU... |
d6078e330d13aa078e7f1f00c90378eeaa4560530947881e7e30f7dc1a993f48 | Python | 6,032 | 191 | import os
import os.path as op
import numpy as np
import nibabel as nib
from dipy.reconst import dti
from scipy.special import gamma
import AFQ.utils.models as ut
__all__ = ["fit_dti", "predict"]
def noise_from_b0(data, gtab, bvals, mask=None, b0_threshold=50):
"""
Coped from vistasoft's dtiComputeImageNo... |
0429dac0a3720eddac3bc48edb355847c2ae33784c887f2828164b4e7aef0317 | Python | 6,034 | 154 | #%%
import os
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
print(os.getcwd())
except:
pass
#%%
import sys
sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/")
import pandas as pd
import numpy as np
import connectome_tools.process_matrix as promat... |
624f47a197d84caae73fc211c875eb63965cd5ec1b2dfa0213df343b6be31fe6 | Python | 6,034 | 163 | # 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... |
902bf2e859044fe9ba6db1c63972413527cfc72767fe247c6cdba3f78dcad973 | Python | 6,034 | 194 | import numpy as np
import itertools
import networkx as nx
from tqdm import tqdm
def path_to_visits(paths, n_verts, from_order=True, out_inds=[]):
visit_orders = {i: [] for i in range(n_verts)}
for path in paths:
for i, n in enumerate(path):
if from_order:
visit_orders[n].ap... |
4957823ba93a28432c9b8846d1763f0c3a565316b59dfad5ecec1f64e2500002 | Python | 6,035 | 223 | """
convert all CSV files (e.g. ID01_epoch1.csv.xz) to the same sampling frequency
John M. O'Toole, University College Cork
Started: 30-10-2022
last update: Time-stamp: <2022-11-10 21:05:51 (otoolej)>
"""
import sys
import argparse
import numpy as np
import pandas as pd
from scipy import signal as sp
import matplotlib... |
db222f4a64bb52ba5b448dd53e0327a924f7e3a0e798bedd204a97e51a891b35 | Python | 6,035 | 155 | #%%
import os
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
print(os.getcwd())
except:
pass
#%%
import sys
sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/")
import pandas as pd
import numpy as np
import connectome_tools.process_matrix as promat... |
2d1fc01f2dc342793e25c31f8d2909fb7dfe1704b6605a0145aeaad50978e263 | Python | 6,038 | 143 | import os
from dash_extensions.enrich import Output, Input, State, callback, ctx, no_update
from dash.exceptions import PreventUpdate
from RV.callbacks.utils.loading_utils import get_file_selection_options
from RV.callbacks.utils.saving_utils import save_annotations_csv, save_bad_channels_txt
def register_saving_ca... |
e37b96bc988f5265d1fba27e16184f476a7663d4132858d3b6c6ff6ed2b04df2 | Python | 6,038 | 146 | import os
import tqdm
import torch
from torch.utils.data import DataLoader
import shutil
import argparse
import pytorch_lightning as pl
from omegaconf import OmegaConf
from synthesizer import Synthesizer
from datasets.text import Language
from datasets import TextMelDataset, text_mel_collate
META_DIR =... |
1e891d72b00821790043188fc89380ff7a8726c533608b7f895ec403e4dc985e | Python | 6,042 | 175 | # Copyright (c) Open-MMLab. All rights reserved.
import logging
import torch.nn as nn
from ..runner import load_checkpoint
from .utils import constant_init, kaiming_init, normal_init
def conv3x3(in_planes, out_planes, dilation=1):
"""3x3 convolution with padding."""
return nn.Conv2d(
in_planes,
... |
27692a8f9ac073cbe8d2aff77de3bd7112468e5ab86bd01580209d7ad6a4495f | Python | 6,042 | 165 | import logging
import unittest
from linkml_runtime.dumpers import yaml_dumper
from oaklib.datamodels.vocabulary import IS_A, PART_OF
from oaklib.implementations.aggregator.aggregator_implementation import (
AggregatorImplementation,
)
from oaklib.implementations.pronto.pronto_implementation import ProntoImplement... |
cd825f8eb9a4c7bd6084279cc48dd6e3718d60f0494d75ed3e492a2a4fd0a85c | Python | 6,044 | 222 | #%%
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from anytree import LevelOrderGroupIter
from sklearn.metrics import adjusted_rand_score
from graspologic.cluster import AutoGMMCluster
from graspologic.embed import AdjacencySpectralEmbed
from graspologic.plot i... |
b7d9804ed5a01530d13640ce75a61efc97e8bd174aff3fb7c860dae3bac0c5a9 | Python | 6,049 | 166 | # basic imports
import os
import pickle
import numpy as np
import matplotlib.pyplot as plt
def prepare_data(data: dict) -> (dict, dict):
'''
This function averages and prepares escape latency and reverse mode probabilities.
Parameters
----------
data : A dictionar... |
8be94be9517febb0a1377adc3c9f837b4e8cf752969a726e5b02bd109116ad5f | Python | 6,050 | 164 | # Copyright 2021-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... |
0fc11e75fefc86f513dd926cd316f87f37768c24c0a0f417585c55d9cf84ed1e | Python | 6,053 | 153 | #!/usr/bin/env python
"""
Mini_catactor utilities.
"""
__author__ = "Kawaguchi RK"
__copyright__ = "Copyright 2021"
__credits__ = ["Kawaguchi RK"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Kawaguchi RK"
__email__ = "rkawaguc@cshl.edu"
__status__ = "Development"
import argparse
import pickle
import sc... |
f54372d15b4a4db85f54ec1818b18f38fd8787a430ad47f2f764bda95264a9d1 | Python | 6,054 | 143 | # basic imports
import numpy as np
import pickle
import matplotlib.pyplot as plt
def computeReactivationMaps(euclidean_similarity=False, suffix='') -> np.ndarray:
'''
This function computes the reactivation maps for replays recorded
in the experiment's three environments.
Parameters
---------... |
60ff671362e46f39532bc3f362b3e31a8b29aad7f906338960b6575adaadc401 | Python | 6,058 | 162 | from __future__ import division
import os
from xml.etree import ElementTree
from distutils.version import LooseVersion
import numpy as np
from .misc import loadmat
def prairie_imaging_parameters(filepath):
"""Parse imaging parameters from Prairie/Bruker."""
def _get_prairieview_version(xml_filepath):
... |
ae51c8fc0be0eb01ad4c25ca96b69994941f02064aeffab906fd50519ffebc8b | Python | 6,058 | 160 |
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.optim as optim
from torch.utils.data import DataLoader
from nets.yolo import YoloBody
from nets.yolo_training import YOLOLoss, weights_init
from utils.callbacks import LossHistory
from utils.dataloader import YoloDataset, yolo_dataset_c... |
4dce6243e5882cc91e5a4f8ff233989cc8ebd2d0d284f48ca6e0b2571f241265 | Python | 6,059 | 155 | import torch
import numpy as np
import pickle
from scipy.ndimage import gaussian_filter1d
from util.datasets import Augmentations
from util.datasets.mouse_v1.preprocess import *
FRAME_WIDTH_TOP = 1024
FRAME_HEIGHT_TOP = 570
class AllRandomAugmentations(Augmentations):
name = 'all_random'
svd_computer = No... |
fcc4e1ec926e8e8cad842e193964a00a65c71bd5788a89acbc854b63da7efe39 | Python | 6,060 | 112 | import argparse
import os
import os.path as op
import shutil
from glob import glob
import numpy as np
import pandas as pd
def get_parser():
parser = argparse.ArgumentParser(description='Run MRIQC on BIDS dataset.')
parser.add_argument('-b', '--bidsdir', required=True, dest='bids_dir',
... |
bb21aa55813e6685fa1f47bdfc24885802c09f0982693b7518d480be9775fdfa | Python | 6,062 | 146 | """Searching for MobileNetV3"""
import torch.nn as nn
from models.baselines.base_model.basic import _Hswish, _ConvBNHswish, Bottleneck, SEModule
__all__ = ['MobileNetV3', 'get_mobilenet_v3', 'mobilenet_v3_large_1_0', 'mobilenet_v3_small_1_0']
class MobileNetV3(nn.Module):
def __init__(self, nclass=2, mode='larg... |
4a0b9eaea70ed4ac2804a6c686370363828a19aab240e7fc1a6b5f6f13a35fad | Python | 6,063 | 178 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Variational Animal Motion Embedding 1.0-alpha Toolbox
© K. Luxem & P. Bauer, Department of Cellular Neuroscience
Leibniz Institute for Neurobiology, Magdeburg, Germany
https://github.com/LINCellularNeuroscience/VAME
Licensed under GNU General Public License v3.0
The ... |
b892af7a250798fe1c688c794e34fc7b357ae992f474efa8b70de18e0cdc32d5 | Python | 6,063 | 230 | """Toy model of a neuron with IA.
@author: Emerson Harkin
"""
# IMPORT MODULES
from __future__ import division
from copy import deepcopy
import numpy as np
import numba as nb
import matplotlib.pyplot as plt
# DEFINE MODEL CLASS
class IAmod(object):
def __init__(self, ga, tau_h, sigma_noise, tau_eff=1):
... |
66bb9a90209f2378bade9fe62dae6e41db037f044f3eaf365df11f1f97cd5777 | Python | 6,064 | 206 | import torch
import torch.nn as nn
import numpy as np
from .diverse import MLP
class ACB(nn.Module):
def __init__(self, dim_theta, dim_mu, stable_s=False, alpha=1.7, s_abs=4, t_abs=4):
"""
dim_theta : dimension of the parameters vector
dim_mu : dimension of the summary vector
"""
... |
80cc5259dec7c1d73da17cee44357b3e30d0d543caa47632cbf2f98c3c3bb4b6 | Python | 6,064 | 195 | import argparse
import os
import os.path as op
from glob import glob
from shutil import copyfile
import pandas as pd
def _get_parser():
parser = argparse.ArgumentParser(description="Run RSFC in AFNI")
parser.add_argument(
"--clean_dir",
dest="clean_dir",
required=True,
help="P... |
c2faaeffc3c6f16fa3cd15dd711c10706d5eb9f1a51df8eb0d78d654b887a510 | Python | 6,065 | 142 | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
import pdb
sys.path.append('%s/l... |
6f85298a0f9d0badbdc802df4186d444141950fde78ea90351ca78984ce00973 | Python | 6,066 | 234 | """Train a TDE-HMM model on Nottingham movie data.
"""
print("Setting up")
import os
import os.path as op
import pickle
import numpy as np
from osl_dynamics import analysis, data
from osl_dynamics.inference import tf_ops
from osl_dynamics.models.hmm import Config, Model
from osl_dynamics.utils import plotting
#%% ... |
7102b3e48c4ce718fd143c7d90d9bb87f63636100041f90e37cac77f071d6599 | Python | 6,067 | 196 | import re
import io
from plotly.subplots import make_subplots
import plotly.graph_objs as go
import plotly.express as px
import base64
import streamlit as st
import numpy as np
import pandas as pd
def V2nm(V):
"""
This function converts applied voltage to nm based on the piezoscanner calibration in the software
... |
c1183c2b219bab70ff5c362aa94e882500c14f98e872c367cf24623c09602844 | Python | 6,067 | 153 | import logging
from neo4j import GraphDatabase
from abc import ABC, abstractmethod
from bds_api.dumps.neo4j_config import neo4j_config
log = logging.getLogger(__name__)
class BDSQuery(ABC):
"""
Abstract base class for Bran Data Standards queries.
"""
def __init__(self):
try:
sel... |
12114d1c04b441a9d4a89a64a667275976477249bcff8ee1e6cbcc4121882f19 | Python | 6,068 | 160 | """Bottleneck ResNet v2 with GroupNorm and Weight Standardization."""
import math
from os.path import join as pjoin
from collections import OrderedDict # pylint: disable=g-importing-member
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def np2th(weights, conv=False):
"""P... |
ce2ee1b2b0548867cad4923768e3b1b8f6964f4dc5f92fdece06da62c4efacfe | Python | 6,068 | 153 | import itertools
import numpy as np
def get_balance_class_downsample(x, y):
"""
Balance the number of samples of all classes by (downsampling):
1. Find the class that has a smallest number of samples
2. Randomly select samples in each class equal to that smallest number
"""
class_labe... |
f02f5ceac2a479be7bcd1f657b2a4561cb0e3656fe7f767771c1105f298ccebb | Python | 6,068 | 187 | import os
from datetime import datetime
import logging
from logging import config
from bisect import bisect
from typing import Dict
class LevelFilter(logging.Filter):
"""
LoggingFilter used to filter one or more specific log levels messages
"""
def __init__(self, level):
self.__level = leve... |
0489ccf1b1b5049c973285b2bb49644a1e0797f7fbd070e96714a51db53ab8ed | Python | 6,069 | 211 | """ Test the functions implemented in models.py """
import os
import sys
import numpy as np
import pytest
import yaml
test_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(test_dir + '/../src')
sys.path.append(test_dir)
import models
import datasets
import test_datasets
N_COMPONENTS = 2
@pytest.fix... |
8880d175e3af445936181a7de8f4ee0cf2343e4c7ecbb233c9931a32fca99005 | Python | 6,070 | 121 | """Dual-DAN compartment-specialised agent.
Combines the two complementary single-channel models from Phases 1–3:
Channel R (RPE): Bennett 2021-style reward prediction error on KC->MBON
weights. Tracks reward CONTINGENCY. Drives extinction.
Biological anchor: appetitive... |
e19c0fb50083130c633bcef10cb6d68d0d4c43ba25fa1a9a02f1ccdde64aea31 | Python | 6,072 | 169 | # Copyright (c) Open-MMLab. All rights reserved.
import numpy as np
from mmcv._flow_warp_ext import flow_warp_c
from mmcv.arraymisc import dequantize, quantize
from mmcv.image import imread, imwrite
from mmcv.utils import is_str
def flowread(flow_or_path, quantize=False, concat_axis=0, *args, **kwargs):
"""Read ... |
48c2c4c9a1a6b1a528dfbbcf03690f40983a389c4fe6a27f2534ed60baf66b41 | Python | 6,077 | 221 | from OLM import OLM_Single
from neuron import h
import numpy as np
from multicompartment.record import record_V_cai_ica_dend,\
record_V_and_Cai, record_soma
from comp_opt_essential.record_1comp import set_up_full_recording
import matplotlib.pyplot as plt
from ukf import UkfEstimator
from tqdm import tqdm
from rando... |
5f45f8963bf4a50576edbcc6572b8e108a2d7b3cbb3e60221d80778e31e912bb | Python | 6,077 | 186 | import os
import torch
import clip
import numpy as np
import pickle
import torchtext
import torchvision.transforms.functional as tvf
from PIL import Image
from torch.utils.data import Dataset
class CUBZeroShot(Dataset):
base_folder = "CUB_200_2011/images"
folder_name = "cub"
def __init__(self, root, spl... |
64d8531d4da9d365b82ab1b28cc6ec8cda3e0f538d84eba99c7ba7ef1c2992de | Python | 6,079 | 154 | import numpy as np
import tensorflow as tf
class ThinPlateSplines:
def __init__(self, ctrl_pts: tf.Tensor, target_pts: tf.Tensor, reg=0.0):
"""
:param ctrl_pts: [N, d] tensor of control d-dimensional points
:param target_pts: [N, d] tensor of target d-dimensional points
:param reg... |
9e34f2740f623a85dbb0377d4f37a893f559c3ec2fe213231705a62eece41796 | Python | 6,079 | 133 | import math
from pathlib import Path
import cv2
from .saveFilesC import saveFilesC
class negativeStrideC:
def __init__(self):
super().__init__()
def negativeStride(self):
self.log_crop_event("Stride cropping started", self.number_of_voxel)
extLeft = tuple(self.biggestAreaContour[sel... |
3ec0ad6c5da342a0a5a1dc4c98029272299bc83fb339862ea457043e2dc2179e | Python | 6,081 | 128 | #%%
from pymaid_creds import url, name, password, token
import pymaid
import numpy as np
import pandas as pd
import connectome_tools.process_matrix as pm
import connectome_tools.process_graph as pg
import networkx as nx
rm = pymaid.CatmaidInstance(url, token, name, password)
# %%
brain = pymaid.get_skids_by_annotat... |
a467ce9dbb60f923425852e6a9d5842e88eac4ad178dbb09d95fee96198ee257 | Python | 6,081 | 131 | #%%
import os
import sys
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/maggot_models/')
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
except:
pass
from pymaid_creds import url, nam... |
64abbc7a110978848931b8fe2f5653aa957ebaa4941dd00461b54000850c6f98 | Python | 6,084 | 173 | # -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
import os
from nipype.interfaces.spm import SPMCommand
from nipype.interfaces.matlab import MatlabCommand
from string import Template
from nipype.interfaces.spm.base import (
SP... |
3467586fd4842726607d1a8700b92f590460926349a9cc0e1479f52c621ffb0f | Python | 6,085 | 167 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import glob
import json
import multiprocessing
import os
import tensorflow as tf
from tflib.data.dataset import batch_dataset, Dataset
_N_CPU = multiprocessing.cpu_count()
_DEFAULT_READER_BUFFER_SIZE_BYTE... |
41b07313bca4ca1266e0282a115fdbf455edfd08b121d675d1916c5c204b07fa | Python | 6,086 | 156 | """
File: covariate_comparison.py
Created: 2020/04/15
Last Changed: 2020/06/19
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, ei... |
8c11dec0cbbb489f3c8524b3dd992f7fe580ac964806431e71601d1939985a9f | Python | 6,089 | 159 | import pandas as pd
import sys, os, subprocess, logging, re
def log_message(*message):
"""write message to logfile and stdout"""
if message:
for i in message:
logging.info(i)
print(i)
def create_symlink(src, dest):
"""symlink file"""
if not os.path.isfile(dest):
... |
df51b286b0b976a505e7cb070aaa45afb3e78037ca1126ff05d897fc1571d573 | Python | 6,089 | 115 | __author__ = 'duarte'
from modules.parameters import ParameterSet, ParameterSpace, extract_nestvalid_dict
from modules.input_architect import EncodingLayer, InputNoise
from modules.net_architect import Network
from modules.io import set_storage_locations
from modules.signals import iterate_obj_list
from modules.visuali... |
235cfac4cec030c349fae493db5edc98955639077df19c036c025a20eab733cd | Python | 6,093 | 133 | import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
class SegNet(nn.Module):
def __init__(self,classes=2, aux=True):
super(SegNet, self).__init__()
batchNorm_momentum = 0.1
self.conv11 = nn.Conv2d(3, 64, kernel_size=3, padding=1)
... |
6cf2e3ba5352f4a1b9f2b9f4ca17e2f463781be175c4fdf226e56d1b62911999 | Python | 6,096 | 218 | #%%
from operator import itemgetter
from pathlib import Path
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import pandas as pd
import seaborn as sns
from graspy.plot import heatmap
from graspy.utils import binarize
from src.data import load_networkx
from src.utils import meta_to_array
vers... |
9e7bac84e403e0440823066cdbe0f7ba50586842af7d52daed70562a9d14abf9 | Python | 6,096 | 182 | ##########################################################################################
## Cell type enrichment analysis of ASD PPI networks using Velmeshev2019 data
## (1) assess overlap between networks vs. genes expressed in >50% of cells in cell type
## (2) assess overlap between networks vs. ASD-DEGs in each ce... |
3ead781d9e6fcfce8198ad3e7af7daa2edf192c2745da848c50cb2af41491722 | Python | 6,097 | 256 | # %% [markdown]
# ##
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from graspy.simulations import sbm
from src.data import load_metagraph
from src.graph import preprocess
from src.hierarchy import signal_flow
from src.io import savefig
from src.traverse import ... |
5b3e27647fc1b74e1c678e4e9a0930f0aa20ff85aabeedcd7c5fe62dc6e27ee9 | Python | 6,097 | 205 | import numpy as np
import elasticdeform
import scipy.ndimage as ndimage
import torch.nn as nn
# NOTE: elastic_transfrom and random_rotate are taken from below
# https://github.com/The-AI-Summer/learn-deep-learning/tree/main/Medical
def exp_dim_mask(image, mask):
"""
Pads the mask to resolve the extra dimens... |
e896e2a6e9b2aa30f2c1d43523af73f7490a9904e4f2c3c9f47176bc17c5ba01 | Python | 6,097 | 168 | import torch
import torch.nn as nn
import math
__all__ = ['U2NET_full', 'U2NET_lite']
def _upsample_like(x, size):
return nn.Upsample(size=size, mode='bilinear', align_corners=False)(x)
def _size_map(x, height):
# {height: size} for Upsample
size = list(x.shape[-2:])
sizes = {}
for h in range(... |
a92bcaafb1cc776544fe087228dc626bf69c10d67a82dd75b1e57129236e9d3a | Python | 6,099 | 210 | '''
Figure 10.
Second part, Paramecium bumping into a 'wall', modeling as a depolarizing stimulus with 50 ms activation/deactivation.
'''
from brian2 import *
from pylab import *
import matplotlib.font_manager as fm
import os
from plotting import *
from matplotlib import gridspec
from mpl_toolkits.axes_grid1 import mak... |
31a0539f9d1683177d2c378db06f7009d1cd9befce8f46042bed53dc96f2b2b8 | Python | 6,100 | 169 | from dataclasses import dataclass
from typing import Any, Tuple, Union
import rdflib
from rdflib import OWL, RDF, RDFS
from oaklib import BasicOntologyInterface
from oaklib.converters.data_model_converter import DataModelConverter
from oaklib.datamodels.obograph import (
Edge,
Graph,
GraphDocument,
Me... |
d26db8ffa56ec2d4d0904c042853f91b153f822efe39e9a1d22f04ce4a8b76a6 | Python | 6,100 | 149 | """
MODULE VERSION:
Combining peptide and membrane structures into a single system.
"""
import os
import core.settings as CoreSettings
import core.system as System
import core.gromacs as Gromacs
import core.gromacs_commands
import user.usersettings as UserSettings
def module_insert_peptide(simulation):
"""
... |
dae769ba37a3118232a9f41d39caeb3b2a344e973176d9d65ad0991f6655348b | Python | 6,100 | 151 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains specific functions for computing losses on the RPN
file
"""
import torch
from torch.nn import functional as F
from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler
from ..utils import cat
from ma... |
d9e35a7456845dd92b8f35087265b5359c793a176c0875d12b4db4c91751bdfd | Python | 6,101 | 156 | #!/usr/bin/env python3
"""
@ Lina Teichmann
INPUTS:
call from command line with following inputs:
-bids_dir
OUTPUTS:
Runs a linear regression, using the MEG data at every timepoint to predict animacy and size ratings for each image.
NOTES:
The plot was made in matlab so it looks t... |
aab3d009d86f83d4ae1c7388cff7e584fb0435a189416c49b3ec5d75e68e1ab6 | Python | 6,106 | 215 | from __future__ import division
from __future__ import unicode_literals
from builtins import str
from builtins import range
# Copyright: Luis Pedro Coelho <luis@luispedro.org>, 2012
# License: MIT
#
# https://gist.github.com/luispedro/3437255
#
# Modified 2014 by Jeffrey Zaremba.
import numpy as np
from itertools impo... |
4d42e954b5678a52bb8ee9fae32803e3598b777b5231866ee2291253f825c1f4 | Python | 6,110 | 249 | # #%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting
# # ms-python.python added
# import os
# try:
# os.chdir(os.path.join(os.getcwd(), "maggot_models/notebooks"))
# print(os.getcwd())
# except:
# pass... |
cab9fb3e8ab1c781c5f2d922c86b71ead5aee0e5f8b865531da0f3e0f5b547ac | Python | 6,110 | 150 | import argparse
from dateutil.relativedelta import relativedelta
from datetime import datetime
import descarteslabs as dl
from tqdm import tqdm
import os
from scripts import dl_utils
DL_SYSTEM_PARAMS = {
'image': ('us.gcr.io/dl-ci-cd/images/tasks/public/' +
'py3.8:v2020.09.22-5-ga6b4e5fa'),
'cp... |
7b72519f75a24faa113a2c44064905d03a688f1677de17969c89040258d773e2 | Python | 6,114 | 102 | import tensorflow as tf
from Electrostatics import G_matrices
from Utilities import outer_product
# Anisotropic repulsion from 'Classical Pauli repulsion: An anisotropic, atomic multipole model' by Rackers et al.
# https://aip.scitation.org/doi/10.1063/1.5081060
# Damping coefficients are based on the reference imple... |
e83b0ed234cf3513164a49d6f65258d8f2e4d3f227b1a970bc3299f5c2379a7a | Python | 6,114 | 146 | import torch
from mmdet.core import bbox2result
from ..builder import DETECTORS, build_head
from .single_stage import SingleStageDetector
@DETECTORS.register_module()
class YOLACT(SingleStageDetector):
"""Implementation of `YOLACT <https://arxiv.org/abs/1904.02689>`_"""
def __init__(self,
b... |
8b04ec7b83f2ab221e1e58b595aab05a4c2d9be04bdfde4ae91fb2a73c2a4471 | Python | 6,115 | 195 | # Copyright 2022 California Institute of Technology
from tkinter import N
from webbrowser import get
from cell_detection import *
from spot_detection import *
from image_manipulation import *
import params
from params import *
import pandas as pd
from argparse import ArgumentParser
import os
from glob import glob
imp... |
ad773011d27a9b37263b3e073e14007fd0339aa87221d4f42dcc2956ec6becc6 | Python | 6,116 | 146 | # The semantic domains of the ontologies.
# These map to different "sub" ontologies (or ontology modules) within
# the overarching ontology.
#
# These are specified in the direction DOMAIN: [LIST_OF_FEATURES]
features_domains = {"study_feature": [
"control",
"Pharmaceutic... |
b8481b9f9d7652033c3232647c909e687d1a5a4854b94bed258048cb7d5e8275 | Python | 6,116 | 151 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
"""Reference from https://github.com/jchen42703/CapsNetsLASeg/blob/master/capsnets_laseg/models/capsnets.py#L165"""
class Length(nn.Module):
"""Computes the length of output vector:
... |
245cdd3308141fbb6d2b04b850d45fabb56a0f8ac74c857c7dd0d38238664f0d | Python | 6,120 | 176 | # 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... |
78fb5aeb6b43f45d55b6d5879d35817007c69b9aeaa7bb49baa69d72ebcaf6d8 | Python | 6,122 | 170 | # 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... |
ee15243f78277cde14c9b0da70b283de0c8a04ac9c15d88eb140fb33fe7541f2 | Python | 6,122 | 184 | from __future__ import unicode_literals
from builtins import input
from builtins import zip
from builtins import str
from builtins import range
import os
import sys
from pickle import Unpickler as _Unpickler
import pickle as pkl
from distutils.util import strtobool
import numpy as np
from sima import ImagingDataset, ... |
f3b7f1a5d1c1524a2533a66895c000d737b5fd06adaeec816e6333c94a0ec9c4 | Python | 6,122 | 179 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.make_layers import conv_with_kaiming_uniform
from maskrcnn_benchmark.modeling.make_layers import deformable... |
131869e88fd3976276939f6d98541eb75ff5f704bd761fdf98e1c69a768b1636 | Python | 6,123 | 257 | # %% [markdown]
# ##
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from graspy.simulations import sbm
from src.data import load_metagraph
from src.graph import preprocess
from src.hierarchy import signal_flow
from src.io import savefig
from src.traverse import ... |
6acc313ff70e721ac10468057ec1ece5a59a1b765cdd696f54767c78b9e2a0f2 | Python | 6,125 | 182 | # 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.