sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
c52faea9a6d701509d607d1436674ff0e6e166e43baf627aaee079fa688be16e | Python | 3,346 | 93 | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class flickr30k_train(Dataset):
def __init__(self, transform, image_root, ann_root, max_words=30, prompt=''):
'''
image_... |
2e1ac0523cd32d7fc351dfb0ca4a8583c59fdf724cffe5d6613f82320251375f | Python | 3,347 | 91 | # 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... |
4097e47b304a5a1aafcf34343f0aa65393246c153480cc92cca1c21988d44225 | Python | 3,356 | 117 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
from typing import Any, Optional, Protocol, Sequence, Tuple, TypeAlias, TypeVar, Union
import numpy as np
import torch
from torch import Tensor
from torc... |
52e92d8b6742011ac22576913fae3ac9816299c1de6d01ce820096cefbea3847 | Python | 3,356 | 109 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import json_tricks as json
from mmcv import Config
from xtcocotools.cocoeval import COCOeval
from mmpose.datasets.builder import DATASETS
from .bottom_up_coco import BottomUpCocoDataset
@DATASETS.register_module()
class BottomUpCrowdPoseDataset(BottomU... |
f96fa57a2d0a4a4e21237b701029796097c4484eaf75c388e4fa966aeee20807 | Python | 3,356 | 110 | from collections import namedtuple
Hsp = namedtuple(
"Hsp",
["qname", "tname", "pid", "len", "qcoords", "tcoords", "evalue", "qlen", "tlen"],
)
def parse_blast(handle):
for line in handle:
line = line.split()
yield Hsp(
qname=line[0],
tname=line[1],
pid... |
5ff9ab0e205ad92e2cde2911007f8cfa5e7eceda9cf91e097ac496c40b1a52db | Python | 3,358 | 89 | from typing import Optional
import eagerpy as ep
import numpy as np
from ..devutils import flatten
from ..devutils import atleast_kd
from ..types import Bounds
from .gradient_descent_base import L1BaseGradientDescent
from .gradient_descent_base import normalize_lp_norms
class SparseL1DescentAttack(L1BaseGradientDe... |
80f1c020b7d67111724155bcf5ba2070401cc766b21915470070e67838752834 | Python | 3,358 | 99 | """File for accessing YOLOv5 via PyTorch Hub https://pytorch.org/hub/
Usage:
import torch
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True, channels=3, classes=80)
"""
dependencies = ['torch', 'yaml']
import os
import torch
from models.yolo import Model
from utils.google_utils import ... |
e544df23b9a2f8b7afd053f37bc6d3cafef5f1c54dfde96145cdcca7dc5ecb4c | Python | 3,358 | 91 | import torch
import torch.nn as nn
import torch.nn.functional as F
class dilated_conv(nn.Module):
""" same as original conv if dilation equals to 1 """
def __init__(self, in_channel, out_channel, kernel_size=3, dropout_rate=0.0, activation=F.relu, dilation=1,
padding=1):
super().__in... |
b7f6c2da494e79624fe75dcfe3af5345a47a39943f900045f297801463f2d4da | Python | 3,363 | 101 | from typing import List, Any
import eagerpy as ep
import foolbox as fbn
import foolbox.attacks as fa
from foolbox.devutils import flatten
import pytest
from conftest import ModeAndDataAndDescription
def get_attack_id(x: fa.Attack) -> str:
return repr(x)
attacks: List[fa.Attack] = [
fa.PointwiseAttack(),
... |
e01e0ac58bb32716f9586ad6b66712d9bd90d79f07f3bf978f68e95fe619aeba | Python | 3,364 | 120 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
# NOTE: This is inspired by the sbibm-package <https://github.com/sbi-benchmark/sbibm>
from functools import partial
from typing import Callable
import t... |
a7bae66a4b0d02efb9709c6ffe758eefe2d963c7e6516dbe208d4327b606927f | Python | 3,366 | 92 | import os
import numpy as np
import pandas as pd
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import DataStructs
def calc_similarity_matrix(smiles_list):
mols = [Chem.MolFromSmiles(smile) for smile in smiles_list]
fgrp = [AllChem.GetMorganFingerprintAsBitVect(mol,2,nBits=1024) fo... |
b5f3b347c970ff2770cdd2c1433a9cb1047c619a98f01d5b2efc8e367da23af4 | Python | 3,370 | 95 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 16 16:21:29 2023
@author: arthu
"""
import tensorflow as tf
import numpy as np
import os
import matplotlib.pyplot as plt
predatapath = " " # path to NNdata
datapath = " " # path for preprocessed data
datasavepath = " "
def get_file_list(file_path):... |
225b42e69b0b9795a5c8a92c8b524e9f0ba314bcf870c2b25744f8b0b74f1ca4 | Python | 3,374 | 84 | """Exports a YOLOv5 *.pt model to ONNX and TorchScript formats
Usage:
$ export PYTHONPATH="$PWD" && python models/export.py --weights ./weights/yolov5s.pt --img 640 --batch 1
"""
import argparse
import torch
import torch.nn as nn
import models
from models.experimental import attempt_load
from utils.activations ... |
5dbfff5c7a27694aee3b2a975c08e2ef65425f29ed04829ab63ac4cca311b6a5 | Python | 3,375 | 77 | import argparse
import typing
import numpy as np
import pandas as pd
import sklearn
import sklearn.ensemble
import models.sklearn
import models.sklearn.metrics
from models.abstract import ModelClassMetaData, ReportOptions, EvaluateResults, FitResults
class RegressionForestModelMeta(models.sklearn.SklearnModelMeta):... |
dd79fd10ae188da4528d66fbd623030e43032304faf46dc0e2de99e49ccda3ac | Python | 3,376 | 102 | import pytest
from pathlib import Path
from typing import Optional
from clipkit.clipkit import execute
from clipkit.ecomp import read_ecomp
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS
here = Path(__file__)
SAMPLES = here.parent / "samples"
EXPECTED = here.parent / "expecte... |
39f274558f47b5fc6ba2a55978b19af2cecb6b33766bdb0f6c52bf729d644fb5 | Python | 3,377 | 99 | import pandas as pd
from os.path import dirname, join
import numpy as np
from transformers import AutoModelForMaskedLM, AutoTokenizer
from datasets import load_dataset, Dataset
from transformers import DataCollatorForLanguageModeling
from transformers import Trainer, TrainingArguments
import torch
torch.manual_seed(0... |
63d7d75ccbbf246b416821395b46d2e92de725c6cbe790bf789ed16f8e6e406b | Python | 3,377 | 121 | import os
import pickle
import copy
import json
from collections import defaultdict
import numpy as np
import random
import torch
from torch_geometric.data import Data, Dataset
from torch_geometric.transforms import Compose
from torch_geometric.utils import to_networkx
from torch_scatter import scatter
#from torch.ut... |
2ba9c41815ec0ade4a38a58a6c8f0ebc8c74c2bb050d4b3fc7453d59bcebb2de | Python | 3,378 | 116 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 11:45:03 2020
@author: bariskuru
"""
import seaborn as sns, pandas as pd, numpy as np
import os
import matplotlib.pyplot as plt
# seed_order = (100,200
# 101,200
# 102,200
# 100,201
# 101,... |
a250d8b21a9d56ca2487ae601d21940edd6dbfcfdcf906aeea2b601f0f394530 | Python | 3,380 | 92 | import torch
import torch.nn as nn
import torch.nn.functional as F
class dilated_conv(nn.Module):
""" same as original conv if dilation equals to 1 """
def __init__(self, in_channel, out_channel, kernel_size=3, dropout_rate=0.0, activation=F.relu, dilation=1,
padding=1):
super().__in... |
1cb95a1b24a76f21b5941acabf27b63199f901c3eca6ee99c5e99dda6714f330 | Python | 3,383 | 91 | #!/usr/bin/env python3
# mypy: no-disallow-untyped-defs
"""
Sometimes one wants to replace the gradient of a model with a different gradient
from another model to make the attack more reliable. That is, the forward pass
should go through model 1, but the backward pass should go through model 2.
This example shows how t... |
ef791764d5484aa325a76b56cf5aed2a0662b8a4de56fc55bef20547bd8eb635 | Python | 3,383 | 125 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
# NOTE: This is inspired by the sbibm-package <https://github.com/sbi-benchmark/sbibm>
import os
from abc import ABC, abstractmethod
from typing import Ca... |
a494d0c98c6dec917d1016bf5a46920f7a87ead894ed58f1b58b35ccec3c8ee7 | Python | 3,388 | 114 | import moderngl
import numpy as np
from PIL import Image
from PyQt5 import QtOpenGL, QtWidgets
class HeadlessDisplay:
def __init__(self, width=512, height=512):
# Create an OpenGL context
self.ctx = moderngl.create_context(standalone=True, size=(width, height))
self.ctx.enable(moderngl.DEP... |
255f0520debcf7621527ccc0d15d921fe1d52d86f450abf1c0ef84d8a1e4708f | Python | 3,389 | 102 | from setuptools import setup, find_packages, Extension
import glob
import os.path
import sys
C_SRC_PREFIX = os.path.join('cbits', 'webrtc', 'common_audio')
C_SRC_RTC_PREFIX = os.path.join('cbits', 'webrtc', 'rtc_base')
c_sources = (
[os.path.join(
'cbits', 'pywebrtcvad.c')]
+ glob.glob(
os.pa... |
361e44021ffef896d313e59c27f5373aee4abe773e788d6cc2fe86c62c796ad8 | Python | 3,391 | 136 | from matplotlib.colors import LinearSegmentedColormap
import numpy as np
import pandas as pd
import nibabel as nib
import os
from statistics.mlp_output_wrappers import name_to_lobe_map, load_roiname_to_roiid_map
"""
The following colormap copied from
https://matplotlib.org/2.0.2/examples/pylab_examples/custom_cmap.ht... |
4b481d79c33bfb8162ec57fa1a09dd8b6df12b4494615453cc6bc1df74f647e6 | Python | 3,391 | 91 | _base_ = [
'../_base_/models/2_mask_rcnn_r50_fpn_sim_seg.py',
'../_base_/datasets/3_uva_all_data.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
load_from = 'results_sim_seg_mar_31_2022/epoch_35.pth'
pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.... |
aaf2d21089994a2246bafd7c2d8bc91ef393990bc1a01e217358a434232c6986 | Python | 3,391 | 118 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
"""Functions that check types."""
from typing import Any
def is_bool(x):
return isinstance(x, bool)
def is_int(x):
return isinstance(x, int)
... |
dbee065c678ca05215038b3ba309e6960fa28b8bd9cf290e8612f73a9c400327 | Python | 3,392 | 108 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import json_tricks as json
from mmcv import Config
from xtcocotools.cocoeval import COCOeval
from mmpose.datasets.builder import DATASETS
from .bottom_up_coco import BottomUpCocoDataset
@DATASETS.register_module()
class BottomUpMhpDataset(BottomUpCocoD... |
e67cff656d5c248c849a0e9e95bc7a0bcd710b656cfe30c6975e0466fcc1958d | Python | 3,394 | 108 | from typing import Union, Any
import eagerpy as ep
from ..models import Model
from ..criteria import Misclassification
from ..distances import l2
from ..devutils import flatten, atleast_kd
from .base import FixedEpsilonAttack
from .base import get_criterion
from .base import T
from .base import raise_if_kwargs
fro... |
bad830eb405b95257331f64b0c5f4960772e4e75b72b5d581c0e238fa736ca8b | Python | 3,395 | 123 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
# NOTE: This is inspired by the sbibm-package <https://github.com/sbi-benchmark/sbibm>
from functools import partial
from typing import Callable
import t... |
d5e3923dc574664dc700e5399ebcf3976910a1379bc89f362cc86c03f75c0559 | Python | 3,398 | 91 | import ctypes
import json
import multiprocessing
import numpy as np
import pytest
from scipy import sparse
import lightgbm as lgb
from lightgbm.basic import _LIB, _c_str, _safe_call
from .utils import find_random_open_port
def _construct_distributed_dataset(data, params, machines, port, output):
_safe_call(_LI... |
8a467cdc44149c4210836044a6d194b6992fc281cc9185f39934eafd26a5b925 | Python | 3,403 | 95 | # Copyright Universitat Pompeu Fabra 2020-2023 https://www.compscience.org
# Distributed under the MIT License.
# (See accompanying file README.md file or copy at http://opensource.org/licenses/MIT)
from pytest import mark
import torch
from torchmdnet.data import DataModule
from utils import load_example_args, DummyD... |
d94fbd805e352e6d904e2d62b4811a733c26ea70fe4dbdac7781a223e9b4d97d | Python | 3,403 | 113 | #!/usr/bin/env python3
# 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 the License, or
# (at your option) any later version.
#
# This program is distributed in the ho... |
3a53e9d33fa6e53c6c2f12bc8d3c393a6e70e5c55c5c2193b0198f1cf0ee6367 | Python | 3,406 | 98 | # -*- coding: utf-8 -*-
"""
Created on Sun May 29 16:17:56 2022
@author: fhu14
"""
'''
Some diagnostic utilities for visualizing and understanding statistics about
different datasets. This needs some work and is the bare bones right now
'''
#%% Imports, definitions
import matplotlib.pyplot as plt
from typing import L... |
d9d29560d66f2ffa873ebc990a88129c4cb180ba8959ea9b338b67b8329dcbef | Python | 3,406 | 116 | """
Simulate pydentate with grid cell inputs on linear trajectories.
This is one of the most computationally intensive steps as it generates
all the raw data that is used for the perceptron, tempotron as well as
CA3 analysis. It allows for reproducibility through a variety of seeding
steps.
"""
import shelve
import c... |
47f72e098b4c083013e158e135d2f13adf71d836b4b3a2ed4bb7a7f3c7666827 | Python | 3,410 | 91 | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
from mmdet.models.dense_heads import GuidedAnchorHead
def test_ga_anchor_head_loss():
"""Tests anchor head loss when truth is empty and non-empty."""
s = 256
img_metas = [{
'img_shape': (s, s, 3),
'scale_factor': 1,
... |
ad5bf68b5369d22a8c8846ea198fb53f2c3fcbe4614a281ea1b348df06961b84 | Python | 3,413 | 88 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source... |
8b076aec7f7d79700423626fe53b23c5d39188dc28a2dbfc628dde3131f218ad | Python | 3,414 | 92 | """RNN models (LSTM/GRU) implemented in PyTorch."""
from torch import nn
from daart.models.base import BaseModel
# to ignore imports for sphix-autoapidoc
__all__ = ['RNN']
class RNN(BaseModel):
def __init__(self, hparams, type='encoder', in_size=None, hid_size=None, out_size=None):
super().__init__()
... |
1e51afc9e768f166377f35e18f6e52224ef6574d75f88f943317d4e3d27e6ba9 | Python | 3,422 | 103 | """
Generate per-subject sleep stage predictions with majority voting.
This script runs inference on a dataset and saves predictions for each subject,
applying majority voting across channel combinations when multiple channels are
evaluated for the same subject.
Usage: see run.md in config folder
The script:
1. Load... |
a751bf30e37365c5ee1ae1e82756a52be1fbfc759cbdd08fd98af59cf6a63499 | Python | 3,422 | 40 | from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
# visdom and HTML visualization para... |
e07a0c9cd71848dbfee0894fbba956b811341f374c46d92c925e660b61d83bab | Python | 3,423 | 41 | from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
# visdom and HTML visualization para... |
2b18aa4f89de569b4b43388db2025d53fc0db48f4f330b0e76508d88eae537eb | Python | 3,426 | 82 | import argparse
import os
from typing import Dict
import pandas as pd
import numpy as np
import argparse_def
from bathymetry_estimations_utils import load_bathymetry
from models.abstract import input_data
from models.sklearn.metrics import rmse
from reference_data_utils import ReferenceData, load_reference_data, filte... |
e7a9f31bbec4566a90005d540039fbb22185bbabd48465c06bcfb29f844043d4 | Python | 3,426 | 106 | """Provide pytest fixtures for the entire test suite.
These fixtures create data and data modules that can be reused by other tests.
"""
import os
import pytest
import shutil
import torch
from typing import Callable, List, Optional
import yaml
from daart.data import DataGenerator
from daart.utils import build_data_... |
f0a9556f8e44cfb55b8be26c4f4f020386eb89acce6335f215fcca5a76bcad30 | Python | 3,428 | 115 | # Copyright (c) OpenMMLab. All rights reserved.
# 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 -----------------------... |
06b80395b601a0c325d8666ec24a90aae7fb8d2bed20803a822d9971dbddb20b | Python | 3,430 | 112 | import json
import random
import numpy as np
from tqdm import trange
NUM_USER = 30
def softmax(x):
ex = np.exp(x)
sum_ex = np.sum(np.exp(x))
return ex / sum_ex
def generate_synthetic(alpha, beta, iid):
dimension = 60
NUM_CLASS = 10
np.random.seed(0)
samples_per_user = np.random.lognorm... |
dd9e65ea646628eab473d13fd7dd4d87d60d3e514fc3b981747c3e59fe450869 | Python | 3,430 | 70 | import torch.nn as nn
import torch
class RNN_OriginalFedAvg(nn.Module):
"""Creates a RNN model using LSTM layers for Shakespeare language models (next character prediction task).
This replicates the model structure in the paper:
Communication-Efficient Learning of Deep Networks from Decentralized Data
... |
f7ac26c2b05308514a3e2c0c94b543a8e764dd85a9721ec285ac443bd0b123e1 | Python | 3,430 | 96 | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
from mmdet.models.roi_heads.mask_heads import (DynamicMaskHead, FCNMaskHead,
MaskIoUHead)
from .utils import _dummy_bbox_sampling
def test_mask_head_loss():
"""Test mask head loss when mask tar... |
9518e6449852f674490c1b8c436910c54508ecc9d43932bb52b372cbe0b70a47 | Python | 3,434 | 98 | import torch
import numpy as np
class System:
def __init__(self, natoms, nreplicas, precision, device):
# self.pos = pos # Nsystems,Natoms,3
# self.vel = vel # Nsystems,Natoms,3
# self.box = box
# self.forces = forces
self.box = torch.zeros(nreplicas, 3, 3)
self.p... |
fe3cacff90c99cf85bb92eaa67bbe636fa226f701dc80e707d97c84c83b995c3 | Python | 3,434 | 112 | import json
import random
import numpy as np
from tqdm import trange
NUM_USER = 30
def softmax(x):
ex = np.exp(x)
sum_ex = np.sum(np.exp(x))
return ex / sum_ex
def generate_synthetic(alpha, beta, iid):
dimension = 60
NUM_CLASS = 10
np.random.seed(0)
samples_per_user = np.random.lognorm... |
0bd4e1e8fae1d0a109d0ea90440302daf7f652485d750851723e51b1f2773250 | Python | 3,436 | 123 | import copy
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
import numpy as np
import time
import utils
import models
import argparse
import data_loader
import pandas as pd
import ujson as json
from sklearn import metrics
fro... |
0c901a5454b6739075ee1b950d9b64b68d209e382235933e9541ad764555b7b8 | Python | 3,436 | 93 | import numpy as np
from sklearn.metrics import accuracy_score
import torch
from torch import nn
from daart.models.base import BaseModel
# to ignore imports for sphix-autoapidoc
__all__ = ['RNN']
class RNN(BaseModel):
def __init__(self, hparams, type='encoder', in_size=None, hid_size=None, out_size=None):
... |
6c22daeda6c70246d2ad03916b4cf852944e2179ac1956c6915b2e51f5b55e05 | Python | 3,438 | 93 | import os
import pickle as pkl
from deprecated.cv_v1 import GridSearchCV, grid_convert
from util import path_check, Timer
dataset_path = "/home/francishe/Downloads/Datasets/ANI-1ccx_energy_clean.h5"
gammas_path = "/home/francishe/Downloads/Datasets/gammas_50_5_full_cec.h5"
cv_root = "/home/francishe/Downloads/ANI_cv"
... |
16af71d362a44ccb7d43d45f37ce672bc19c9fcf71066ebc9873293f44494197 | Python | 3,440 | 120 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 1 21:10:12 2021
@author: baris
"""
import torch
import torch.nn as nn
from torch import optim
import numpy as np
# labels maker
# output for training the network, 5 for each trajectory
def _label(n_poiss):
a = np.tile([1, 0], (n_poiss, 1)... |
6f6e020839f86df819aab0b05b2c605fb9e93856a3f8d525cb5cb392055605eb | Python | 3,441 | 104 | #!/usr/bin/env python3
import json
import re
import os
import sys
SHOW_UNUSED_LANGS = "--unused" in sys.argv
# use a regex on code to get all "hex.lang.id"_lang occurences
def get_lang_occurrences_in_code(path):
for dir, _, files in os.walk(path):
for file in files:
if not os.path.splitext(fi... |
2d74ab1eee84b1646bb4508e841e80c2f79f8269e9fa59286039b9a46b5a4cfc | Python | 3,442 | 93 | import os
import pickle as pkl
from deprecated.cv_v1 import GridSearchCV, grid_convert
from util import path_check, Timer
dataset_path = "/home/francishe/Downloads/Datasets/Au_energy_clean.h5"
gammas_path = "/home/francishe/Downloads/Datasets/gammas_50_5_full_aec.h5"
cv_root = "/home/francishe/Downloads/Au_cv"
assert... |
33599c8f2cb02e6004a38252489e127b8034e4a63e1184f327a421447440ae28 | Python | 3,444 | 67 | #! /usr/bin/env python
# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source ... |
3ec2f709fccfe9bd008f49d29722208fd38c7a2ee453489e8389d1fecb41110c | Python | 3,445 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
5c2f07e721092d30c532f556ef17850242915c13fac34c2503abcdf27b5a79e9 | Python | 3,445 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
b3b32fec50f0b2acac42f17b9aa770a0c6a88586fb1634f2bd5d5243b4fda180 | Python | 3,447 | 101 | # -*- coding: utf-8 -*-
"""Process the outputs and generate ROC"""
__author__ = "Sean Benson"
__copyright__ = "MIT"
from dtor.utilities.utils_stats import stats_from_results
import numpy as np
import argparse
import torch
from dtor.utilities.utils import set_plt_config
from dtor.utilities.model_retriever import load_... |
893c6f16902f24db0e03883b2b9495be7c4b35b3fa5bfb21bd91ff04e8dad20b | Python | 3,449 | 112 | import re
import json
import os
import torch
import torch.distributed as dist
import utils
def pre_caption(caption,max_words=50):
caption = re.sub(
r"([.!\"()*#:;~])",
' ',
caption.lower(),
)
caption = re.sub(
r"\s{2,}",
' ',
caption,
)
capti... |
aacbc4ada4ea2a9b7cb2cf8a0784ea31687e9abd3fe182f886c36b641dc7fe37 | Python | 3,450 | 126 | """Utils for language models."""
import re
# ------------------------
# utils for shakespeare dataset
# Vocabulary re-used from the Federated Learning for Text Generation tutorial.
# https://www.tensorflow.org/federated/tutorials/federated_learning_for_text_generation
CHAR_VOCAB = list(
'dhlptx@DHLPTX $(,048cgk... |
9765231466d8280e9ea7e5daa901b3b9c13ac1bafc67291e09b436b33e519ecd | Python | 3,451 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
abeee94de8e3dbcba5085179d484b41167e6b860305a7bb3ea24f4691215625a | Python | 3,452 | 87 | import os
import sys
import numpy as np
from EEGModels import get_models
from data_loader import load_data
from experiment import Experiment
from mcnemar import mcnemar_test
from tensorflow.keras import backend as K
from tensorflow.keras.utils import to_categorical
from training_testing import run_experiment... |
08d048b14a3fc5eea36f826af59e7b2125209a0d1ea5dfa2f47bdbd733d627fd | Python | 3,454 | 151 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
from __future__ import absolute_import
from __future__ import with_statement
from __future__ import division
from __future__ import nested_scopes
from __future__ import generators
from __future__ import unicode_literals
from __future__ import print_function
"""
Naively smoothi... |
4cf78e583ee9f1c497ec2ed866314fcf26b48690902c6e4a7a9599a6f17fd7cf | Python | 3,454 | 103 | """Tests that warp-ops and pure-Python TensorNet paths produce identical results."""
import os
import pytest
import torch
from torch.testing import assert_close
from os.path import dirname, join
import torchmdnet.models.tensornet as _tn
CURR_DIR = dirname(__file__)
CKPT = join(CURR_DIR, "example_tensornet.ckpt")
CAF... |
e9f1550197c4367a80c7585140488744c4261ac2a2196735c6cf572e860a742d | Python | 3,454 | 88 | import os
import json
import random
from PIL import Image
import torch
from torch.utils.data import Dataset
from data.utils import pre_question
from torchvision.datasets.utils import download_url
class vqa_dataset(Dataset):
def __init__(self, transform, ann_root, vqa_root, vg_root, train_files=[], split="train")... |
011eea912b40e805ba500b90cfd34f625eef7dd812779835e1acae37f0e21d91 | Python | 3,456 | 98 | # Copyright (C) 2025 ETH Zurich, Niels Maeder and other DASH contributors.
import numpy as np
import pytest
import torch as pt
from rdkit import Chem
from serenityff.charge.gnn.utils.rdkit_helper import (
get_mol_prop_as_np_array,
get_mol_prop_as_pt_tensor,
)
@pytest.fixture
def sample_mol_with_prop():
... |
26203f91976ff0684d1b9a96d3422ad810855658e5aec189342d1377419691ff | Python | 3,457 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
744f3a72b3ef98aeb46e8468f78496c70a2b58872ff4ffb8411cf0a8ca81395a | Python | 3,457 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
633b58888a5783728286885f66b8a0fa65a2353573217f927c5e69232af32fc1 | Python | 3,458 | 98 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
301092918bb2036058845c693adc94241816ebd9eb64ea1927ee345fa17d9eee | Python | 3,459 | 103 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 29 13:33:19 2022
@author: fhu14
Script for running code through DFTBpy and comparing the results. The steps
of running a DFTBpy calculation are taken from the run_dftbplus.py file in
the DFTPlus package.
"""
#%% Imports, definitions
from DFTBpy import DFTB
import pickl... |
f1e6a0b33d582c1cbe52451ce1703b864dc871f1255fdc693a18cba3c5efbcfc | Python | 3,462 | 106 | from pathvalidate import sanitize_filename
import numpy as np
import re
import redis
from datetime import timedelta
def safe_filenames(label_1, label_2):
""" Return safe and distinct filenames from the labels provided for the uploaded datasets"""
sf_1 = sanitize_filename(label_1)
sf_2 = sanitize_filename... |
a018b6e831f588682ce006e2de045d67f0e7d8f4f8722b0dcc6123883e6585fa | Python | 3,473 | 126 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 2 12:40:41 2021
@author: ravinderjit
"""
import os
import pickle
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
from scipy import signal
import mne
import matplotlib
import sys
sys.path.append(os.path.abspath('../../ms... |
121aa2e3672fcf21292884d9f5e1276b6962dcd4b2429317fc1d9efa48a5fcb4 | Python | 3,476 | 99 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
RNNS = ['LSTM', 'GRU']
class Encoder(nn.Module):
"""
The Encoder layer will encode a temporal sequence into a single feature vector.
Implementation inspired by:
https://github.com/mttk/rnn-classifier
"""
def ... |
ecf5e9445ef5f25af667f1d4fecfca714edb19d5ff0fc6a211acbee55b3b9ae4 | Python | 3,477 | 110 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
from mmcv import Config
from xtcocotools.cocoeval import COCOeval
from ...builder import DATASETS
from .topdown_coco_dataset import TopDownCocoDataset
@DATASETS.register_module()
class TopDownCrowdPoseDataset(TopDownCocoDataset):
"""CrowdPoseDatase... |
895a6e38b9bed147ff41f9fa44eb72a19621866e9aa1b1c07f0f183114fb869b | Python | 3,481 | 89 |
def segment_labely(ij, folder_in, segmented, processed, classifier, macro_path, N=3):
print("INCOMPLETE IDEA - \n")
print(" Was planning to use 'pyimagej' to import imagej,\n")
print("and then use ij.run_plugin to operate inside python.\n")
print("Now have found method to get macro to run so not finis... |
3add9c1cc05766b8c5e8689218935016bc86a77bc57b9c2a673fe36a92cf8a30 | Python | 3,482 | 93 | import numpy as np
class Patch(object):
def __init__(self, sample_offset, width_list, area_points, peak_pos = None):
self.sample_offset = sample_offset
self.width_list = np.copy(width_list)
self.area_points = area_points
#print("Patch:", sample_offset)
self.num_pair = sampl... |
e8b7c33b51348cc578717e001ec2338620a184d3c1f5a097786b509292963b00 | Python | 3,491 | 102 | import functools
import inspect
import typing
import argparse
import models.abstract
def get_available_models() -> typing.Dict[str, models.abstract.AbstractModelMeta]:
_available_models = {_m.__name__: _m for _m in
models.abstract.AbstractModel.get_implementations()}
return _availabl... |
a3ad9ef21d259f9a2eaecb728b10b5ca0b4cbcd089c2403a7203b3b68be697bf | Python | 3,492 | 127 | """
Evaluate cross-validated variance explained (R2) for every size-5 and size-6
combination of low-level & NLP feature sets when predicting GPT embeddings.
"""
#### ChatGPT was used to assist writing code. The authors reviewed, edited, and take full responsibility for the content.
import os
PODCAST_ROOT = os.environ... |
097be10513a1778af810bb38ec2d02f62e9328986f240cd4504483dbcd479271 | Python | 3,493 | 81 | # HED batch processing script; modified from https://github.com/s9xie/hed/blob/master/examples/hed/HED-tutorial.ipynb
# Step 1: download the hed repo: https://github.com/s9xie/hed
# Step 2: download the models and protoxt, and put them under {caffe_root}/examples/hed/
# Step 3: put this script under {caffe_root}/exampl... |
f70887ad55753ba3dc3207be1fa6582344f519becd31509d3bcded969defb9af | Python | 3,500 | 105 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 9 13:17:20 2021
@author: fhu14
"""
#%% Imports, definitions
from typing import Dict, List
import collections
import numpy as np
Array = np.ndarray
import random
#%% Code behind
def count_nheavy(molec: Dict) -> int:
r"""Counts the number of heavy atoms in a molecule... |
f4df5680da5bc308325ee8df4f077416918d20b711d342d2ceeea986cb210e04 | Python | 3,501 | 77 | # Copyright (c) 2020-present Joindbre.com
# Authors: Patricia Maraver.
#
# This program is free software: you can redistribute it and/or modify
# it under the GNU Affero General Public License version 3
# as published by the Free Software Foundation.
# You should have received a copy of the Server Side Public Lic... |
52945631cc0f8cf960f532fd97ab49de01778cebe5cd7312619aa9bf141fbcf7 | Python | 3,505 | 127 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
# NOTE: This is inspired by the sbibm-package <https://github.com/sbi-benchmark/sbibm>
import math
from typing import Callable
import torch
from torch.di... |
8352caababa1950fb9c79cb4a564493cd8a5a85464e0c1e7e460aed515a8bc6f | Python | 3,508 | 75 | """Test the validation of externally supplied cluster sample splits."""
import numpy as np
import pytest
from doubleml import DoubleMLData
from doubleml.utils._checks import _check_sample_splitting
from doubleml.utils.resampling import DoubleMLClusterResampling
N_CLUSTERS = 6
def _cluster_data(n_cluster_vars: int)... |
0a953d231b786e3caa7063d6acaeacaa3bc72885467186d452ff46d9bb457e13 | Python | 3,509 | 100 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from torch.utils.checkpoint import checkpoint
from ..builder import NECKS
@NECKS.register_module()
class HRFPN(BaseModule):
"""HRFP... |
1726c506c24729408ffec3903f2d63d3504535fa81b8f6cd48adcdfe7ead2182 | Python | 3,512 | 152 | #!/usr/bin/env python
# (c) 2012 - Ryan M. Layer
# Hall Laboratory
# Quinlan Laboratory
# Department of Computer Science
# Department of Biochemistry and Molecular Genetics
# Department of Public Health Sciences and Center for Public Health Genomics,
# University of Virginia
# rl6sf@virginia.edu
import sys
fro... |
9fc8d7af1aee3f38550cb6d56f3d707668fcf1d7a6a4a954665faedd2715971a | Python | 3,514 | 86 | ############################################
# imports
############################################
from typing import Any
from scipy.sparse import csr_matrix
from oligo_designer_toolsuite.database import OligoDatabase
from oligo_designer_toolsuite.oligo_efficiency_filter import BaseScorer
#########################... |
4679f157e57343327b4ecf734c2ba498029c4fbd2058f766844eca87cba33eb3 | Python | 3,515 | 99 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
5117c3e9853db10c4b797c3c365e2b69ce871b5d2b846fbde09397cd6bf87c1a | Python | 3,516 | 99 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
996fecf7b48620526c53d76a681cfbe50f6b1b91abadd3a243395cca5de9daae | Python | 3,516 | 54 | # Imports #
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.dropdown import DropDown
from kivy.app import App
from Classes.Menu import MenuBase, ImageSetDropdown, ImageSetItem
class ConfigureScreen(MenuBase):
def __init__(self,**kwargs):
super(ConfigureScreen,self).__init... |
d04a6b879280f9723ce7313188d3764a6698a0c324cb51f2d478e3659e73128f | Python | 3,516 | 85 | """
Build hdf5 files based on MURA datasets.
"""
import os
import sys
import h5py
import imageio
import numpy as np
import pydicom
def readlist(dcm_path, annotation_path, save_path, test_case_number):
dcm_folders = os.listdir(dcm_path)
RESULT_FILE_NAME = "StrokeCT.h5"
result_file = h5py.File(os.path.jo... |
8df6da0e3abb57e0cf24b8852d9955c1fac9a4391c9826af0bba4fecf1fa81e9 | Python | 3,519 | 137 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 2 14:01:55 2021
@author: baris
"""
from pydentate import neuron_tools
from grid_model import grid_simulate
import shelve
import copy
import time
import numpy as np
from pydentate_integrate import granule_simulate
import os
start = time.time()
"... |
40e888c14d863df2a0b4acf756f57a4ffed22839070e8c66e2dec96cf0bb3c3c | Python | 3,520 | 103 | from torchmd.forcefields.forcefield import _ForceFieldBase
from math import radians
import numpy as np
import yaml
class YamlForcefield(_ForceFieldBase):
def __init__(self, mol, prm):
self.mol = mol
with open(prm, "r") as f:
self.prm = yaml.load(f, Loader=yaml.FullLoader)
def _get... |
482d9358546862d8d6638b966c03863628d9716eb856ee5035e1fbdd86bb13a1 | Python | 3,521 | 122 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/mpii_trb.py'
]
evaluation = dict(interval=10, metric='PCKh', save_best='PCKh')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
wa... |
17a69fbf1152ee7b28bb07024b9d1a82d78a20fd5aff3d79a93c37cbf4314857 | Python | 3,522 | 84 | from functools import partial
from typing import Any
import torch
from torch import Tensor
from aimnet.config import get_module
class MTLoss:
"""Multi-target loss function with fixed weights.
This class allows for the combination of multiple loss functions, each with a specified weight.
The weights are... |
8ee7369eb1bece04424ee7e4a3591368500d3b16298faada4fdcf60a5ec91cff | Python | 3,522 | 103 | # Copyright (C) 2022-2025 ETH Zurich, Niels Maeder and other DASH contributors.
from typing import Optional
import torch
from torch import nn
from torch.nn import functional as F
from serenityff.charge.gnn.utils.attentive_fp import AttentiveFP
class ChargeCorrectedNodeWiseAttentiveFP(AttentiveFP):
# TODO: add d... |
8ac9595bc84e1e1a071f290b4bc7f769f9bc4de0d199c11d86b48d49f4815399 | Python | 3,523 | 101 | #!/usr/bin/env python
# Adapt from ->
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
# <- Written by Yaping S... |
b70c875a17b381d609b3a5ee867c8393d4574a1bae10f33e1dc524fc9706f05a | Python | 3,523 | 122 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/mpii_trb.py'
]
evaluation = dict(interval=10, metric='PCKh', save_best='PCKh')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
wa... |
cf0cd057e3d1a9e3d7c78a0481197ff2683fa3776859b56970f233eca1e4c670 | Python | 3,523 | 122 | _base_ = [
'../../../../_base_/default_runtime.py',
'../../../../_base_/datasets/mpii_trb.py'
]
evaluation = dict(interval=10, metric='PCKh', save_best='PCKh')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
wa... |
52291605bb0905bc385e147a15f783635a2dbf3516484a80fb5cbd7bd876b611 | Python | 3,525 | 99 | from copy import copy, deepcopy
from transformers import TrainingArguments
import os
from os.path import join, splitext
from model.torch_models.bert_cnn import CNN_Over_BERT
from model.torch_models.bert_linear import Linear_Over_BERT
from model.torch_models.bert_rnn import RNN_Over_BERT
from config_path import LOG_PAT... |
f3ca508ebaa227adf2686d270e199473c334cfebdcbebc173869091c4fa9e4e7 | Python | 3,527 | 92 | """
subsample slices and shift the short axis and long axis slices
"""
import cv2
import numpy as np
import random
from scipy import ndimage
from scipy.ndimage.interpolation import shift
class ExpRandomShiftSxlxCls:
"""
Subsample the 3D numpy [h, w, d] by slice max number.
"""
def __init__(self, rand... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.