sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d6f3645712260c00f24e65f54fe4263f899a951d4668313c2853fd4618aad3ba | Python | 3,361 | 65 | """Neural Bypass configuration: capture/steering layer pairs sharing one reservoir.
A configuration is a list of rows ``[capture, steer, enabled]``. The active set is the sorted
set of unique enabled pairs, so row order and duplicate rows never change what is executed.
- One active pair runs the legacy single-bypass ... |
e3029c7c7c8a977d13a45d0e3e8f5101c5277c63eb1919f398e4d37611706bfc | Python | 3,361 | 102 | # 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... |
7f0c07c32e2799a01efb00779fb98613f36c75ab352428e6d0fc166cb520d210 | Python | 3,362 | 89 | """Random-weight tiny transformer tests validate hooks, not scientific outcomes."""
import numpy as np
import pytest
import torch
from scipy import sparse
from transformers import Qwen3Config, Qwen3ForCausalLM
from liquidaion_fly.llm import Coupling, compare_logits
from liquidaion_fly.reservoir import Reservoir
@pyte... |
98190a23046a7fedf12f51cd486cd0f334162386f318b6a97805d9e1d0952b85 | Python | 3,362 | 132 | import pytest
import torch
@pytest.fixture
def inputs():
"""Create sample input tensor for testing."""
return torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
@pytest.fixture
def relu_layer(tmp_path):
"""Create a ReLU layer for testing."""
from elasticai.creator.nn.integer.relu.relu import ReLU
... |
a5542fc46f7a3135d54b786dff955ab8c1b9cfd39944a089c46351e740399d2e | Python | 3,362 | 106 | import os
from torch.utils import data as torch_data
from torchdrug import data, utils
from torchdrug.core import Registry as R
@R.register("datasets.FB15k")
class FB15k(data.KnowledgeGraphDataset):
"""
Subset of Freebase knowledge base for knowledge graph reasoning.
Statistics:
- #Entity: 14,9... |
e0cdb500afadca3c023243e5be0ad9e3ddc22389c4e778539b4c9d15955fe72d | Python | 3,363 | 92 | #!/home/dingml/anaconda3/envs/expressBert39/bin/python3
from tqdm import tqdm
import argparse
import os
import sys
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset, Subset
from biodml import set_rand_seed
from train_utils import model_summary, make_logger, make_directory, get_run_info
f... |
50dc37d6d551d19ad7c92c96c6116183a9b20b9fd13d1a605c12dc9a16f035c9 | Python | 3,364 | 99 | """
=================
Run RANSAC
=================
In this example we show how to run the RANSAC of ``pyprep``.
.. currentmodule:: pyprep
""" # noqa: D205 D400
# Authors: Yorguin Mantilla <yjmantilla@gmail.com>
#
# License: MIT
# Based On: use_noisy_module.py
######################################################... |
67174f963aa896fe4ec2802aee4ca45c8aac6f2d74a74eb6770904d1670aaf5a | Python | 3,364 | 109 | #!/usr/bin/env python3
"""Inspect SEA-AD donor metadata and CPS files.
This script only summarizes downloaded public metadata. It does not inspect or
analyze expression results.
"""
from pathlib import Path
import pandas as pd
ROOT = Path(__file__).resolve().parents[1]
RAW = ROOT / "data" / "raw"
PROCESSED = ROOT ... |
52587508fbbb47ad759e6bbbb62a7db902965aee971cb75980496cfe148d587b | Python | 3,365 | 91 | import warnings
from typing import Protocol
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.vhdl.design.design import Design
from elasticai.creator.vhdl.system_integrations.env5_constraints.env5_constraints import (
ENV5Constraints,
)
from elasticai.creator.vhdl.system_integration... |
e9c8dc00df1e38ddbd9ea76db3f8a608069380fd4e21a167bda38d647fb39a00 | Python | 3,365 | 79 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute neighborhood complexity of Drosophila connectome and controls
Note: This script generates some duplicated data. I have decided to keep it, because the files are small and potentially useful
in case the... |
7d100f85137a816f56ba76f4284e8f406b4f6a966c6a07307e7b5ed35b51aeb3 | Python | 3,366 | 81 | """Tests that the JSON schema loader rejects JSON that is not a HED schema (issue #1464)."""
import json
import os
import shutil
import tempfile
import unittest
from hed.errors.exceptions import HedExceptions, HedFileError
from hed.schema import load_schema, load_schema_version
from hed.schema.schema_io.json2schema i... |
513dd0d4cbe1762bb4f8caf1582d18c8412a855505a69d5e82d5b95b08ee3ba3 | Python | 3,367 | 99 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
74d3e590247c505913abc32b169fc2bf4fcef8c268abe56faecf19433fb24aef | Python | 3,367 | 99 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
c8dc0bfb8778b779f1e10697eb9eaf93934adb25182b07ecc0d53374e9a8152d | Python | 3,368 | 81 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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
#
# ht... |
98fdd973dbbbaa7579d5e3979d25a5b4c3f5adb686b8ad4fec03a561ae86191b | Python | 3,369 | 97 | """
Bonito Export
"""
import os
import re
import sys
import json
import torch
import bonito
import hashlib
import numpy as np
from glob import glob
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
class JsonEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer... |
8d519b7a0f73b00e7070fc0deeb5abaad4e5068c28103c66cf6fc19e1fc22650 | Python | 3,370 | 111 | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
package_path = os.path.abspath("../src")
# Suppress superfluous frozen modules warning.
os.e... |
4bb4dbd7d339c47c1276ad077182ef31a00c87bcc7a927c0a9956b638457d07e | Python | 3,373 | 105 | from abc import ABCMeta, abstractmethod
from pathlib import Path
from typing import Self
import bpy
from ... import blender as bl
from ..base import EntityType, MolecularEntity
class Ensemble(MolecularEntity, metaclass=ABCMeta):
def __init__(self, file_path: str | Path):
"""
Initialize an Ensemble... |
9cc7470cfa45fa314f964bc67e16fa56c5deaba81ef06202724218b627091098 | Python | 3,374 | 90 | import math
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.file_generation.template import (
InProjectTemplate,
module_to_package,
)
from elasticai.creator.vhdl.code_generation.addressable import calculate_address_width
from elasticai.creator.vhdl.code_generation.code_abstrac... |
ea5cb9a1d29faabcad293f7fed4ae51a49479dfd4348adabf42e9c48ce2c6b6f | Python | 3,374 | 112 | from .core import encode, decode, alabel, ulabel, IDNAError
import codecs
import re
from typing import Tuple, Optional
_unicode_dots_re = re.compile('[\u002e\u3002\uff0e\uff61]')
class Codec(codecs.Codec):
def encode(self, data: str, errors: str = 'strict') -> Tuple[bytes, int]:
if errors != 'strict':
... |
99125e6e48bd1221d12018889b60cb63f44a2c772ed1035349248a47315fd524 | Python | 3,375 | 140 |
"""
Author: Anup Kumar
"""
import toml
import glob
import jobflow as jf
from ase import Atoms
from ase.io import read
from fireworks import LaunchPad
from jobflow.managers.fireworks import flow_to_workflow
from quacc.recipes.newtonnet.ts import ts_job
from quacc.recipes.newtonnet.ts import irc_job
from atomate.common... |
842d16a02afe0924fb069c58d919582a045b1afcb0919a54b203a04ef2a15182 | Python | 3,376 | 83 | # Node-group asset "Charge" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING
from b... |
cb82eb615284949d24696104fc6a338ded31bca970655f3c336a214185f9a383 | Python | 3,376 | 80 | ############################################################################################
# Plot the 1000 evoked CCA components for task evoked versus resting state data
#############################################################################################
import numpy as np
import pandas as pd
import matplo... |
afc3c3f42e1199a62f413c4a9ef35972e62d2c227f7fb49cd352d2a1f2c10b6f | Python | 3,377 | 103 | from __future__ import absolute_import, print_function, division
import numpy as np
from scipy.optimize import linear_sum_assignment
from typing import Tuple
def match_coordinates(targets:np.ndarray, preds:np.ndarray, radius:float) -> Tuple[np.ndarray, np.ndarray]:
d2 = np.sum((preds[:,np.newaxis] - targets[np.n... |
b3348fe9c701b1888748853d72718729a983398c8e4fc9fb0cdaaf9f1df5cf87 | Python | 3,377 | 123 | #!/home/jones/miniconda3/bin/python
import sys
import os
# Uncomment if running on TPU
os.environ["XRT_TPU_CONFIG"] = "localservice;0;localhost:51011"
import time
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import Dataset, D... |
c0bfd2ba21a216c53171761266676aebcc4c133af1807d6dbb36e502eba82787 | Python | 3,378 | 94 | ### Auxiliary Functions: Feature Extraction ---------------------------------------------------------
from .feature_extraction import *
def chunk_list(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
def get_image_transforms():
from torchvision import transforms
imagenet_stats = {'mean... |
f12740e7f9eb3741914e8f965c8c0f63d8b4dca917385be75697eb6c46185738 | Python | 3,378 | 109 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Docs here"""
__author__ = "Mitchell R. Vollger"
__credits__ = ["Mitchell R. Vollger"]
__maintainer__ = "Mitchell R. Vollger"
__email__ = "mrvollger@gmail.com"
__status__ = "Development"
import logging
import argparse
import pysam
import sys
import pa... |
7cb292e6189df92a9d4c81c58abee46eb9fa5ee1da03fdefaaf7f7026d53da42 | Python | 3,379 | 94 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import suites
from lab.reports import Attribute, gm
from common_setup import IssueConfig, IssueExperiment
try:
from relativescatter import RelativeScatterPlotReport
matplotlib = True
except ImportError:
print 'matplotlib not availabe, scatter plots ... |
c1d524c2b0bf80dd15fdec278d670f81941a14aa39be5912f2ede6de362eac2b | Python | 3,380 | 79 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute neighborhood complexity of Celegans connectome and controls
Note: This script generates some duplicated data. I have decided to keep it, because the files are small and potentially useful
in case the r... |
4d43ea722cb0b5cb7afd423b00372fe91093b2a77572b4157637776b6ba8ffd7 | Python | 3,381 | 117 | # 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 in writing, software
# distributed under th... |
1a0261348109449495d1fccd0cd35ad26320218d07270ac3b82ca74d9062b598 | Python | 3,383 | 124 | """
Django settings for PeerJCode project.
Generated by 'django-admin startproject' using Django 4.1.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
... |
7b8bfecd2b71927319f07c8fbc097893107cfe29614265b402cced5e885a4113 | Python | 3,383 | 111 | from common import *
from itertools import izip
def tajD(N,S,k):
'''N is the number of indv
S is the number of seg. sites
k is the (ave number of pairwise nuc. diffs), e.g. total number of pairwise diffs divided by choose(N,2)
so:
i1 AT|T|GGCG|A|CAG|T
i2 AT|G|GGCG|C|CAG|A
... |
896a2380220aa5b6bdc4243b7e5b7edabdd3b1717ad966f420f7afef459f0012 | Python | 3,383 | 128 |
# coding: utf-8
# In[158]:
import nest
import numpy as np
import sys
import os
nest.ResetKernel()
# In[159]:
unique_ID = sys.argv[1]
params_file = 'params' + unique_ID + '.param'
params = np.genfromtxt(params_file)
gL_Bas = params[0]*1000 #5.0e-3 #7.14293e-3
tauMem_Bas = params[1] #14.0
Cm_Bas = t... |
aa65bda29408d65f5d58ed86fd409f55e545d85086d7aa40d62cd1371db5e1be | Python | 3,383 | 104 | """Cancel terminates the REAL run process, not just the launcher (issue #119).
The registration run executes in a detached terminal, so the QProcess launcher
the GUI holds has already exited. The pipeline records its PID to ``<lock>.pid``;
_TerminalJobMixin.cancel_job() must read that and kill the tree. These test... |
19e9a40b524a61732599e7fd08e32ad5d1de6d3522dd41aad773251bb0f04b9f | Python | 3,384 | 93 | # By Shuran Liu, 2023
import random
import numpy as np
from torch.utils.data import Dataset
import h5py
import cv2
class TrainDataset(Dataset):
def __init__(self, h5_file, patch_size, scale):
super(TrainDataset, self).__init__()
self.h5_file = h5_file
self.patch_size = patch_size
s... |
0208d79e227726c513aadd57f704b825a31246f3e89a2e8dfa5f1097d5f6a541 | Python | 3,385 | 120 | '''
ResNet block implementation from torchvision.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
[2] https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py
'''
from typing import Callable, Optional
from torch i... |
08c85c021487e1422baf1140e11e876be073b37e7e3df50cae1b21f585f7c443 | Python | 3,385 | 116 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 16:11:11 2020
@author: au571303
"""
from random import shuffle
from psychopy import prefs
prefs.hardware['audioLib'] = ['PTB']
#prefs.hardware['audioLib'] = ['pyo']
from psychopy import visual, core, sound, event, gui, logging
import os
import numpy as np
#from trigger... |
65138ce312da6c4d2d9a40a23449ea55406c922732fbaef2c81fdc107caec0e3 | Python | 3,385 | 130 | # -*- coding: utf-8 -*-
"""
Created on Thu May 17 12:17:20 2018
@author: Francois
"""
#Tuning the parameters:
#Integrator max(resp .min): max nb of steps the motor can make in DeltaT
from control._def import *
class PID:
def __init__(self, P=PID_parameters.P_DEFAULT, I=0, D=PID_parameters.D_DEF... |
46fffcb42eb367d0dd0a29d781531b33ec2315afb5ab0bde7d7555c9cefb5c44 | Python | 3,387 | 105 | import pytest
import numpy as np
from sella.utilities.math import pseudo_inverse, modified_gram_schmidt
@pytest.mark.parametrize("n,m,eps",
[(3, 3, 1e-10),
(3, 5, 1e-10),
(100, 3, 1e-6),
])
def test_mppi(n, m, eps):... |
f01380de46c672257c268aa032b43e651021f38c92c805e6f399e9648785adf7 | Python | 3,387 | 132 |
# coding: utf-8
# In[158]:
import nest
import numpy as np
import sys
import os
nest.ResetKernel()
# In[159]:
unique_ID = sys.argv[1]
params_file = 'params' + unique_ID + '.param'
params = np.genfromtxt(params_file)
gL_Bas = params[0]*1000 #5.0e-3 #7.14293e-3
tauMem_Bas = params[1] #14.0
Cm_Bas = ... |
a26dad67645c6217ee79f5dd7779c6d89da85beaafa75392c62faf55c2892caa | Python | 3,388 | 103 | import argparse
from nilearn.image import load_img
from nilearn.masking import apply_mask
from os.path import join as pjoin
import numpy as np
from tqdm import tqdm
from dimension_encoding.TopObjects import TopObjectsProfile
from dimension_encoding.utils import get_all_roi_files, load_clip66_preds
def load_pmod_betas... |
9e0929e5b1e40128a92796321026d818e3c20c6be70ae7906d405847d37731dc | Python | 3,389 | 99 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
dd614059b08e75cb67a8ef6e70619eb4599b58408e48d3b42e6295aeed512908 | Python | 3,389 | 107 | # Node group ".Backbone Position" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and accessors are regen... |
4809a05bb842487fbf74d14f54366a0eb0f0fd7d89628fc9367425e0e2e7acc2 | Python | 3,390 | 113 | import time
import torch
def _train_or_test(model, dataloader, optimizer=None,
coefs=None, log=print):
'''
model: the multi-gpu model
dataloader:
optimizer: if None, will be test evaluation
'''
is_train = optimizer is not None
start = time.time()
n_examples = 0
n... |
5c41f476f7ac9ad5ff2b4f341deb85e718d8fbd32f0616b01eaacbf7dcca3f80 | Python | 3,390 | 96 | """
Optuna example that optimizes a classifier configuration for cancer dataset using XGBoost.
In this example, we optimize the accuracy of cancer detection using the XGBoost. The accuracy is
estimated by cross-validation. We optimize both the choice of booster model and its
hyperparameters.
"""
import os
import shu... |
ce76ffb6f4fddcb06366f98205043259eef44fbd99446fcf2576fcf331297368 | Python | 3,390 | 146 | import pytest
import torch
from elasticai.creator.arithmetic import FxpParams
from elasticai.creator.nn import fixed_point as nn_creator
@pytest.mark.parametrize(
"total_bits, frac_bits, num_steps",
[
(4, 3, 4),
(6, 4, 32),
(8, 5, 64),
(10, 6, 16),
(12, 7, 128),
... |
1a04584b30e4d500257b2a0889fa9f7861d44897765b83902f42b1579292fbaf | Python | 3,391 | 78 | import argparse
from matplotlib import pyplot as plt
import pytorch_lightning as L
import seaborn as sns
import sys
from statsmodels.stats.descriptivestats import sign_test
# local imports
sys.path.append("..")
from shapelearningtheory.datasets import make_dataset
from helpers import format_table, train_and_validate, u... |
4e7f9a282c78cf0345f20ae2ec516099b0cfd2ffd21ff471890bf735d54f1d84 | Python | 3,391 | 105 | import cocotb
import pytest
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge, Timer
from elasticai.creator.arithmetic import int_arithmetic
from elasticai.creator.testing import CocotbTestFixture, eai_testbench
from elasticai.creator_plugins.multipliers.utils import (
generate_mult_testdata,
... |
bb712f89986cc29ab3a915d140a73d20afcbc6df468de6f0225b25ec2d854d87 | Python | 3,391 | 110 | # Node-group asset "Boolean AndOr" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING... |
4093a51397856c4a33555d34ba75d5932384e755e480a8a4bebf0012305a2dd8 | Python | 3,393 | 104 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Modified version of code from https://github.com/tkipf/keras-gcn
Written by Tong He and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
"""
from __future__ import print_function
from keras import activations, initializers
from kera... |
6f8a3ac755225a6b6c218424ea36de696997e50e867e65d7970aec03b1e107ae | Python | 3,393 | 63 | """
Minor modifications to `../assemblyfire/find_assemblies.py` to be able to run on spike traces
extracted from the co-registered MICrONS dataset (see `query_functional_data.py` for fetching that data)
last modified: András Ecker 09.2023
"""
import os
from collections import namedtuple
import numpy as np
from assemb... |
7bb8fe1fec2fdbf53436e991cd5dda4a68fb7a9ace651acbb05e9b4e77f77945 | Python | 3,393 | 114 | # Node-group asset "Vector Angle" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING
... |
4a49c07cd0c64e3d8c0665295fcc4e3e5687894084ebea8853825f5c2f65b502 | Python | 3,396 | 107 | # Node group "Index Mixed" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated ... |
60b06eb4113b77383bd2206bf929c09c8d6b823b5afcddd1b906b6539795eca8 | Python | 3,396 | 84 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
from lab.environments import LocalEnvironment, MaiaEnvironment
from lab.reports import Attribute, geometric_mean
from downward.reports.compare import ComparativeReport
from common_setup import ... |
7e733d3a42a21e2180a6737f3a27ab906de8df61319599df14f45a84ec7824d1 | Python | 3,396 | 90 | from torch import nn
from torch.nn import functional as F
from torchdrug import core
from torchdrug.layers import functional
from torchdrug.core import Registry as R
@R.register("models.ProteinLSTM")
class ProteinLSTM(nn.Module, core.Configurable):
"""
Protein LSTM proposed in `Evaluating Protein Transfer Le... |
9e58b8d88c549fd1ebae324808e5e0def285983ce3a8d2df8652c2288c5209df | Python | 3,396 | 110 | #--------------- Libraries -------------------
import numpy as np
import pandas as pd
import celltypist
import anndata as ad
import sys
import scanpy as sc
import pickle
import os
import random
### Set seed
random.seed(123456)
#--------------- Parameters -------------------
sample_path = str(sys.argv[1])
model_path... |
62c858f0a9ecb7800c7219be58686b29aee5210364aa9b73736d5ece807bf20f | Python | 3,397 | 42 | #--------------------------------------------------------------------------------------------------------------------------------------------------------
# Author: Brandon S Coventry
# Date: 12/8/20
# Purpose: This is the main function for running reinformcement learning on computational Basal-Ganglia Thalamocortical m... |
94c2065693e5aee9f7e6d700be9eebd63d4044fd6287646190f27ed5d59febea | Python | 3,397 | 111 | import ecdsa
import numpy as np
import ssl
import asyncio
import websockets
import time
import random
from hashlib import sha256
from request import Request
from tvm_cifar10 import TvmDeployment, VGG16
from utils import cifar_test, cifar_train, get_dataset, cifar_test_loader, cifar_train_loader, attack_dataset
from mul... |
c091f31aab62e1535c5d812865b7bed993cd3dec741892505e5d9082863bca18 | Python | 3,398 | 119 | """Core recipes for Onetep."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ase.optimize import LBFGS
from quacc import job
from quacc.recipes.onetep._base import run_and_summarize, run_and_summarize_opt
from quacc.utils.dicts import recursive_dict_merge
if TYPE_CHECKING:
from typin... |
9eb791b2bbb7ad0faa87c27176f1d776c34745ff0c2bf3c120c5a2ed40122893 | Python | 3,399 | 100 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 14:39:43 2020
@author: asong
"""
from torchvision import transforms
from layers.DiffractiveLayer import Diffractive
from utils.layer_utils import layer_type
def update_layer(layer_config,config_dict):
layer = layer_type(layer_config["layerType"])
... |
8f46d582d9edddacb080649ce65254735a105434185094231fa105d84e2d4936 | Python | 3,400 | 94 | #!/usr/bin/env python3
# so no GDK warning issues when running on fritos.
import matplotlib
matplotlib.use('Agg')
from matplotlib import pylab as plt
from matplotlib import rcParams
import seaborn as sns
# v3: 2023-08-13
# -- now parsing the efficiency-fairness table.
#
# Set plotting style.
plt.style.use('... |
d5cb44d36eb2d9cff5fe9a3553be3060457dc0239b332b7f17537f9d7e2d500e | Python | 3,400 | 80 | """
This script provides an example of how a pre-trained ilastik
PixelClassification project can be used to generate predictions
from within Python, without the need to read/write data from disk.
Once the project is loaded, this script doesn't touch the hard-disk.
"""
from __future__ import print_function
from colle... |
0f78d294603d8fb303064fe5d7eadfc85d2d66b0916caadc1e40032ecccd854e | Python | 3,402 | 106 | #!/usr/bin/env python3
import sys
import os
import shutil
import subprocess
from pathlib import Path
# prints out an error and exits with code 1
def exitWithError(msg):
print(f"Error: {msg}")
sys.exit(1)
# runs an external command
def run(cmd, check=True):
print(f"> {cmd}")
result = subprocess.run(cmd... |
ee38ed21c6be24a33115627e138b847b5d3c2954927c72295d2dcb3c113a8970 | Python | 3,402 | 80 | """End-to-end test of the CLI output-finalization helper (no cellpose model)."""
import json
import pandas as pd
from regtools.cellpose_sam.__main__ import _finalize_outputs
from regtools.cellpose_sam.report import build_html_report
def test_finalize_writes_summary_and_histograms(tmp_path):
combined =... |
4ac6490aef961870ee34ecd360f23ea11fdf5e11d03ce39e2c47b63eeaec4efe | Python | 3,404 | 107 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from torch.optim import Adam
from collections import deque, namedtuple
import copy
from .initi_update import soft_update, hard_update, weights_init_
LOG_SIG_MAX = 2
LOG_SIG_MIN = -2... |
47b136d6aecb9da32ba751328ef1af3c4bdf735c7b42da58228db3fc35386c2f | Python | 3,405 | 85 | import pandas as pd
import json
import main_config as conf
# detectors where a .5 detection threshold is sufficient
HALVER_DETECTORS = ['ReRe', 'rere', 'Alter-ReRe', 'alter-rere', 'AREP', 'arep',
'AnDePeD', 'andeped', 'ANDEPED', 'AnDePeDPro', 'andepedpro', 'ANDEPEDPRO']
def read_anomaly_detectio... |
742a0c65097153856aa7e7315e0371ea5ff4002dcdff5a9a962d82c1ed6ff208 | Python | 3,406 | 79 | import matplotlib
matplotlib.use("Agg")
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
import yaml, io
with open("./config/MNIST_config.yaml", 'r') as stream:
config= yaml.safe_load(stream)
config["default_path"]= str(config["default_path"])
config["cuda"]= str(config["cud... |
02b456ddc0f9cbd5ae9e878c52ea435d6c9ca36fb292f2960df52cf6b2f4492e | Python | 3,407 | 90 | import functools
import keras_applications as ka
from .models import resnet as rn
from .models import resnext as rx
from .models import senet as sn
class ModelsFactory:
_models = {
# ResNets
'resnet18': [rn.ResNet18, rn.preprocess_input],
'resnet34': [rn.ResNet34, rn.preprocess_input],
... |
30e6cfefa88c8969946fce61ffdf862b2448508130e5b4bd36adaee70eb1e942 | Python | 3,407 | 77 | ### TCGA
import openslide as slide
from PIL import Image
import numpy as np
from skimage import data, io, transform
from skimage.color import rgb2gray, rgb2hsv
from skimage.util import img_as_ubyte, view_as_windows
from skimage import img_as_ubyte
from os import listdir, mkdir, path, makedirs
from os.path import join
... |
37bbeff1f3327f795ff8dedfb4fb74f9dde8e031e79995489b095869c9e2869c | Python | 3,407 | 81 |
import pandas as pd
# Read the file
file_path = 'ATH_Results-Localizer.txt' # Replace with your actual file path
df = pd.read_csv(file_path, sep='\t', comment='#', usecols=[0, 1, 2], on_bad_lines='skip')
Predicted_DTP = df[df['Chloroplast '].str.contains('Y', na=False) & df['Mitochondria '].str.contains('... |
f423391ba98b24d1619dda8fc40d119e54c122d002cea134ac51ac6e3c59e15e | Python | 3,407 | 124 | """Various utility functions."""
import numpy as np
import scipy.sparse as sp
import torch
from typing import Union
import networkx as nx
import random
# from sklearn.preprocessing import normalize, StandardScaler
from collections import Counter
import pandas as pd
from scipy.stats import norm
import pickle
def load_... |
b3e50350970d8e4c076059c0dba07b8075559f4de52ecd79063ce43b2487fb32 | Python | 3,408 | 89 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: A.Akdogan
"""
import os
import cv2
from pathlib import Path
class ImageConverter:
def __init__(self, row, col):
self.row = row
self.col = col
@staticmethod
def get_final_path(sub_count, join_list):
path = os.path.... |
e1af2805d5b49a8c6c6547c56ee45d3a7df3ed90145c08b2ca7b1d96126a749a | Python | 3,409 | 104 | """
@Mariellapanag
Created on March 2023
@author: mariella
Code for computing abnormality data as well as band power
"""
# external modules
import numpy as np
import os
import pandas as pd
# internal modules
import proj_funcs.generic_funcs as generic_funcs
import proj_funcs.atlas_chan_rois_funcs as atlas_chan_rois... |
95efc983b428a5ec31b70257038d3efb552f8f5a596baf7ffba8286a199827c3 | Python | 3,410 | 124 | """Various utility functions."""
import numpy as np
import scipy.sparse as sp
import torch
from typing import Union
import networkx as nx
import random
# from sklearn.preprocessing import normalize, StandardScaler
from collections import Counter
import pandas as pd
from scipy.stats import norm
import pickle
def load_... |
9f7bcc64a0514abf25b93ffca71c29e5f291757d45dc87ebfffe99a8b8fa48f4 | Python | 3,410 | 139 | from elasticai.creator import graph as gr
from elasticai.creator.graph import produces_dangling_edge
def build_graph(adjacency_list):
g = gr.BaseGraph()
for src in adjacency_list:
for dst in adjacency_list[src]:
g.add_edge(src, dst)
return g
def test_catch_dangling_edge_d_b():
g ... |
a6ec267f66a9819472a2212679c0f85bf08e996c0c948ab7d430934edfbbd13c | Python | 3,410 | 117 | # Node-group asset "Mesh Contours" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKING... |
cf73887a6fc7cc3c1303e7a4ddd4cc77cbf3fe90d63b6697f93e8ca430fe22b0 | Python | 3,410 | 134 | # Node-group asset "Periodic Image" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHECKIN... |
1d7f713fbf395210af13215a37a4f19af45c952616658c06f871cca9aa48c694 | Python | 3,411 | 101 | """
Cog SDK Input definition.
This module provides the Input() function and FieldInfo class for defining
predictor input parameters with constraints and metadata.
"""
from dataclasses import dataclass
from typing import Any, Callable, List, Optional, Union
@dataclass(frozen=True)
class FieldInfo:
"""
Intern... |
235677836a886692d526b715a02cdbdbca0fc5e509d13d9588bb276f94836131 | Python | 3,411 | 159 |
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Bin Xiao (Bin.Xiao@microsoft.com)
# ------------------------------------------------------------------------------
from __future__ import absolute_import
from __fut... |
84e702d57dc0afd2a2fac8d88c3030cad4f63a5aa91cb8b2e871558e5f0a0de7 | Python | 3,411 | 91 | #! /usr/bin/env python3
import os
import subprocess
import logging
import APT_interface
class cd :
"""Context manager for changing the current working directory, and automagically changing back when done"""
def __init__(self, path):
self.path = path
def __enter__(self):
self.old_path = ... |
d1e2f39e9bee2737f25341d5b651b79a61691a42fec7cdb4f50db9f589df573e | Python | 3,411 | 105 | import numpy as np
from utils import stats, pickle_dump
from joblib import Parallel, delayed
from joblib.externals.loky import set_loky_pickler
set_loky_pickler('pickle')
import os
os.environ['OPENBLAS_NUM_THREADS'] = "1"
os.environ['MKL_NUM_THREADS'] = "1"
NNULLS = 10000
conns = {}
for res in ['125', '500']:
... |
4f87b10d01d3b5e90b6233fa34f4ef2d84898baff24457877f452b0c367382a8 | Python | 3,413 | 104 | """Prepare Cityscapes dataset"""
import click
import os
import shutil
import mmcv
import zipfile
from pathlib import Path
from segm.utils.download import download
USERNAME = None
PASSWORD = None
def download_cityscapes(path, username, password, overwrite=False):
_CITY_DOWNLOAD_URLS = [
("gtFine_trainval... |
b0bb5149f424523bc2ec70497dbf59697acf28f8110809c8bd0d1daf3a9c0d68 | Python | 3,413 | 96 | import torch
from torch_geometric.data import InMemoryDataset, Data
from torch_geometric.utils import dense_to_sparse
import numpy as np
import pandas as pd
import os
import pickle as pkl
class SpiderDataset(InMemoryDataset):
def __init__(self, root, raw_data_root,transform=None, pre_transform=None, force_reload=... |
c3b9a0ab579a307d79f20bc2b2143c58ab5773df3df1a46de6267596f3189ea4 | Python | 3,413 | 69 | #################################################################################################
# Generate plots to identify bad channels to mark for removal
#################################################################################################
import os
import mne
import numpy as np
import pandas as pd
i... |
43aba3f4e530ab38875627472a4182cc867340029115828f952ed4f8de1fbd23 | Python | 3,414 | 115 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
457fde1d4d7d61ee384eabcf48ba577e440082af2df932fc821307bac21c6b53 | Python | 3,414 | 123 | from typing import final, override
import pytest
import torch
from torch import Tensor
from torch.nn import (
BatchNorm2d,
Conv1d,
Conv2d,
Flatten,
Linear,
Module,
ReLU,
Sequential,
)
from elasticai.creator import ir, torch2ir
from elasticai.creator.experimental.ir.shape_inference impo... |
a8fd4f730579eb68a41d25b2485a6d76574e0df34411ae497b4be8cd34ebfed5 | Python | 3,414 | 98 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
b8e01f3be8e3bb8cdd870cad8f8527eaa4552ed68e90a7890056ff7975778876 | Python | 3,414 | 97 | """"""
"""
Prosper_nn provides implementations for specialized time series forecasting
neural networks and related utility functions.
Copyright (C) 2022 Nico Beck, Julia Schemm, Henning Frechen, Jacob Fidorra,
Denni Schmidt, Sai Kiran Srivatsav Gollapalli
This file is part of Propser_nn.
Propser_nn is free softw... |
f69aa1c86c36ab61c61865c03a96db7b38f4db8680affe3bc437d7cf915ab3b5 | Python | 3,414 | 96 | """distutils.dep_util
Utility functions for simple, timestamp-based dependency of files
and groups of files; also, function based entirely on such
timestamp dependency analysis."""
import os
from .errors import DistutilsFileError
def newer(source, target):
"""Return true if 'source' exists and is more recently ... |
b57e72f50f5014674dc1890fc6e5d55eef084396d6be45f5c5138adade61e0b2 | Python | 3,415 | 111 | import warnings
import os
warnings.filterwarnings("ignore")
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
# Here you can choose which GPU to use
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
import tensorflow as tf
import cryovesnet
# from keras import backend as K
# K.set_image_data_format('channels_last')
# import unetmic.u... |
f9e59c65eaa027e62b71d7f61fa300bc47ea4d03d7abf25f5bf429ec3d0fb80b | Python | 3,416 | 71 | from absl import app
from absl import flags
import os
import scripts.trainer as trainer
import torch
import random
FLAGS = flags.FLAGS
# Define Flagg names for inputs.
flags.DEFINE_string('z', 'example_data/Simulation_data0.z', 'Location of Z Score')
flags.DEFINE_string('target', 'results', 'Location to store results... |
4644129dc80c3172cb8eb07480a0dc814ff358afe7730f2b96663b3ed69c9c91 | Python | 3,418 | 91 | """MultiLineButton title/status eliding: the TITLE (a fixed label) shows in full
whenever the row can hold it; only the variable status is elided when space is
tight. Regression for "Select Input Points Files (Optional)" eliding with room.
Widths are derived from the widget's own fontMetrics so the test is
platfo... |
4cf9940577d72635cc2d1ae0bbd2fc8bcb2c73f8f8d852b743be818e38d75be3 | Python | 3,418 | 91 | #! /usr/bin/env python3
import os
import subprocess
import logging
import APT_interface
class cd :
"""Context manager for changing the current working directory, and automagically changing back when done"""
def __init__(self, path):
self.path = path
def __enter__(self):
self.old_path = ... |
aa83f4aa883dca1ac9bfa602480dfc251507c69529b430254ff8f11e68a0d12d | Python | 3,418 | 95 | import os
import pandas as pd
########################################
### PROCESS AND COMBINE TABLES ###
########################################
### Read tables/ directory ###
dir_contents = os.scandir(path='tables')
# FreeSurfer Dataframes, AMR and non-AMR
amr_dataframes = []
nonamr_dataframes = []
# He... |
c889e94bc9d97a197fb2d3d35613df36ad54139ee7b75d41d1f431cfd4cfeab5 | Python | 3,419 | 142 | from collections import defaultdict
import pandas as pd
import torch
import dgl
from torch.nn import functional as F
from rdkit import Chem
from tdc.single_pred import ADME
from tdc.single_pred import HTS
from tdc.single_pred import Tox
ATOM_VOCAB = [
'C', 'N', 'O', 'S', 'F',
'H', 'Si', 'P', 'Cl', 'Br',
'Li', ... |
d9b8c232254baf259c255b2f8f11f64887a27714552c732ccec40999737d4832 | Python | 3,419 | 106 | #
# MIT License
#
# Copyright (c) 2024 GT4SD team
#
# 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 without restriction, including without limitation the rights
# to use, copy, modify, merge,... |
dbd25dc436bf5e07509340f0077c56208fab74f8a9d4078943598b6649dacef7 | Python | 3,420 | 59 | import argparse
from train_utils import add_flags_from_config
config_args = {
'training_config': {
'lr': (0.01, 'learning rate'),
'dropout': (0.0, 'dropout probability'),
'cuda': (-1, 'which cuda device to use (-1 for cpu training)'),
'epochs': (5000, 'maximum number of epochs to t... |
32113a7eab5d85965c391a3f867161a29bbbd147bb24ebb03b908c8328b01737 | Python | 3,421 | 100 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
70ae39c0e00dc23dd8c267e2ddc6aa98841d55a07bfc4cfb989727c03b56b17a | Python | 3,422 | 89 | ''' Script for generating a list of coordinates (with Euler angles) and their correspodent reconstructed particles to STAR file '''
''' % generate folders corresponding to tomogram names in rln folder '''
import os
import csv
import random
import pyseg as ps
import scipy as sp
# I/O files
in_coords = '/fs/pool/pool-l... |
a17a2aa4724e64dbe4ec30b62ac4b21850666f82d5dc7dcfa10036893ab2b333 | Python | 3,422 | 123 | #!/usr/bin/env python
import argparse
import pathlib
import time
import numpy as np
import torch
import torch.nn.functional as F
import tqdm
from fvcore.common.checkpoint import Checkpointer
from pytorch_image_classification import (
apply_data_parallel_wrapper,
create_dataloader,
create_loss,
creat... |
489d60ccab77c88fc4e73920338de63ed626e6e057f01402859cbc0865ff04e2 | Python | 3,423 | 86 | '''
# ====================
# Residual U-Net
# ====================
citation:
@article{zhang2020plug,
title={Plug-and-Play Image Restoration with Deep Denoiser Prior},
author={Zhang, Kai and Li, Yawei and Zuo, Wangmeng and Zhang, Lei and Van Gool, Luc and Timofte, Radu},
journal={arXiv preprint},
year={2020}
}
# =======... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.