sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
94d25c1d4bcc763b494967ed4b4a49d2c348535626b87e8d77838b6e13bc3c9f | Python | 5,059 | 147 | # 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... |
ae4e59aa4a3e3aa6958fc3e40363af0b65e4f289d218308a5dd415503aec3e81 | Python | 5,059 | 135 | """
Handles computing and outputting the log fold change scores
"""
from scipy.special import logit
from .handler import PredictionsHandler
class LogitScoreHandler(PredictionsHandler):
"""
The logit score handler calculates and records the
difference between `logit(alt)` and `logit(ref)` predictions
... |
b25e9d1b8bccb300aeedfe01326f9af15bc53a5e73feb6aaac5b35d1bffbaa84 | Python | 5,060 | 126 | from __future__ import print_function, division
import numpy as np
from ase.db import connect
from tinnet.regression.regression import Regression
lr = 0.0007277509272133079
lamb = 0.1
atom_fea_len = 177
n_conv = 5
h_fea_len = 33
n_h = 5
Esp = -4.24
db = connect('train.db')
images = np.array([r.toatoms()
... |
6ce8504f807993f6091f98baf59ad33d56076e733ba2a4b84373061b3aa36fa8 | Python | 5,062 | 129 | import time
from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
from .compute_madd import compute_madd
from .compute_flops import compute_flops
from .compute_memory import compute_memory
class ModelHook(object):
def __init__(self, model, input_size):
assert isinstanc... |
ea4cedcf93bc17eb11aa3ed7ba36842c0d572e0e647d91b1053f54d4ba55a572 | Python | 5,062 | 122 | # 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 SyncSmokeTest
WORLD = "Town10HD_Opt"
class TestWalkerNa... |
76bbc4f56dfa005898167f61755bf1072c62b6e4fd4cae299ce57a211016f5d3 | Python | 5,064 | 121 | # basic imports
import os
import gc
import pickle
import numpy as np
# framework imports
from cobel.agents.sfma import SFMAAgent
from cobel.analysis.rl_monitoring.replay_monitors import ReplayMonitor
from cobel.interfaces.gridworld import InterfaceGridworld
from cobel.misc.gridworld_tools import make_open_field, make_g... |
18ee0c7c068c76a705f8477712db250f443f9464172c79f169a33635cef6b3c9 | Python | 5,065 | 94 | from functions import *
import pickle
import matplotlib.pyplot as plt
starttime = datetime.now()
#Running this script required 0.6sec on a MacBook Pro with a 2.3GHz Quad-Core processor and 16 GB of RAM
#Plot Figure IBMTorontoComparison comparing the results of a single state transition in the network of Giacomantonio... |
60970a414ee501e8abeb31bab1317d984223c446df2a968bebe9aaea8aa11af6 | Python | 5,065 | 130 | #!/usr/bin/python
import numpy as np
import os
import Bio
import shutil
from Bio.PDB import *
import sys
import importlib
from IPython.core.debugger import set_trace
# Local includes
from default_config.masif_opts import masif_opts
from triangulation.computeMSMS import computeMSMS
from triangulation.fixmesh import fi... |
6572ce3653f83f5728b6dfeae7b8d79ee71c0864060a518ab7a24433d4c3641f | Python | 5,065 | 150 | # @author: Miroslav Kuchta
# |---|---|
# | F | S |
# |---|---|
#
# We will read in a background mesh which is union of solid and fluid
# Then we might want to do seperate fluid/solid computation on the
# corresponding submeshes. For this we might need to put that from the
# union function space to the spaces on the sub... |
6f6f2eee3b825f75c5d07dc76bf8e947599352badce501832ba623230d2b84ed | Python | 5,072 | 158 | '''
Full model
'''
from brian2 import *
from brian2.units.constants import faraday_constant,gas_constant
from scipy.special import exprel
from file_management import *
import csv
from os.path import split
__all__ = ['paramecium_constants', 'paramecium_equations']
## Build the table of Paramecium constants
paramecium_... |
b1d7f20745f6e0221c17316bdd2aa5eea662f99711bf26947db5f1dc6e576707 | Python | 5,072 | 124 | import numpy as np
from scipy import sparse
from scipy.sparse.linalg import spsolve
import pyqtgraph as pg
def savitzky_golay(y, window_size, order, deriv=0, rate=1):
"""From SciPy cookbook
https://scipy-cookbook.readthedocs.io/items/SavitzkyGolay.html
Not particularly useful for undersampled data!!
Smooth (and ... |
7a3965ba01d91de620e121cd063ddcf2b5be8eaf12c65fe9d19257e9ced222ae | Python | 5,075 | 161 | """
This is a skeleton file that can serve as a starting point for a Python
console script. To run this script uncomment the following lines in the
``[options.entry_points]`` section in ``setup.cfg``::
console_scripts =
fibonacci = palm_tools.skeleton:run
Then run ``pip install .`` (or ``pip install -e .... |
c25dc54b6f4d0292405990f0340de73ffdd2ca38ea9d6eee58f6c2530ced8f73 | Python | 5,075 | 159 | import numpy as np
import torch
def bbox_flip(bboxes, img_shape, direction='horizontal'):
"""Flip bboxes horizontally or vertically.
Args:
bboxes (Tensor): Shape (..., 4*k)
img_shape (tuple): Image shape.
direction (str): Flip direction, options are "horizontal" and
"verti... |
8e585c111fe98e19aed5ee77d97b71d997593542a8c04ba31ce7ce25eb4a5f1a | Python | 5,079 | 116 | # 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>.
from . import SyncSmokeTest
import carla
import time
import numpy as np
from queue import Queue
fro... |
863008eb4d0de905fc659cd150a8ed250759a8cd9443ca409b1b0f9cf5b932c0 | Python | 5,084 | 126 | import unittest
import numpy as np
from alpamayo_controller import TrajectoryTracker
class ControllerTest(unittest.TestCase):
def setUp(self):
self.tracker = TrajectoryTracker()
def test_straight_accelerating_path(self):
path = np.column_stack(
(np.arange(0.5, 10.5, 0.5), np.zer... |
1a82aa0f8c39f4ec905fb51317e5bf40b7b55a02c471c360a11c7f2f9aafbe73 | Python | 5,086 | 141 | """
simple script for calculating novelty stats
Datasets used for these stats:
bigpatent dataset: https://evasharma.github.io/bigpatent/
clpubsum: https://github.com/EdCo95/scientific-paper-summarisation
arxiv: https://github.com/armancohan/long-summarization
scisummnet: https://cs.stanford.edu/~myasu/projects/scisum... |
d8d6b0676f543eca4317f3049d51c185110f833732bbaae4566122533bbc704a | Python | 5,086 | 113 | import tensorflow as tf
import numpy as np
import tensorlayer as tl
# from tensorlayer.layers import InputLayer, Conv2d, Conv3dLayer, UpSampling2dLayer, SubpixelConv2d, ElementwiseLayer, BatchNormLayer, ConcatLayer
from tensorlayer.layers import *
from .custom import *
from tensorlayer.layers import Layer
#w_init =... |
65b9305fd5691312919edb2a0ab5809f5248875e4268d8d2cfea03ee09ed5778 | Python | 5,087 | 197 | #%%
import os
import time
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import pandas as pd
import seaborn as sns
from giskard.plot import stacked_barplot
from graspologic.partition import (
HierarchicalCluster,
hierarchical_leiden,
leiden,
modularity,
modularity_compon... |
6a4004542ab18f90ce8ade78205b887a88323cda73eaa80dd7a6eb99a549c119 | Python | 5,093 | 142 | """
File: cmd_line_arguments.py
Created: 2020/03/23
Last Changed: 2020/06/10
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, eit... |
3c046b9c298c1a69e9b00203796b4b09c7b649d9971551ac1e3ca5c0b01f6d89 | Python | 5,094 | 182 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pathlib
import unetsl.cerberus
import unetsl.model
import unetsl.masker
import numpy
import click
def guessShaper(key):
"""
REDUNDANT see unetsl.cerberus.__main__
"""
kl = key.lower()
if "crop" in kl:
return "crop"
... |
4ec1c953603343923df3c0ee6adedbc4f2ebe72cbfb968c7ed602dd77c088057 | Python | 5,095 | 141 | import torch
from .builder import IOU_CALCULATORS
@IOU_CALCULATORS.register_module()
class BboxOverlaps2D(object):
"""2D IoU Calculator."""
def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate IoU between 2D bboxes.
Args:
bboxes1 (Tensor): bboxes have... |
b3a2b5422db3fa019f57ab003806954158562d33756d2f6da6cb49191e0004ab | Python | 5,096 | 148 | import os
import torch
import torchvision
import torch.nn as nn
from torchvision import transforms
from torchvision.utils import save_image
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Hyper-parameters
latent_size = 64
hidden_size = 256
image_size = 784
num_epochs = ... |
0499a63d70729c1b687f57899ccdf73b11717343714ecb3e638a5b1e933a9abf | Python | 5,098 | 78 | import carla,time,json,math,queue,argparse,os
from pathlib import Path
from PIL import Image
parser=argparse.ArgumentParser(description='Model 3 integration check; use an isolated CARLA server.')
parser.add_argument('--port',type=int,default=4674);args=parser.parse_args()
P=Path(os.environ.get('CARLA_MODEL3_WORKDIR',Pa... |
2aa8adaac100d46c0bc46f569469ec8960bf7b701c6b2db4c522a53c9ed6c8f7 | Python | 5,099 | 132 | import os
from os.path import join
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import ShuffleSplit, GridSearchCV
from sklearn.metrics import (mean_absolute_error, mean_squared_error,
... |
15704b0a6464587335c6942518c37b5c5f7e2ea8ca52eaf233a4d89b93870907 | Python | 5,100 | 181 | #%% [markdown]
# # Generating a graph layout for the Hemibrain data
# > Here I use some of our layout tools to plot a 2D representation of the Hemibrain Fly Connectome.
# dataset.
#
# - toc: true
# - badges: true
# - comments: true
# - categories: [pedigo, graspologic, connectome]
# - hide: false
# - search_exclude: ... |
942b3c4e3d4f74e2e71432d7afb0627872b297dd77ed176c376055922d4db237 | Python | 5,101 | 128 | # 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... |
bfad6b0c61545a9aac6d789da65b4ab0553e35308f43904e41d3a85e18220981 | Python | 5,101 | 139 | # 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... |
7eaf8e1213fab75f21043649a32980a375478504c79aa9b6d5da588b43524fb6 | Python | 5,105 | 79 | """Images for PythonAPI/docs/snipets: draw_box, TrafficLight.set_state, Map.get_waypoint."""
import os, sys, queue, math
import numpy as np, carla
from PIL import Image, ImageDraw, ImageFont
sys.path.insert(0, os.path.dirname(__file__)); import scene
OUT = sys.argv[1]; os.makedirs(OUT + "/tl", exist_ok=True)
MONO = Ima... |
08903749588fa5d44cbcd3f9010718adc7bd098aed1c253d3dd20e26c089862b | Python | 5,106 | 130 | import os
import cv2
import glob
import torch
import shutil
import numpy as np
from tqdm import tqdm
from util.reverse2original import reverse2wholeimage
import moviepy.editor as mp
from moviepy.editor import AudioFileClip, VideoFileClip
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
import time
fr... |
24123410bbf2ab19ba69897a80445681cb5bfd83407681fc917e4728331e8d9e | Python | 5,106 | 160 | import SimpleITK as sitk
from PIL import Image
import numpy as np
import cv2
import pydicom
def load_dcm_video_new(videoname):
# load dcm video
d = SITK.ReadImage(videoname)
video_array = SITK.GetArrayFromImage(d)
if len(video.shape) == 3:
frame_num, height, width = video_array.sha... |
cf15a545f3daf326672a14707988713b9453eb0ebba77c4f7cd12d0dd1ac98b1 | Python | 5,107 | 123 | #!/usr/bin/env python
# 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 argparse
import math
import carla
"""Visualize the different vehicle... |
dc0085da7ac53dafaafeff4f691787d89d5eb779fcbf790cf87e07d37cb45e50 | Python | 5,107 | 140 | # basic imports
import os
import pickle
import numpy as np
import matplotlib.pyplot as plt
def recover_position(state: int, width: int) -> np.ndarray:
'''
This function recovers the position coordinates of a state.
Parameters
----------
state : The state index.
... |
e0ee811f1c93446be77f93d49087b3882861d009069288e0b947e10095805062 | Python | 5,110 | 110 | import argparse
import torch
import torch.nn as nn
import numpy as np
import os
import pickle
from data_loader import get_loader
from build_vocab import Vocabulary
from model import EncoderCNN, DecoderRNN
from torch.nn.utils.rnn import pack_padded_sequence
from torchvision import transforms
# Device configuration
devi... |
d3d3757fffd1fd252b4d89d103db255695154d2f830067c891c0171ca0d71bfc | Python | 5,111 | 183 | #%%
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... |
9052284365b471acd4d068167b3dbcc5084388bed0b7e1248d1488c46942f817 | Python | 5,113 | 149 | """
Run multidimensional scaling on single trial responses in category-selective brain areas.
Usage:
python mds_betas.py <subject_ID> <bids_path> <category_1> <category_2> <color_1> <color_2>
Examples:
python mds_betas.py 01 /home/user/thingsmri vehicle tool lightskyblue mediumvioletred
python mds_betas.py 01 /home/... |
a5f7978b270e0d66e38e5b651fe77a9bd115663cf86293c22f67f7d5247174bc | Python | 5,114 | 163 | import rdkit
import rdkit.Chem as Chem
import numpy as np
import copy
from chemutils import get_clique_mol, tree_decomp, brics_decomp, get_mol, get_smiles, set_atommap, enum_assemble, decode_stereo
def get_slots(smiles):
mol = Chem.MolFromSmiles(smiles)
return [(atom.GetSymbol(), atom.GetFormalCharge(), atom.G... |
8a4feb40067d4c72458026d999504820e0adaa0571e2823abce449f1c9ebdf45 | Python | 5,116 | 81 | """TM traffic: aerial Cinematic camera + top-down camera with hybrid-physics overlay.
python3 traffic.py OUT --aerial x,y,z,yaw,pitch --top x,y,z --frames 160
"""
import argparse, os, queue, sys, math
import numpy as np, carla
from PIL import Image, ImageDraw, ImageFont
sys.path.insert(0, os.path.dirname(__file__))
im... |
292eb12ea60132224ce8419f2f2af5a902b7dbdc82aaf3795e094472b8e0d767 | Python | 5,117 | 94 | """Sensor gallery from one static viewpoint (Town10HD_Opt).
python3 gallery.py OUT --pose x,y,z,yaw[,pitch] [--weather k=v,...]
Writes OUT/<sensor>.png (+ lidar/radar .npy) all of the same frozen scene.
"""
import argparse, os, queue, sys, time, json
import numpy as np, carla
sys.path.insert(0, os.path.dirname(__file_... |
5c55822c774b8ee2288807671e51d74fc347be0332f228fead9acaec5c2db95b | Python | 5,117 | 147 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# 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 of... |
6152ce0a7d1e8634718c8c9b66f09f8f1326443c80a28e23aaf04d48cb725ee6 | Python | 5,118 | 140 | #!/usr/bin/env python3
"""
File: marker_genes_selection.py
Created: 2020/04/08
Last Changed: 2020/04/26
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 F... |
4cb9f612a2af87a1b2a079ff61b2fa78707be0d58fa64201b86045d4579dea66 | Python | 5,119 | 139 | from functools import partial
import mmcv
import numpy as np
import torch
from mmcv.runner import load_checkpoint
try:
from mmcv.onnx.symbolic import register_extra_symbolics
except ModuleNotFoundError:
raise NotImplementedError('please update mmcv to version>=v1.0.4')
def generate_inputs_and_wrap_model(con... |
07af312246cd9b38f9638ab02af4c3da47eee707a75fdf0562426356106566e9 | Python | 5,120 | 111 | import sys, getopt
import ddmr.utils.constants as C
import os
def parse_arguments(argv):
try:
opts, args = getopt.getopt(argv, "hg:b:l:r:d:t:i:f:x:p:q:", ["gpu-num=",
"batch-size=",
"... |
9194d710ea3273f4aa2ae654396df894213fd3b29b19f2d548be912e758f65e5 | Python | 5,120 | 151 | ''' Define the Layers '''
import torch
import torch.nn as nn
from torch.nn import MultiheadAttention
import math
def pad_mask(seq, pad_idx=0):
return seq == pad_idx
def tri_mask(seq, diag=1):
''' For masking out the subsequent info. '''
sz_b, len_s = seq.size()
masks = torch.ones((len_s, len_s)).tri... |
dc3885360fe6ef6fb7bf1be354f6caca0a843ba6749fe5af92d30c36f314639b | Python | 5,121 | 125 |
import numpy as np
import pydicom
import os
import argparse
from DicomData import DicomData
def get_filepaths(directory):
"""
This function will generate the file names in a directory
tree by walking the tree either top-down or bottom-up. For each
directory in the tree rooted at director... |
fe5836aa1b3b3ec659ab13a52039ed892be0f655445072c7669680188a66c8d3 | Python | 5,122 | 154 | # 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... |
04daf6d940108e03d2398b626d78d9e197a6a38de4ef7cf849f34e455870a616 | Python | 5,123 | 151 | #!/usr/bin/env python3
###
# #%L
# Triangulated surface for deforming in 3D.
# %%
# Copyright (C) 2013 - 2023 University College London
# %%
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software w... |
79eaa5782a301cffd81f93b3d245d08488b375e138618005a0b10988032a64ff | Python | 5,123 | 126 | import datetime
import matplotlib.pyplot as plt
import os
import pandas as pd
import seaborn as sns
import torch
from scipy import stats
from benchnirs.load import load_dataset
from benchnirs.process import process_epochs, extract_features
from benchnirs.learn import machine_learn, deep_learn
ALL_DATA_PATH = '../..... |
4a3c4fed13d82b44c5dc0b8553d4e1fea26dd2d9e5e126539c1418f46be1580f | Python | 5,124 | 132 | # 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... |
4afeb47413a9a01fccecac716f3ff61ee828a5562e3908d140f32edce3fdc895 | Python | 5,124 | 179 | import numpy as np
import pandas as pd
from importlib import reload
from os import rmdir, remove, listdir
from os.path import exists, isfile
from math import sqrt
import persistence_statistics_per_quadrant as stats
reload(stats)
from scipy.stats import skew, kurtosis, entropy
# TEST - quadrant_statistics
##############... |
2121a0731ca083bed509d790099912bbdd9c0b5217e6817af1e2021536194c54 | Python | 5,125 | 156 | # Copyright 2016 Vimal Manohar
# Apache 2.0.
"""This module contains utilities for preparing the HUB4 broadcast news
evaluation corpora.
"""
import os
import re
import sys
def parse_uem_line(reco, line):
"""This method parses a 'line' from the UEM for recording 'reco'
and returns the line converted to ka... |
f5b7efc37de7ba9efc0ce049722879ab6301232469815fa0f3d02908d97fd723 | Python | 5,127 | 149 | """Implementation of optimization based attack,
CW Attack for ROBUST point perturbation.
Based on AAAI'20: Robust Adversarial Objects against Deep Learning Models.
"""
import pdb
import time
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
class CWKNN:
"""Class for CW attack.... |
28951be06057df6e61d060329bf914a125b72fbba72e00c1f1721b2515b3dff3 | Python | 5,128 | 140 | ####################################################################################################
# Copyright (c) 2020, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free softwar... |
03dc239e571b5ba68d36b09d676270685514488a6450af5056557cf29e2a26ed | Python | 5,129 | 97 | # Copyright (c) 2016, Konstantinos Kamnitsas
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the BSD license. See the accompanying LICENSE file
# or read the terms at https://opensource.org/licenses/BSD-3-Clause.
from __future__ import absolute_im... |
e317f1229015e13f337e7b08e83c6b13a5aaacff4a5c7d6a70863ad0f2748ee9 | Python | 5,129 | 112 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
ground-truth element may be assigned t... |
a13bf9a0bda23c1e0e4df7832bba911e9b9f5a5b51bf3a54bdecfb343a63ffca | Python | 5,130 | 125 | import os
import torch
from graphxai.explainers import *
from graphxai.datasets import Mutagenicity, Benzene, FluorideCarbonyl
from graphxai.gnn_models.graph_classification import GIN_3layer, GCN_3layer, GAT_3layer, SAGE_3layer, JKNet_3layer
def get_exp_method(method, model, criterion, pred_class, data, device, train... |
07a2cd42483f7aac1902747a16370774ffd19ee525083f256424ee96ab861d8b | Python | 5,133 | 133 | import datetime
import json
import logging
import os
import re
import shutil
import subprocess
import warnings
from drugex.logs import config, logger, setLogger
from drugex.logs.config import LogFileConfig
BACKUP_DIR_FOLDER_PREFIX = 'backup'
def export_conda_environment(filepath: str):
"""Export the conda enviro... |
c56b8773b2f8eab9c49b74a5ee2f7c7ee916f4241ac5cd64fac027be02c12571 | Python | 5,134 | 134 | # YOLOv5 experimental modules
import numpy as np
import torch
import torch.nn as nn
from models.common import Conv, DWConv
from utils.google_utils import attempt_download
class CrossConv(nn.Module):
# Cross Convolution Downsample
def __init__(self, c1, c2, k=3, s=1, g=1, e=1.0, shortcut=False):
# ch... |
e3503164734a52e18fbe79bcf99a3098d0c0a5747fad04cd23e5e8f286679d6a | Python | 5,135 | 126 | # 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... |
83ac87ab6904dae165f1b855839358d7e814dfbe2df8b845f869fef947b1cf03 | Python | 5,137 | 144 | """Attention layers (some modules are copied from https://github.com/Diego999/pyGAT."""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class DenseAtt(nn.Module):
def __init__(self, in_features, dropout):
super(DenseAtt, self).__init__()
self.dropout = dropout... |
9250cd3cde2fd425386fa5ddfb6ca3269216f0af1640489950772d66c223492d | Python | 5,137 | 142 | import argparse
import os
import numpy as np
import scipy.io
from PIL import Image
parser = argparse.ArgumentParser('dataset list generator')
parser.add_argument("--data_root", type=str, default='./', help='where dataset stored.')
args, _ = parser.parse_known_args()
data_root = args.data_root
print("Data dir is:", ... |
eab6a321477345ecd323a1101e314dd9844096de49e00afaca9620064f29108c | Python | 5,138 | 53 | """Minimal HTML status page at ``/ui`` (token kept in the browser's localStorage)."""
PAGE = r"""<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>carla-cosmos</title>
<style>
:root{--bg:#f6f7f4;--fg:#1e2320;--mute:#6a736c;--line:#d7dcd5;--acc:#2f6f5e;--bad:#a23b3b;--ok:#2f6f5e;--warn:#9a6b1f}
@media(... |
94135b85a11a5ae50100b0e6f27ca6cd5a291ce0b2953e863031c410cc6b7dcc | Python | 5,140 | 149 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import List, Tuple, Dict
import pandas as pd
from tmkit.chain.Collate import Collate as coll
from tmkit.chain.CollateBatch impo... |
545a483d3019ddd5218b9aefb37de9ac18b970526c52e3597366a9b2b617be61 | Python | 5,141 | 180 | #%%
import datetime
import time
from ast import literal_eval
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from giskard.plot import crosstabplot
from graspologic.cluster import DivisiveCluster
from src.data import join_node_meta, load_maggot_graph... |
630f5296fb07c5024f4349b47c9d4bd517d7f07c1303c8e0e45d88b5c8dbe094 | Python | 5,141 | 182 | import matplotlib.pyplot as plt
import numpy as np
import pathlib
import json
import seaborn as sns
from datetime import datetime
from helper.misc import infer_and_accuracy, clear_print
from helper.data import load_data, get_architecture
from mip.get_nn import get_nn
from gd.gd_nn import GD_NN
colors = sns.color_palet... |
f7f6d5c3bf08b62fe69d30f3ac716c3a53c7428daece12924932787d6fc7c95a | Python | 5,149 | 168 | """CTF Rest Dataset: Static Network Analysis.
In this script we calculate static network metrics using source
reconstructed resting-state MEG data.
The examples/toolbox_paper/ctf_rest/get_data.py script can be used
to download the training data.
"""
import os
import numpy as np
import pandas as pd
from osl_dynamics... |
5a69772a1679c7e739092bb55b3e7a14ba7f704ac0ae42a7bd7c9a4f6888b2c3 | Python | 5,152 | 103 | import glob, tempfile, os
import PIL.Image
import numpy as np
import torch, torchvision
WHITE = (255,255,255)
GREEN = ( 0,255, 0)
RED = (255, 0, 0)
BLUE = ( 0, 0,255)
BLACK = ( 0, 0, 0)
class Dataset:
def __init__(self, inputfiles, targetfiles, patchsize=512, augment=False, colors=[WHITE, GREEN... |
6f1156dbcef7b1ad8f9c9b610212240f0a7925a10e58fda344e2c1a056898fdc | Python | 5,157 | 174 | import numpy as np
import tensorflow as tf
from typing import Union
from .layer.layers import DownBlock, UpBlock
class Generator(tf.keras.Model):
"""Generator for Pix2pix and CycleGAN. Can also be used as plain
U-Net with mode=="UNet"
:param initialiser: e.g. keras.initializers.RandomNormal
:param c... |
1d65e904446b32323faca3d08921616e05edb979b62bddfabf1a0a8045dcea0c | Python | 5,158 | 156 | import torch
import numpy as np
import scipy.stats as st
import sklearn.metrics as metrics
import warnings
warnings.filterwarnings("ignore")
from tqdm import trange
from sklearn.model_selection import KFold, train_test_split, StratifiedKFold
from sklearn.metrics import f1_score, accuracy_score, precision_score, recal... |
bb71e4f740c1ffdd48a38f44bd24aed287d608869d99851ab79ab15d2b53c547 | Python | 5,158 | 133 | #!/usr/bin/env python
# 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>.
"""
Sensor synchronization example for CARLA
The communication model for the... |
5a84c14edb23d42a28478bdb4f1c6ced5e45d582a1a7bf0c03a9be767b5a7866 | Python | 5,159 | 148 | # 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... |
03f504fb0c038e1ccea9f71c7f17c54d86db54f37d5b37f7e303dab778e0efa5 | Python | 5,160 | 187 | #%%
import csv
import gzip
import os
import time
from pathlib import Path
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
from giskard.plot import set_theme, soft_axis_off
from matplotlib.collections import LineCollection
from src.data import load_maggot_graph, load_palette
from src.io import ... |
ad63a99db1d5d6bc08a16b5a7025ce17d2e1bb1f9c86aba276529abdaabc41db | Python | 5,161 | 165 | #! /usr/bin/env python
# Copyright 2016 Vimal Manohar
# Apache 2.0.
"""Prepare CSR-IV 1996 Language model text corpus (LDC98T31)."""
from __future__ import print_function
import argparse
import gzip
import logging
import os
import re
import subprocess
import sys
from bs4 import BeautifulSoup
sys.path.insert(0, ... |
b1089711b07e3ab17142c29b4adad6f7d0f08f849bd538f8c49cdc24b6a0cdf8 | Python | 5,162 | 130 | #!/usr/bin/env python
# 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>.
# Allows controlling a vehicle with a keyboard. For a simpler and more
# docu... |
3f731f59fe75360c80b6a31fe073062ba69ffe1da3ef7abf9687c7c4053aed14 | Python | 5,165 | 141 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
b136933a0d0ab6a6779990eea1e410b70c0da9f822178f47a854a8e1a4be466a | Python | 5,165 | 138 | # 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... |
aa0a82ff4136a913900b801c613ec436202b29ef7dd4f347d51f984954add04d | Python | 5,169 | 145 | #!/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
"""
... |
1258a6634b5fff30c23c6315245e33c364d3f28e2b774028f26cafc7bd8372f8 | Python | 5,173 | 135 | # generate atom features
from typing import Callable, List, Union
import numpy as np
from rdkit import Chem
from deepchem.utils.molecule_feature_utils import construct_hydrogen_bonding_info
from deepchem.utils.molecule_feature_utils import get_atom_hydrogen_bonding_one_hot
Atom = Chem.rdchem.Atom
AtomFeatu... |
32dd0fe7ad385d9163aea4402aea760410b151c4336a7422802f1e4da9ccea60 | Python | 5,173 | 132 | import argparse
from dateutil.relativedelta import relativedelta
import descarteslabs as dl
from tqdm import tqdm
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'),
'cpus': 1,
'maximum_concurrency': 200,... |
c0ccabe4fa4bd9109977b9c1870ab6d9edd6f11330bc00c58dde5e10e63a57a8 | Python | 5,174 | 146 | # 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>.
"""Smoke tests for the recorder/replayer compatibility fixes from PR #0j of
issue #9628 (port of ue4... |
e51f628c93a8700948abcc4b52bee2bffb9d3292607c614b8f285a55c98030bb | Python | 5,175 | 113 | # 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... |
e492bcc3111eec2da131cff04dc1df19e8e2270ccd6d5ec2c04c4ba9265f8be5 | Python | 5,178 | 205 | # %% [markdown]
# #
import os
import numpy as np
from sklearn.model_selection import ParameterGrid
from tqdm import tqdm
from graspy.plot import pairplot
from src.data import load_metagraph
from src.io import savecsv, savefig
from src.visualization import CLASS_COLOR_DICT
from topologic.embedding import node2vec_embe... |
182a7fa3750630bb488dd27e8a5b09adf681446a51948f386e72ecc049a1aab6 | Python | 5,179 | 170 | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config
# -- Path setup ------------------------------------------------------------... |
db2517bdfe9b618df49dcd61ec4570652e458899d1641331f4906a9be4810623 | Python | 5,181 | 141 | #coding:utf-8
import torch
import torchvision
import torch.nn as nn
from torch.autograd import Variable
import torchvision.models as models
import numpy as np
def print_model_parm_nums(model):
#model = models.alexnet()
total = sum([param.nelement() for param in model.parameters()])
print(' + Number of p... |
b095f0396695825fb4bc8ca2e5e91226f691dc92d18a12dd293f52aa349f4013 | Python | 5,182 | 135 | """Paper Figure 4: latent inhibition — the precision-weighted RPE signature.
Layout (1 x 3, with insets):
A — RPE control and pre-exposed curves overlap (structural no-LI)
B — Dual-DAN dramatic separation, tight variance across 20 seeds
C — lambda sweep dose-response: LI effect scales monotonically... |
65d9590c59155d9b248d13b0ae0cfcf100c082cd98b4ffad723a2cd43154fe6f | Python | 5,183 | 154 | """
File: plotter.py
Created: 2020/06/09
Last Changed: 2020/06/11
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 ... |
9766fd78706cf827f1fb1d0cebe0d7dd0de7ab3853002a65f3607db29571f15a | Python | 5,183 | 138 | """EfficientNet"""
import torch.nn as nn
from models.baselines.base_model.basic import _ConvBNHswish, MBConvBlock
__all__ = ['EfficientNet', 'get_efficientnet', 'efficientnet_b0', 'efficientnet_b1', 'efficientnet_b2',
'efficientnet_b3', 'efficientnet_b4', 'efficientnet_b5', 'efficientnet_b6', 'efficientnet... |
da0d1553d65aaa11d2be669ce70e96f30e24335303d6198848c01fbded088870 | Python | 5,183 | 163 | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset
import os, glob
import numpy as np
import pandas as pd
from skimage.transform import resize
import cv2
def normalize(image):
epsilon = 1e-6
image = (image - np.min(image)) / float(np.max(image) - np.min(image) + epsilon)
... |
fd261ef4116c8e2b9b2a198c4440526ea766aa672f31af3598f90456377b49e7 | Python | 5,186 | 126 | import logging
import re
import os
import numpy as np
from time import sleep
from subprocess import check_output
logger = logging.getLogger(__name__)
def _get_system_wide_set_gpus():
allowed_gpus = os.environ.get("CUDA_VISIBLE_DEVICES")
if allowed_gpus:
allowed_gpus = allowed_gpus.replace(" ", "").sp... |
824dc04158a15bca86ca7d039e71e38299141b2748dbd307c50638a43f48fbfc | Python | 5,189 | 125 | #!/usr/bin/env python
# Copyright 2014 Gaurav Kumar. Apache 2.0
from __future__ import print_function
import os
import sys
import subprocess
latticeLocation = {1:"/export/a04/gkumar/kaldi-trunk/egs/fishcall_es/j-1/latjosh-2/lattices-pushed/",
2:"/export/a04/gkumar/kaldi-trunk/egs/fishcall_es/j-2/latjosh-2/lattices... |
c3b7077afee5f3e39b00340c65be77b2e6c614f62ad93374340261d2d72a9045 | Python | 5,189 | 167 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import random
import numpy as np
import torch
import torchvision
from torchvision.transforms import functional as F
class Compose(object):
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, image, ta... |
93a964b2e8f79c1cacbd90cac8042f97c7c850c7b56ef0b988b04558a4808bd7 | Python | 5,193 | 114 | import os
import torch
"""
Code based on ZSSR provided by Assaf Shocher
https://github.com/assafshocher/ZSSR
"""
class Config:
# network meta params
python_path = '~/.conda/envs/pytorch/bin/python'
scale_factors = [[2.0, 2.0]] # list of pairs (vertical, horizontal) for gradual increments in resolution... |
f101d1ce4f6acf75b55401862222c3af8141b45fd9301b47538f853b2a7f079d | Python | 5,197 | 139 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 09:40:34 2021
@author: paulmueller
"""
import ast
import os
import numpy as np
import glob
import pandas as pd
def make_path(path):
"""Create directory at path (str) if it does not allready exists"""
try:
os.makedirs(path)
e... |
7169c48ac052e850fcbb061cf75407341dead3a499578250030519fe18367728 | Python | 5,200 | 137 | #!/usr/bin/env python3
"""
File: cellmap_genes_per_celltype.py
Created: 2020/04/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 Sof... |
b477de1f777d534cf5151484560289cfc4fd2fed1513e54086e06dc7729c3b26 | Python | 5,200 | 138 | import csv
import io
import os
import json
import zipfile
import pytest
from backend import root_tracking
def test_tracking_csv_header_matches_values_and_quotes_filenames():
stats = {
'sum_same': 11,
'sum_decay': 12,
'sum_growth': 13,
'sum_negative': 14,
'sum_exmask': 15,... |
97567b315410bc3546d525d51656aee11d78a7d63c0ae0062a7edfbae865700f | Python | 5,202 | 175 | """
Compute metrics
===============
Sample file to test metrics.
"""
if __name__ == '__main__':
# ------------------
# Libraries
# ------------------
# Generic libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Basic functions in sklearn
from ... |
79e050d018399a0f72ea04aa78e759d869d60ed1ee0a17ee06018599042d88b5 | Python | 5,203 | 184 | import os
import torch
from torch.autograd import Function
from torch.utils.cpp_extension import load
module_path = os.path.dirname(__file__)
upfirdn2d_op = load(
'upfirdn2d',
sources=[
os.path.join(module_path, 'upfirdn2d.cpp'),
os.path.join(module_path, 'upfirdn2d_kernel.cu'),
],
)
cla... |
7302bd2e4e4e6e05379d7d49bc658eac512a16ff99b46ee756da363fdd5e2778 | Python | 5,209 | 181 |
def find_first_neg(input_list):
result = 0
for i in input_list:
if i < 0:
result = i
break
return result
def alg_1(order_list, queue_len):
start = 0
end = queue_len
result_list = []
while end <= len(order_list):
new_list = order_list[start : end]
... |
140089a1f3230964b91b23c021c22069c97c9247f47a84a21d81d3f79db9d314 | Python | 5,212 | 169 | ### SAFT Utility Functions
### Andrew Plested 2020-11-14
import sys
import os.path
import string
import random
import pandas as pd
import numpy as np
import pyqtgraph as pg
from PySide2 import QtGui
class txOutput():
"""Console frame"""
def __init__(self, initialText, *args, **kwargs):
sel... |
f2f9cd0ca74f00727157d22a31767693fac756f3e2d13773a24cc9884c7dec15 | Python | 5,218 | 127 | import os
from datetime import datetime
import mesh.convert
import FBEM.config as cfg
from mesh import triangulate_system
from FBEM.various import prepare_csv_line
def write_input_to_file(filename, tria_generator, *tria_generator_args, description='',
external_flow_field=None):
"""
... |
c9819e5d948897b4303d29657e68159bd2b58a6d99a3bce63d7e3bb3bfdc59bd | Python | 5,224 | 141 | import os
import os.path as op
import numpy as np
import nibabel as nib
from dipy.reconst import csdeconv as csd
from dipy.reconst import mcsd
from dipy.reconst import shm
from dipy.core.gradients import gradient_table, unique_bvals_magnitude
import AFQ.utils.models as ut
# Monkey patch fixed spherical harmonics fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.