version stringclasses 21
values | code stringlengths 225 174k | apis list | full_version stringlengths 1 6 | repo_name stringlengths 10 107 | hexsha stringlengths 40 40 |
|---|---|---|---|---|---|
1.8 | # coding=utf-8
#
# Copyright 2020 Heinrich Heine University Duesseldorf
#
# Part of this code is based on the source code of BERT-DST
# (arXiv:1907.03040)
# Part of this code is based on the source code of Transformers
# (arXiv:1910.03771)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may no... | [
"torch.cuda.amp.grad_scaler.GradScaler",
"torch.distributed.get_world_size",
"torch.utils.data.RandomSampler",
"torch.cuda.amp.autocast",
"torch.cuda.is_available",
"torch.load",
"torch.nn.DataParallel",
"torch.distributed.init_process_group",
"torch.utils.data.DataLoader",
"torch.utils.tensorboar... | 1.8.1 | SparkJiao/MERIt | e887dd11bd2969345a5fb07c47d49bd0245e41e6 |
1.8 | from datetime import datetime
import os
import pickle
import argparse
import numpy as np
import torch
import torch.nn.functional as F
from mcmc_unlearner import sgmcmcUnlearner
import utils
import models
class myUnlearner(sgmcmcUnlearner):
def _apply_sample(self, z):
x, y = z
if not self.cpu: x, ... | [
"torch.cat",
"torch.cuda.synchronize",
"torch.no_grad",
"torch.nn.functional.cross_entropy",
"torch.tensor",
"torch.load"
] | 1.8.1 | fshp971/mcmc-unlearning | 3113dedca6de33bcaf316b804cb9c1e636db7fd5 |
1.9 | import time
import hashlib
import torch
from torch_geometric.data import DataLoader
from cgl.utils.params import ParamDict
from cgl.data.graph_data import CircuitInMemDataset, CircuitGraphDataset
# from cgl.models.gnn import DeepGENNet
s = time.time()
print('Loading the dataset ...')
root = '/store/nosnap/results/n... | [
"torch.where"
] | 1.9.0 | kouroshHakha/circuit-fewshot-code | 32007e119da30632736868a3f643027624bf08d2 |
1.0 | # File: rigidbody.py
import abc
import torch
from mechamodlearn import nn, utils
from mechamodlearn.models import CholeskyMMNet, PotentialNet, GeneralizedForceNet
class AbstractRigidBody:
@property
@abc.abstractmethod
def thetamask(self):
"""Returns theta mask for configuration q.
These... | [
"torch.zeros_like",
"torch.enable_grad",
"torch.stack",
"torch.sum"
] | 1.0 | sisl/mechamodlearn | ed514b5d1193ce546b0221ba9222b0228d6c319a |
1.6 | """
Experiment config to evaluate a PointNav RGB policy
trained with Nav. Loss + Rotation Prediction
Supports "Clean" and the following visual corruptions
- Defocus Blur
- Motion Blur
- Spatter
- Low Lighting
- Speckle
"""
# Required imports
import glob
import os
from abc import ABC
from math import ceil
from typing ... | [
"torch.cuda.is_available",
"torch.cuda.device_count"
] | 1.6.0 | DexiongYung/robustnav_AE | f2b1b5bb8780e4e6ae5f81c127b7589cfc949801 |
1.4 | # Copyright (C) 2019-2021 Ruhr West University of Applied Sciences, Bottrop, Germany
# AND Elektronische Fahrwerksysteme GmbH, Gaimersheim Germany
#
# This Source Code Form is subject to the terms of the Apache License 2.0
# If a copy of the APL2 was not distributed with this
# file, You can obtain one at https://www.a... | [
"torch.zeros",
"torch.mul",
"torch.softmax",
"torch.ones",
"torch.matmul",
"torch.Tensor",
"torch.reshape"
] | 1.4 | by-liu/calibration-framework | 7b306e4bbe6361d411b209759b7ba3d016bd0d17 |
1.8 | import torch
import torch.distributed as dist
from .parallel_mode import ParallelMode
from typing import Tuple
def _check_sanity():
from colossalai.core import global_context as gpc
if gpc.tensor_parallel_size > 1 or gpc.pipeline_parallel_size > 1:
raise NotImplementedError("Moe is not compat... | [
"torch.distributed.get_world_size",
"torch.distributed.get_rank",
"torch.cuda.is_available",
"torch.distributed.new_group"
] | 1.8 | JunjieChen-2020/ColossalAI | 0e121a256ac4f628f5d26a16dc553cd0024ca2d5 |
1.6 | """Script to train the Hamiltonian Generative Network
"""
import ast
import argparse
import copy
import pprint
import os
import warnings
import yaml
import numpy as np
import torch
import tqdm
from utilities.integrator import Integrator
from utilities.training_logger import TrainingLogger
from utilities import loader... | [
"torch.__getattribute__",
"torch.optim.Adam",
"torch.clamp",
"torch.cuda.is_available"
] | 1.6.0 | feng-y16/Hamiltonian-Generative-Networks | 702d3ff3aec40eba20e17c5a1612b5b0b1e2f831 |
1.8 | # coding=utf-8
import math
import torch
import numpy as np
from torch.nn import init
from itertools import repeat
from torch.nn import functional as F
import collections.abc as container_abcs
from typing import Optional
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class DOConv2... | [
"torch.zeros",
"torch.cat",
"torch.nn.parameter.Parameter",
"torch.einsum",
"torch.from_numpy",
"torch.nn.init._calculate_fan_in_and_fan_out",
"torch.eye",
"torch.nn.init.uniform_",
"torch.nn.functional.pad",
"torch.Tensor",
"torch.nn.functional.conv2d",
"torch.reshape"
] | 1.8.0 | khawar512/OPVT | 690e540e7f54e43751d28a046009993e3e325291 |
1.4 | import torch
import torch.nn as nn
import torch.nn.functional as F
class MolDQN(nn.Module):
def __init__(self, input_length, output_length):
super(MolDQN, self).__init__()
self.linear_1 = nn.Linear(input_length, 1024)
self.linear_2 = nn.Linear(1024, 512)
self.linear_3 = nn.Linear(... | [
"torch.nn.Linear",
"torch.nn.ReLU"
] | 1.4.0 | iamchosenlee/MolDQN-pytorch | bda8a74eb9e5d2f3232a6a27b6a32928a3797f6d |
0.6 | import numpy as np
import torch
from sklearn.metrics import roc_auc_score
from tqdm import tqdm
import config as c
from model import get_cs_flow_model, save_model, FeatureExtractor, nf_forward
from utils import *
def train(train_loader, test_loader):
model = get_cs_flow_model()
optimizer = torch.optim.Adam(mo... | [
"torch.no_grad"
] | 0.6.3 | MuhammadSYahyaS/cs-flow | bef320ae7b2063f1dce41fb2f2225228cd43a589 |
0.4 | import os
import json
import torch
import numpy as np
from torch.utils import data
from PIL import Image
from ptsemseg.utils import recursive_glob
from ptsemseg.augmentations import Compose, RandomHorizontallyFlip, RandomRotate
class mapillaryVistasLoader(data.Dataset):
def __init__(
self,
root,
... | [
"torch.utils.data.DataLoader"
] | 0.4.1 | EEEGUI/Mapillary-vistas-semseg | d07a107fd08a7536f09f25e426a6f15033cbb609 |
1.0 | # coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# 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... | [
"torch.no_grad"
] | 1.0 | shangz-ai/transformers | 75259b44bf2e2b98b5a4d431fb400b7190342a01 |
1.0 | # coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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 r... | [
"torch.Size",
"torch.zeros",
"torch.cat",
"torch.einsum",
"torch.no_grad",
"torch.ones",
"torch.manual_seed",
"torch.tensor",
"torch.ones_like",
"torch.allclose",
"torch.argmax"
] | 1.0 | shangz-ai/transformers | 75259b44bf2e2b98b5a4d431fb400b7190342a01 |
1.0 | # coding=utf-8
# Copyright 2020 The Allen Institute for AI team and The HuggingFace Inc. team.
#
# 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... | [
"torch.nn.Linear",
"torch.cat",
"torch.einsum",
"torch.finfo",
"torch.bmm",
"torch.ones",
"torch.masked_fill",
"torch.nn.BCEWithLogitsLoss",
"torch.nn.functional.pad",
"torch.nn.CrossEntropyLoss",
"torch.nn.LayerNorm",
"torch.zeros_like",
"torch.zeros",
"torch.nn.Tanh",
"torch.nn.functio... | 1.0 | shangz-ai/transformers | 75259b44bf2e2b98b5a4d431fb400b7190342a01 |
1.0 | # coding=utf-8
# Copyright 2019-present, Facebook, Inc and the HuggingFace Inc. team.
#
# 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
#
# Un... | [
"torch.nn.Linear",
"torch.cat",
"torch.nn.AdaptiveLogSoftmaxWithLoss",
"torch.nn.ModuleList",
"torch.finfo",
"torch.nn.BCEWithLogitsLoss",
"torch.nn.CrossEntropyLoss",
"torch.nn.LayerNorm",
"torch.nn.init.constant_",
"torch.nn.init.normal_",
"torch.tensor",
"torch.nn.functional.dropout",
"to... | 1.0 | shangz-ai/transformers | 75259b44bf2e2b98b5a4d431fb400b7190342a01 |
1.7 | import torch
import torch.nn as nn
import torch.nn.functional as F
from .block import Mish, SeparableConv2d, Block
class WideTipXception(nn.Module):
def __init__(self, num_class):
super(WideTipXception, self).__init__()
self.conv1 = nn.Conv2d(1, 192, 3, 2, 1, bias=True)
self.bn1 = nn.Batc... | [
"torch.nn.Linear",
"torch.nn.Conv2d",
"torch.nn.BatchNorm2d",
"torch.nn.functional.adaptive_avg_pool2d"
] | 1.7.1 | Luciano233/OCR_Japanease | 055bdd0cc8e4d053dfb471cd642b1616ba0938d1 |
1.1 | import torch
import torch.nn as nn
import spconv
from functools import partial
from .spconv_backbone import post_act_block
from ...utils import common_utils
class SparseBasicBlock(spconv.SparseModule):
expansion = 1
def __init__(self, inplanes, planes, stride=1, downsample=None, indice_key=None, norm_fn=None... | [
"torch.nn.ReLU",
"torch.cat"
] | 1.1 | StarGazer1995/OpenPCDet | 4af33e8badb0c8e68c7c94c71b0ec5667aad2348 |
1.9 | """
Copyright (c) 2022 Intel Corporation
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 writin... | [
"torch.allclose",
"torch.ones"
] | 1.9.1 | openvinotoolkit/nncf_pytorch | 13a483eac6ed891720ba90d7902142c4b3bfa599 |
1.7 | import torch.nn as nn
class Generator(nn.Module):
def __init__(self, img_size=32):
super(Generator, self).__init__()
# TODO: update to proper image size
self.init_size = img_size // 4
self.l1 = nn.Sequential(nn.Linear(10, 128 * self.init_size ** 2))
self.conv_blocks = nn.... | [
"torch.nn.Linear",
"torch.nn.Tanh",
"torch.nn.BatchNorm2d",
"torch.nn.LeakyReLU",
"torch.nn.Upsample",
"torch.nn.Conv2d",
"torch.nn.Dropout2d"
] | 1.7.1 | nata1y/fltk-testbed-group-3 | e23b59fa2a5e638d3804a39fe5012983e2988ca6 |
0.4 | from typing import Type
import torch
from torch import nn
from torch.jit import ScriptModule
from catalyst.dl.core import Experiment, Runner
class _ForwardOverrideModel(nn.Module):
"""
Model that calls specified method instead of forward
(Workaround, single method tracing is not supported)
"""
... | [
"torch.device",
"torch.jit.trace"
] | 0.4.1 | 162/catalyst | b4ba36be52c51160e0fabecdcb084a8d5cd96cb7 |
1.1 | from functools import partial
import torch
import random
import numpy as np
from ...ops.roiaware_pool3d import roiaware_pool3d_utils
from ...utils import common_utils, box_utils
from . import augmentor_utils, database_sampler
class DataAugmentor(object):
def __init__(self, root_path, augmentor_configs, class_name... | [
"torch.from_numpy"
] | 1.1 | Jasonkks/mlcnet | 8f89c860c709733c8baa663607004fc48d76291d |
1.4 | from typing import Any, Dict, List, Optional, Tuple, Type, Union
import numpy as np
import torch as th
from torch.nn import functional as F
from stable_baselines3.common import logger
from stable_baselines3.common.off_policy_algorithm import OffPolicyAlgorithm
from stable_baselines3.common.type_aliases import GymEnv,... | [
"torch.no_grad",
"torch.nn.functional.smooth_l1_loss"
] | 1.4.0 | haorang/285 | 3b7369b8eb4433952c9cdf27d4feaa015a6c40e4 |
1.0 | # coding=utf-8
# Copyright 2022 The HuggingFace Team. 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 requir... | [
"torch.cat",
"torch.no_grad",
"torch.ones",
"torch.cuda.is_available",
"torch.LongTensor",
"torch.ones_like",
"torch.allclose"
] | 1.0 | JingyaHuang/transformers | 6589e510fa4e6c442059de2fab84752535de9b23 |
1.0 | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | [
"torch.nn.Linear",
"torch.cat",
"torch.nn.ParameterList",
"torch.einsum",
"torch.nn.ModuleList",
"torch.ne",
"torch.nn.BCEWithLogitsLoss",
"torch.nn.CrossEntropyLoss",
"torch.chunk",
"torch.ger",
"torch.sum",
"torch.nn.LayerNorm",
"torch.nn.init.constant_",
"torch.FloatTensor",
"torch.tr... | 1.0 | JingyaHuang/transformers | 6589e510fa4e6c442059de2fab84752535de9b23 |
1.6 | from typing import Union
import torch
import torch.nn as nn
import torch.utils.data
from torch.optim.lr_scheduler import _LRScheduler, ReduceLROnPlateau
from torch.optim.optimizer import Optimizer
from mighty.loss import LossPenalty
from mighty.models import AutoencoderLinear
from mighty.monitor.monitor import Monito... | [
"torch.no_grad",
"torch.isfinite"
] | 1.6.0 | dizcza/pytorch-mighty | 942c53b529377c9100bffc2f7f20ec740763e6ae |
0.3 | import torch
from torch.autograd import Variable
import onmt.translate.Beam
import onmt.io
class Translator(object):
"""
Uses a model to translate a batch of sentences.
Args:
model (:obj:`onmt.modules.NMTModel`):
NMT model to use for translation
fields (dict of Fields): data fie... | [
"torch.autograd.Variable",
"torch.Tensor"
] | 0.3.1 | Priyansh2/csnli | de31f3f5ae0a956496b76a4643fa9ce7f3736d29 |
1.5 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Backbone modules.
"""
import torch
import torch.nn.functional as F
import torchvision
from torch import nn
from torchvision.models._utils import IntermediateLayerGetter
from typing import Dict, List
from util.misc import NestedTensor, is_main_p... | [
"torch.zeros",
"torch.ones"
] | 1.5.0 | playerkk/HoiTransformer | b710216d6b338863ebe9d40a96765ab52780cefa |
0.4 | import logging
from typing import Any, Dict, List, Tuple
import difflib
import sqlparse
from overrides import overrides
import torch
from allennlp.common.util import pad_sequence_to_length
from allennlp.data import Vocabulary
from allennlp.data.fields.production_rule_field import ProductionRuleArray
from allennlp.sem... | [
"torch.nn.init.normal_",
"torch.cat",
"torch.FloatTensor",
"torch.nn.Dropout"
] | 0.4.1 | ljch2018/allennlp | 63ba3fb28897578d4798039d1713e2b7995eb753 |
1.8 | import sys
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.autograd import Variable
def conv3x3(in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=True)
def conv_in... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.nn.init.constant_",
"torch.nn.Sequential",
"torch.nn.BatchNorm2d",
"torch.nn.Conv2d",
"torch.nn.functional.max_pool2d"
] | 1.8.1 | christophbrgr/ood_detection_framework | c3b7e3064ed8ee4aeb112cd2ab946ee41636f79f |
1.8 | import math
import warnings
import torch
from typing import List, Union
from torch import Tensor, nn
from ..common import EncoderModule, _take
__all__ = ["GenericTimmEncoder", "make_n_channel_input_std_conv"]
class GenericTimmEncoder(EncoderModule):
def __init__(self, timm_encoder: Union[nn.Module, str], layer... | [
"torch.cat",
"torch.nn.Parameter"
] | 1.8.1 | George-Jiao/pytorch-toolbelt | 920e03876805351ed5645e439a64074cb4f37589 |
1.9 | # Copyright (c) 2017-2019 Uber Technologies, Inc.
# SPDX-License-Identifier: Apache-2.0
import torch
import torch.distributions as torchdist
from torch.distributions import constraints
import pyro
import pyro.distributions as dist
from pyro.contrib.gp.models.model import GPModel
from pyro.contrib.gp.util import condi... | [
"torch.cat",
"torch.linalg.cholesky"
] | 1.9.0 | GautamV234/pyro | d5474ebc6101b330bf9060a3731830d4b6a585d5 |
1.8 | # Copyright The PyTorch Lightning team.
#
# 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 i... | [
"torch._C._log_api_usage_once",
"torch.no_grad",
"torch.autograd.set_detect_anomaly",
"torch.cuda.is_available",
"torch.set_grad_enabled"
] | 1.8 | valanm22/pytorch-lightning | 5d190eabd28671a6222741f5dd9ee3f214e519b1 |
1.8 | # Copyright The PyTorch Lightning team.
#
# 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 i... | [
"torch.device",
"torch.tensor"
] | 1.8 | valanm22/pytorch-lightning | 5d190eabd28671a6222741f5dd9ee3f214e519b1 |
1.11 | import torch
from luffy.models.palm import *
def test_palm_tony():
model = PaLMTony(num_tokens=20000)
tokens = torch.randint(0, 20000, (1, 2048))
feat = model(tokens)
assert feat.shape == (1, 2048, 20000)
| [
"torch.randint"
] | 1.11.0 | Fei-Wang/dl-pytorch | a7672603e2de7824d0ff7e97b69dedad3fd9d476 |
1.7 | from .predict import predict
import argparse
import sys, multiprocessing
import torch
def _parse_args():
parser=argparse.ArgumentParser(description="Run SolTranNet aqueous solubility predictor")
parser.add_argument('input',nargs='?',type=argparse.FileType('r'),default=sys.stdin,help='PATH to the file containi... | [
"torch.device"
] | 1.7.0 | hengwei-chan/molecular_attention_transformer | 29193d4155df528e3a6a0c1e0da39111d0b8db93 |
1.3 | """Utility functions used by PyTorch algorithms."""
import torch
import torch.nn.functional as F
class _Default: # pylint: disable=too-few-public-methods
"""A wrapper class to represent default arguments.
Args:
val (object): Argument value.
"""
def __init__(self, val):
self.val = v... | [
"torch.nn.functional.pad",
"torch.full",
"torch.Tensor",
"torch.nn.functional.conv2d"
] | 1.3.0 | adibellathur/garage | 482a26a07d46091f878c41b582f1478588e397ff |
1.0 | # Copyright 2019 NVIDIA Corporation
#
# 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 wr... | [
"torch.nn.Linear",
"torch.cuda.is_available"
] | 1.0.0 | stormymcstorm/condensa | c7321e0a362f73eca9349769b341a7dd688ee1b9 |
0.4 | from easydict import EasyDict as edict
# from pathlib import Path
import torch
import os
from torchvision import transforms as trans
from utils.constants import *
list_model = ['wget https://www.dropbox.com/s/akktsgxp0n8cwn2/model_mobilefacenet.pth?dl=0 -O model_mobilefacenet.pth',
'wget https://www.dropbox.com/s/kzo52... | [
"torch.cuda.is_available"
] | 0.4.0 | LongKt7/Face_Recognize_Pytorch | baa02e633d379abe1001c8b8acb942617177329c |
0.4 | from network import PNet,ONet
import torch,cv2,itertools
from torch.autograd import Variable
import torch.nn.functional as F
import numpy as np
import time
from matlab_cp2tform import get_similarity_transform_for_cv2
import math
def alignment(src_img,src_pts, crop_size = (112, 112)):
ref_pts = np.array([... | [
"torch.cat",
"torch.cuda.synchronize",
"torch.unsqueeze",
"torch.cuda.set_device",
"torch.LongTensor",
"torch.tensor",
"torch.load",
"torch.Tensor",
"torch.exp",
"torch.set_num_threads"
] | 0.4.0 | LongKt7/Face_Recognize_Pytorch | baa02e633d379abe1001c8b8acb942617177329c |
1.6 | import torch
import numpy as np
import SimpleITK as sitk
from Phys_Seg.data_loading import load_and_preprocess, save_segmentation_nifti, read_file, save_img
from Phys_Seg.predict_case import predict_phys_seg, physics_preprocessing, image_preprocessing
import importlib
from Phys_Seg.utils import postprocess_prediction, ... | [
"torch.load"
] | 1.6.0 | pedrob37/Phys_Seg | 7adc65d7b228b3a5702acfa9e6d0494d6b4c2dee |
1.8 | import math
import torch
import torch.nn as nn
from torch.cuda.amp import autocast
from torchreid.losses import AngleSimpleLinear
from torchreid.ops import Dropout, EvalModeSetter, rsc
from .common import HSigmoid, HSwish, ModelInterface, make_divisible
import timm
from torchreid.integration.nncf.compression import ... | [
"torch.nn.Linear",
"torch.nn.Identity",
"torch.cuda.amp.autocast",
"torch.nn.Sequential",
"torch.nn.BatchNorm2d",
"torch.nn.ReLU",
"torch.nn.Conv2d",
"torch.nn.PReLU",
"torch.nn.BatchNorm1d",
"torch.nn.InstanceNorm2d",
"torch.nn.AdaptiveAvgPool2d"
] | 1.8.1 | daniil-lyakhov/deep-object-reid | b0f7d6a2d4cff8c417a66d82c09d16788d81ec67 |
1.8 | from __future__ import absolute_import, division, print_function
from enum import auto
import torch
import torch.nn.functional as F
from torch import nn
from torch.cuda.amp import GradScaler, autocast
from torchreid import metrics
from torchreid.losses import AsymmetricLoss, AMBinaryLoss
from torchreid.metrics.accura... | [
"torch.zeros",
"torch.sigmoid",
"torch.cuda.amp.autocast",
"torch.stack",
"torch.nn.ModuleList",
"torch.nn.functional.kl_div",
"torch.cuda.amp.GradScaler"
] | 1.8.1 | daniil-lyakhov/deep-object-reid | b0f7d6a2d4cff8c417a66d82c09d16788d81ec67 |
1.6 | import torch
import torch.nn as nn
import torch.nn.functional as F
def _create_activation(activation_type):
if activation_type == 'relu':
return torch.relu
elif activation_type == 'swish':
return lambda x: x * torch.sigmoid(x)
raise ValueError('invalid activation_type.')
def create_encod... | [
"torch.nn.Linear",
"torch.rand",
"torch.cat",
"torch.sigmoid",
"torch.nn.ModuleList",
"torch.no_grad",
"torch.nn.BatchNorm2d",
"torch.nn.Conv2d",
"torch.nn.BatchNorm1d"
] | 1.6.0 | meokz/d3rlpy | 40504e2d8b424547558ab82786c523e8f4626a82 |
0.4 | # coding: UTF-8
import argparse
import logging
import random
import torch
import copy
import numpy as np
from dataset import CDTB
from collections import Counter
from itertools import chain
from structure.vocab import Vocab, Label
from structure.nodes import node_type_filter, EDU, Relation, Sentence, TEXT
f... | [
"torch.save",
"torch.from_numpy",
"torch.manual_seed"
] | 0.4 | NLP-Discourse-SoochowU/TDDiscourseParser | 2f9c7cef85c564c47b368ee4935caf1fad7c598d |
1.1 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms, datasets
import logging
import argparse
import sys
import asyncio
import numpy as np
import syft as sy
from syft import workers
from syft.frameworks.torch.federated import utils
logger = logging.getLogger(__name__)... | [
"torch.nn.Linear",
"torch.device",
"torch.no_grad",
"torch.nn.functional.log_softmax",
"torch.manual_seed",
"torch.nn.Conv2d",
"torch.cuda.is_available",
"torch.jit.trace",
"torch.nn.functional.nll_loss",
"torch.nn.functional.max_pool2d"
] | 1.1 | theoptips/PySyft | 4b68c3c6fbe0c18cdf87dfe6ddc3c2071a71f1cc |
1.1 | import torch as th
from torch.utils.data import BatchSampler, RandomSampler, SequentialSampler
from syft.generic import ObjectStorage
from syft.federated.train_config import TrainConfig
class FederatedClient(ObjectStorage):
"""A Client able to execute federated learning in local datasets."""
def __init__(se... | [
"torch.utils.data.SequentialSampler",
"torch.utils.data.RandomSampler",
"torch.utils.data.DataLoader"
] | 1.1 | theoptips/PySyft | 4b68c3c6fbe0c18cdf87dfe6ddc3c2071a71f1cc |
0.3 | from __future__ import division, print_function
from conllu.parser import parse, parse_tree
from tags import Tags, Tag, Label
import os
import re
import math
import numpy as np
import itertools
import pdb
import pickle
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import torch
from torch.aut... | [
"torch.LongTensor",
"torch.exp",
"torch.autograd.Variable",
"torch.max",
"torch.log"
] | 0.3.0 | chaitanyamalaviya/NeuralFactorGraph | 6cd664b7edc43d56c6f1165baa7e7625eb0f7cd8 |
1.9 | import json
from transformers.tokenization_utils import PreTrainedTokenizer
from yacs.config import CfgNode
from openprompt.data_utils.data_utils import InputFeatures
import re
from openprompt import Verbalizer
from typing import *
import torch
import torch.nn as nn
import torch.nn.functional as F
from openprompt.utils... | [
"torch.log",
"torch.tensor",
"torch.nn.Parameter"
] | 1.9.0 | hlzhang109/OpenPrompt | 8a1ec1ceac3805a11b09dda9b96ad7406d222f26 |
1.8 | import torch
import torch.nn as nn
class ChamferLoss(nn.Module):
def __init__(self):
super(ChamferLoss, self).__init__()
self.use_cuda = torch.cuda.is_available()
def forward(self, preds, gts, reverse=True, bidirectional=True):
def compute_loss(preds, gts):
P = self.batch... | [
"torch.cuda.is_available",
"torch.min",
"torch.arange",
"torch.sum"
] | 1.8.0 | anglixjtu/MeshCNN_ | 83826e66d8989ed4967047c2ed6d099568c5781c |
1.8 | import numpy as np
from faiss import IndexFlatIP, IndexFlatL2
import pyvista as pv
import os
import time
from torch_geometric.nn import global_mean_pool, global_add_pool, global_max_pool, global_sort_pool
import torch.nn.functional as F
from torch.utils.tensorboard import SummaryWriter
from .util import get_labels_from... | [
"torch.utils.tensorboard.SummaryWriter"
] | 1.8.0 | anglixjtu/MeshCNN_ | 83826e66d8989ed4967047c2ed6d099568c5781c |
1.0 | # coding=utf-8
# Copyright 2018 Mesh TensorFlow authors, T5 Authors and HuggingFace Inc. team.
#
# 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... | [
"torch.nn.Linear",
"torch.cat",
"torch.nn.ModuleList",
"torch.ones",
"torch.nn.CrossEntropyLoss",
"torch.where",
"torch.sqrt",
"torch.abs",
"torch.tensor",
"torch.zeros_like",
"torch.nn.functional.relu",
"torch.nn.functional.dropout",
"torch.full_like",
"torch.matmul",
"torch.nn.Dropout"... | 1.0 | kushalj001/transformers | 0538820737bd8fb9ba1eb3a772412c6bbe2433ab |
1.4 | import torch
import numpy as np
from torch.distributions import Categorical
from typing import Any, Dict, Tuple, Union, Optional
from tianshou.policy import SACPolicy
from tianshou.data import Batch, ReplayBuffer, to_torch
class DiscreteSACPolicy(SACPolicy):
"""Implementation of SAC for Discrete Action Settings.... | [
"torch.no_grad",
"torch.distributions.Categorical",
"torch.min"
] | 1.4.0 | danagi/tianshou | c97aa4065ee8464bd5897bb86f1f81abd8e2cff9 |
0.4 | from models.base_model import BaseModel
import torch.nn as nn
import torch.nn.functional as F
import os, sys
import torch
import numpy as np
import itertools
from torch.autograd import Variable
from optimizers import get_optimizer
from schedulers import get_scheduler
from models.sync_batchnorm import SynchronizedBatch... | [
"torch.cat",
"torch.nn.init.kaiming_normal_",
"torch.nn.SmoothL1Loss",
"torch.cuda.is_available",
"torch.nn.BCEWithLogitsLoss",
"torch.load",
"torch.sum",
"torch.nn.init.constant_",
"torch.nn.functional.adaptive_avg_pool2d",
"torch.nn.init.normal_",
"torch.as_tensor",
"torch.nn.init.orthogonal... | 0.4.1 | BwCai/DCAA-UDA | 359c2122060aebfbe4384c918768c261fe2dc9c7 |
1.4 | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import argparse
import logging
import math
import os
import time
import warnings
from benchmark_dataset import BenchmarkLMDataset, collate_sentences_lm
import torch
from torch.distributed import rpc
import torch.multiprocessing as mp
import torch... | [
"torch.distributed.get_world_size",
"torch.cuda.manual_seed",
"torch.multiprocessing.spawn",
"torch.cuda.current_device",
"torch.ones",
"torch.cuda.is_available",
"torch.cuda.memory_stats",
"torch.distributed.rpc.shutdown",
"torch.nn.CrossEntropyLoss",
"torch.distributed.init_process_group",
"to... | 1.4.0 | jessijzhao/fairscale | d6a8fc6dadc5d5ab4e3ee3f42f8cd570d70d30ec |
1.4 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import Dict
import torch
from torch.cuda.amp import GradScaler as TorchGradScaler
import torch.distributed as dist... | [
"torch.distributed.all_reduce"
] | 1.4.0 | jessijzhao/fairscale | d6a8fc6dadc5d5ab4e3ee3f42f8cd570d70d30ec |
1.0 | """
Unit tests for RNN decoders.
"""
import unittest
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from texar.torch.hyperparams import HParams
from texar.torch.modules.decoders.decoder_helpers import get_helper
from texar.torch.modules.decoders.rnn_decoders import (
Attent... | [
"torch.rand",
"torch.nn.LSTM",
"torch.is_tensor",
"torch.nn.functional.embedding",
"torch.randint",
"torch.tensor",
"torch.argmax"
] | 1.0.0 | wwt17/texar-pytorch | 9fb3ae8f7b541da5c808357033a93fba1817bfbd |
1.5 | import os
import torch
from pathlib import Path
from nn_interpretability.model.definition.am_mnist_classifier import AMCNN
from nn_interpretability.model.definition.mc_dropout_cnn import CNN_Dropout
from nn_interpretability.model.definition.general_mnist_cnn import GeneralCNN
from nn_interpretability.model.definition.... | [
"torch.cuda.is_available",
"torch.load"
] | 1.5.0 | miquelmn/nn_interpretability | 2b5d2b4102016189743e09f1f3a56f2ecddfde98 |
1.7 | # coding: utf-8
# Copyright 2020 Tarkan Temizoz
# 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... | [
"torch.mul",
"torch.no_grad"
] | 1.7.1 | tarkantemizoz/Cost-Sensitive-Learning | 083f8dfd2950b7e3874df34bf61c2ca1e4a91fbb |
1.5 | from model import DeepJIT
import torch
from tqdm import tqdm
from utils import mini_batches_train, save
import torch.nn as nn
import os, datetime
def train_model(data, params):
data_pad_msg, data_pad_code, data_labels, dict_msg, dict_code = data
# set up parameters
params.cuda = (not params.no_cuda) ... | [
"torch.cuda.is_available",
"torch.tensor",
"torch.nn.BCELoss",
"torch.cuda.FloatTensor"
] | 1.5.0 | ZZR0/ISSTA21-JIT-DP | c2916f7c3b1d235ff2858220886d6a7da068bf8a |
1.5 | import math
import random
import time
import argparse
from sklearn import preprocessing
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, precision_score, recall_score, roc_curve, auc
import pandas as pd
import numpy as np
import torch.nn as nn
import torch
from LR import... | [
"torch.tensor",
"torch.nn.BCELoss"
] | 1.5.0 | ZZR0/ISSTA21-JIT-DP | c2916f7c3b1d235ff2858220886d6a7da068bf8a |
1.5 | import torch
import torch.nn as nn
class LR(nn.Module):
def __init__(self, input_size, num_classes):
super(LR, self).__init__()
# self.fc = nn.Linear(input_size, 128)
# self.fc1 = nn.Linear(128, 256)
# self.fc2 = nn.Linear(256, 64)
# self.fc3 = nn.Linear(64, num_classes)
... | [
"torch.nn.Linear",
"torch.no_grad",
"torch.tensor",
"torch.nn.Sigmoid"
] | 1.5.0 | ZZR0/ISSTA21-JIT-DP | c2916f7c3b1d235ff2858220886d6a7da068bf8a |
1.3 | from torch.distributions import constraints
from torch.distributions.transforms import AbsTransform
from pyro.distributions.torch import TransformedDistribution
class ReflectedDistribution(TransformedDistribution):
"""
Equivalent to ``TransformedDistribution(base_dist, AbsTransform())``,
but additionally... | [
"torch.distributions.transforms.AbsTransform"
] | 1.3.0 | ajrcampbell/pyro | 37680e6d08f20cda95729427143f17875484b21d |
1.2 | import torch as th
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
import numpy as np
from convlab2.policy.larl.multiwoz.latent_dialog.enc2dec.base_modules import BaseRNN
from convlab2.policy.larl.multiwoz.latent_dialog.utils import cast_type, LONG, ... | [
"torch.nn.Linear",
"torch.cat",
"torch.no_grad",
"torch.FloatTensor",
"torch.bmm",
"torch.nn.functional.log_softmax",
"torch.LongTensor",
"torch.nn.functional.softmax",
"torch.nn.Embedding",
"torch.nn.functional.tanh"
] | 1.2.0 | ljw23/ConvLab-2 | 13d48ea0e441701bd66100689b6c25b561f15525 |
1.2 | # Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch.autograd import Variable
from convlab2.e2e.rnn_rollout.engines import EngineBase, Criterion
class Selectio... | [
"torch.autograd.Variable",
"torch.no_grad"
] | 1.2.0 | ljw23/ConvLab-2 | 13d48ea0e441701bd66100689b6c25b561f15525 |
1.9 | import os
import torch
import torch.nn.functional as F
import glob
import numpy as np
from torch.optim import Adam
from utils.utils import soft_update, hard_update
from utils.model import GaussianPolicy, QNetwork, DeterministicPolicy
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, In... | [
"torch.zeros",
"torch.FloatTensor",
"torch.cuda.is_available",
"torch.Tensor"
] | 1.9.0 | hzm2016/assistive-gym-robosuite | 5c529f4444cc386383618bfa584341740a8468f9 |
1.3 | # -*- coding: utf-8 -*- #
"""*********************************************************************************************"""
# FileName [ runner_mockingjay.py ]
# Synopsis [ runner for the mockingjay model ]
# Author [ Andy T. Liu (Andi611) ]
# Copyright [ Copyleft(c), Speech Lab, NTU, Taiwan ... | [
"torch.cuda.manual_seed_all",
"torch.manual_seed",
"torch.cuda.is_available",
"torch.load"
] | 1.3.0 | andi611/Mockingjay-Speech-Representation | e77df17a7f63a983c3757140c7a1e8c199cac614 |
1.8 | import torch
import torch.nn as nn
import torchvision
class ResNeXtBlock(nn.Module):
def __init__(self,in_places,places, stride=1,downsampling=False, expansion = 2, cardinality=32):
super(ResNeXtBlock,self).__init__()
self.expansion = expansion
self.downsampling = downsampling
sel... | [
"torch.nn.ReLU",
"torch.nn.Conv2d",
"torch.nn.BatchNorm2d",
"torch.randn"
] | 1.8.1 | carlsummer/python_developer_tools | fc0dcf5c4ef088e2e535206dc82f09bbfd01f280 |
1.8 | # !/usr/bin/env python
# -- coding: utf-8 --
# @Author zengxiaohui
# Datatime:5/12/2021 9:00 PM
# @File:DcnV2
"""
conda create -n DCNV2 python=3.8
conda activate DCNV2
git clone https://github.com/jinfagang/DCNv2_latest.git
cd DCNv2_latest/
pip install torch==1.6.0
pip install torchvision==0.7.0
python3 setup.py build ... | [
"torch.randint",
"torch.cat",
"torch.randn"
] | 1.8.1 | carlsummer/python_developer_tools | fc0dcf5c4ef088e2e535206dc82f09bbfd01f280 |
1.9 | from itertools import chain
from pathlib import Path
from typing import Tuple
import torch
from accelerate import Accelerator
from torch.utils.data import DataLoader
from saticl.config import Configuration, SSLConfiguration
from saticl.datasets.icl import ICLDataset
from saticl.datasets.transforms import invariance_t... | [
"torch.utils.data.DataLoader"
] | 1.9.0 | edornd/multimodal-icl | f79bfa73665db471c12ee9cb57bbee1bcabb0467 |
1.2 | import copy
import os
import torch
from . import geom
from .cell import WaveCell
from .probe import WaveIntensityProbe
from .rnn import WaveRNN
from .source import WaveSource
from .utils import set_dtype
def save_model(model,
name,
savedir='./study/',
history=None,
history_geom_state=None,
... | [
"torch.save",
"torch.load"
] | 1.2 | Kshitiz-Bansal/wavetorch | 927ad02dc9db83f72b8df1d91418a6681e60fd56 |
1.8 | import networkx as nx
import numpy as np
import torch
from torch.utils.data import Dataset
from dsloader.util import kron_graph, random_binary, make_fractional
class KroneckerDataset (Dataset):
def __init__(self, kron_iter=4, seed_size=4, fixed_seed=None, num_graphs=1, perms_per_graph=256, progress_bar=False):
... | [
"torch.tensor"
] | 1.8.0 | willshiao/brgan | 99d1627176a59811bf9032ef1f99d6e7261095fb |
1.8 | import torch
import torch.nn as nn
class ModdedSharedSvdGenerator(nn.Module):
def __init__(self, latent_dim=100, layer_size=128, num_nodes=500, rank=30, extra_dim=False):
super(ModdedSharedSvdGenerator, self).__init__()
self.num_nodes = num_nodes
self.rank = rank
self.latent_dim = l... | [
"torch.diag_embed",
"torch.nn.Linear",
"torch.nn.Sequential",
"torch.bmm",
"torch.nn.ReLU",
"torch.nn.BatchNorm1d",
"torch.randn"
] | 1.8.0 | willshiao/brgan | 99d1627176a59811bf9032ef1f99d6e7261095fb |
0.4 | import torch
import torch.nn as nn
from torch.nn import init
import functools
from torch.optim import lr_scheduler
from math import floor, log2
from functools import partial
from linear_attention_transformer import ImageLinearAttention
###
from random import random
import numpy as np
import torch.nn.functional as F... | [
"torch.nn.Linear",
"torch.cat",
"torch.optim.lr_scheduler.StepLR",
"torch.nn.ModuleList",
"torch.optim.lr_scheduler.CosineAnnealingLR",
"torch.nn.LeakyReLU",
"torch.nn.BatchNorm2d",
"torch.nn.init.kaiming_normal_",
"torch.cuda.is_available",
"torch.nn.BCEWithLogitsLoss",
"torch.nn.functional.pad... | 0.4.1 | izhorvath/MetGAN | aca85fb3306d2515a65c8d525cd78e1147ba7e1b |
1.8 | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# 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 requi... | [
"torch.nn.Embedding",
"torch.device",
"torch.nn.Linear",
"torch.stack",
"torch.nn.utils.rnn.pad_sequence",
"torch.utils.data.random_split",
"torch.save",
"torch.no_grad",
"torch.tensor",
"torch.utils.data.DataLoader",
"torch.nn.CrossEntropyLoss"
] | 1.8 | iamgroot42/opacus | 51708309e71c030aa2bf15d6dccc7bcbbe9ed570 |
1.0 | import unittest
from transformers import AutoTokenizer, is_torch_available
from transformers.testing_utils import require_torch, slow
if is_torch_available():
import torch
from transformers import (
DataCollatorForLanguageModeling,
DataCollatorForNextSentencePrediction,
DataCollatorF... | [
"torch.Size",
"torch.randint",
"torch.tensor"
] | 1.0 | WERimagin/transformers | cc7d14511c647f8147494df72f8b0575015e37ab |
1.4 | from typing import List
import torch
from torch.nn import ParameterList, Parameter
from allennlp.common.checks import ConfigurationError
class ScalarMix(torch.nn.Module):
"""
Computes a parameterised scalar mixture of N tensors, ``mixture = gamma * sum(s_k * tensor_k)``
where ``s = softmax(w)``, with ``w... | [
"torch.cat",
"torch.sqrt",
"torch.split",
"torch.FloatTensor",
"torch.sum"
] | 1.4.0 | annaproxy/udify-metalearning | 55206a3aac0aba74a3615a36192d03b6467cfd6f |
1.4 | # pylint: disable=no-self-use,invalid-name
from numpy.testing import assert_almost_equal
import torch
from allennlp.modules import Highway
from allennlp.common.testing import AllenNlpTestCase
class TestHighway(AllenNlpTestCase):
def test_forward_works_on_simple_input(self):
highway = Highway(2, 2)
... | [
"torch.FloatTensor",
"torch.ones"
] | 1.4.0 | annaproxy/udify-metalearning | 55206a3aac0aba74a3615a36192d03b6467cfd6f |
1.8 | from typing import Optional, Tuple
import torch
def marginal_pdf(
values: torch.Tensor, bins: torch.Tensor, sigma: torch.Tensor, epsilon: float = 1e-10
) -> Tuple[torch.Tensor, torch.Tensor]:
"""Calculate the marginal probability distribution function of the input tensor based on the number of
histogram ... | [
"torch.arange",
"torch.ones_like",
"torch.zeros_like",
"torch.exp",
"torch.mean",
"torch.sum"
] | 1.8.1 | Ishticode/kornia | 974abb43ec72d12dbd244a2fb247bbbab8498de0 |
1.8 | # based on: https://github.com/ShiqiYu/libfacedetection.train/blob/74f3aa77c63234dd954d21286e9a60703b8d0868/tasks/task1/yufacedetectnet.py # noqa
import math
from enum import Enum
from typing import Callable, Dict, List, Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from kornia.g... | [
"torch.device",
"torch.cat",
"torch.nn.BatchNorm2d",
"torch.nn.ReLU",
"torch.nn.Conv2d",
"torch.tensor",
"torch.hub.load_state_dict_from_url",
"torch.nn.init.xavier_normal_",
"torch.nn.functional.max_pool2d",
"torch.exp"
] | 1.8.1 | Ishticode/kornia | 974abb43ec72d12dbd244a2fb247bbbab8498de0 |
1.8 | import os
import cv2
import imageio
import torch
import kornia as K
import kornia.geometry as KG
def load_timg(file_name):
"""Loads the image with OpenCV and converts to torch.Tensor."""
assert os.path.isfile(file_name), f"Invalid file {file_name}" # nosec
# load image with OpenCV
img = cv2.imread(... | [
"torch.no_grad"
] | 1.8.1 | Ishticode/kornia | 974abb43ec72d12dbd244a2fb247bbbab8498de0 |
1.6 | '''
Code taken from https://github.com/WilhelmT/ClassMix
Slightly modified
'''
import kornia
import torch
import random
import torch.nn as nn
def normalize_rgb(data, dataset):
"""
Args:
data: data to normalize BxCxWxH
dataset: name of the dataset to normalize
Returns:
normalized... | [
"torch.nn.ConstantPad2d",
"torch.nn.functional.interpolate",
"torch.Tensor",
"torch.flip"
] | 1.6.0 | drkostas/SemiSeg-Contrastive | af6b133400368911ef77f401b7673894fe6aa05c |
1.9 | from collections import OrderedDict
import torch
from torch import Tensor
import torch.nn as nn
from torch.utils.model_zoo import load_url as load_state_dict_from_url
from ptnetworks.ActivationTracker import ActivationTracker
from typing import Type, Any, Callable, Union, List, Optional
class ResNetCIFAR(nn.Module):... | [
"torch.nn.Linear",
"torch.device",
"torch.nn.Identity",
"torch.nn.init.kaiming_uniform_",
"torch.flatten",
"torch.nn.init.constant_",
"torch.nn.Sequential",
"torch.nn.init.orthogonal_",
"torch.nn.init.kaiming_normal_",
"torch.utils.model_zoo.load_url",
"torch.nn.init.sparse_",
"torch.nn.Conv2d... | 1.9.1 | Criscraft/pytorch_classification | d5772963e55ce218ae4719fb7f85604263aab65f |
1.7 | # ===============================================================================
# Author: Xianyuan Liu, xianyuan.liu@outlook.com
# Raivo Koot, rekoot1@sheffield.ac.uk
# Haiping Lu, h.lu@sheffield.ac.uk or hplu@ieee.org
# ===============================================================================
... | [
"torch.hub.download_url_to_file"
] | 1.7.0 | SheffieldAI/pykale | 1f5cce57a50f7772520a482e8135a391eb0517f5 |
1.7 | import pytest
import torch
from kale.predict.losses import multitask_topk_accuracy, topk_accuracy
# Dummy data: [batch_size, num_classes]
# Dummy ground truth: batch_size
FIRST_PREDS = torch.tensor(
(
[0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],
[0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],
[0.7, 0.6, 0.5,... | [
"torch.tensor"
] | 1.7.0 | SheffieldAI/pykale | 1f5cce57a50f7772520a482e8135a391eb0517f5 |
1.7 | # Copyright The PyTorch Lightning team.
#
# 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 i... | [
"torch.from_numpy"
] | 1.7.1 | dudeperf3ct/lightning-flash | a855cd14cf1cd0301b4a2f82c0c95e4d8d986650 |
1.0 | """ Class for the Sequence to sequence model for ATIS."""
import os
import torch
import torch.nn.functional as F
from . import torch_utils
from . import utils_bert
from data_util.vocabulary import DEL_TOK, UNK_TOK
from .encoder import Encoder, Encoder_Gnn
from .embedder import Embedder
from .token_predictor import ... | [
"torch.zeros",
"torch.cat",
"torch.optim.Adam",
"torch.load",
"torch.cuda.FloatTensor"
] | 1.0.1 | sahara2001/editsql | d4325ac996d1ed0069def6d349e43e2a1914e761 |
1.0 | #!/usr/bin/env python3
# encoding: utf-8
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Training/decoding definition for the speech recognition task."""
import json
import logging
import os
import numpy as np
import torch
from espnet.asr.a... | [
"torch.is_tensor",
"torch.no_grad",
"torch.load"
] | 1.0.1 | MarkWuNLP/StreamingTransformer | df9bfe348608b7e55ef1ff70464070c0055ea799 |
3 | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from itertools import product
import torch
from fvcore.common.benchmark import benchmark
from pytorch3d.ops.interp_face_attrs import (
interpolate_face_attributes,
interpolate_face_attributes_python,
)
def _generate_data(N, S, K, F, D, ... | [
"torch.device",
"torch.cuda.synchronize",
"torch.manual_seed",
"torch.randint",
"torch.cuda.is_available",
"torch.randn"
] | 3 | shubham-goel/pytorch3d | e5e6e90af6f81b3eccb35bbdfdc7e64ec6a4df21 |
3 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import collections
import os
import pickle
import warnings
import hydra
import numpy as np
import torch
from nerf.dataset import get_nerf_datasets, trivial_collate
from nerf.nerf_renderer import RadianceFieldRenderer, visual... | [
"torch.utils.data.RandomSampler",
"torch.no_grad",
"torch.save",
"torch.manual_seed",
"torch.cuda.is_available",
"torch.utils.data.DataLoader",
"torch.load",
"torch.optim.lr_scheduler.LambdaLR"
] | 3 | shubham-goel/pytorch3d | e5e6e90af6f81b3eccb35bbdfdc7e64ec6a4df21 |
3 | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
"""This module implements utility functions for loading .mtl files and textures."""
import os
import warnings
from typing import Dict, List, Optional, Tuple
import numpy as np
import torch
import torch.nn.functional as F
from iopath.common.file_i... | [
"torch.zeros",
"torch.stack",
"torch.arange",
"torch.ones",
"torch.from_numpy",
"torch.nn.functional.grid_sample",
"torch.tensor",
"torch.meshgrid",
"torch.flip"
] | 3 | shubham-goel/pytorch3d | e5e6e90af6f81b3eccb35bbdfdc7e64ec6a4df21 |
3 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
"""
This example demonstrates camera parameter optimization with the plain
pulsar interface. For this, a reference image has been pre-generated
(you can find it at `../../tests/pulsar/reference/examples_TestRenderer_test_cam.... | [
"torch.device",
"torch.rand",
"torch.cat",
"torch.optim.SGD",
"torch.nn.Parameter",
"torch.manual_seed",
"torch.tensor"
] | 3 | shubham-goel/pytorch3d | e5e6e90af6f81b3eccb35bbdfdc7e64ec6a4df21 |
1.10 | #!/usr/bin/env python
"""Train the Text2Mel network. See: https://arxiv.org/abs/1710.08969"""
__author__ = 'Erdene-Ochir Tuguldur'
import sys
import time
import argparse
from tqdm import *
import numpy as np
import torch
import torch.nn.functional as F
# project imports
from models import Text2Mel
from hyperparams ... | [
"torch.zeros",
"torch.nn.functional.l1_loss",
"torch.from_numpy",
"torch.cuda.is_available",
"torch.set_grad_enabled"
] | 1.10.2 | TraceOnBrainOff/pytorch-dc-tts | 993a0fbace561729b04df2179b41a0a7ea502e93 |
1.8 | #!/usr/bin/python3
"""Recipe for training a speaker verification system based on PLDA using the voxceleb dataset.
The system employs a pre-trained model followed by a PLDA transformation.
The pre-trained model is automatically downloaded from the web if not specified.
To run this recipe, run the following command:
... | [
"torch.no_grad",
"torch.ones",
"torch.tensor"
] | 1.8.0 | pnsafari/speechbrain | 3a6956a838f3796ff6d041ee6a20bcdea55794cb |
1.8 | import torch
import torch.nn.functional
from e3nn.o3 import Irreps
from e3nn.util.jit import compile_mode
from nequip.data import AtomicDataDict
from .._graph_mixin import GraphModuleMixin
@compile_mode("script")
class OneHotAtomEncoding(GraphModuleMixin, torch.nn.Module):
num_types: int
set_features: bool
... | [
"torch.nn.functional.one_hot"
] | 1.8 | mir-group/nequip | 4e6a0914a289cf000da57a6b6e79678efdf3347f |
1.8 | #!/usr/bin/env python3
"""Generate `trn` files for Librispeech
Given a Librispeech directory, parse transcript files,
transcribe the corresponding audio, and generate hypothesis files.
"""
import os
import time
import logging
import argparse
from pathlib import Path
import torch
import torchaudio
import fairseq
impor... | [
"torch.zeros_like",
"torch.set_num_threads"
] | 1.8 | mthrok/ctcdecode | b1a30d7a65342012e0d2524d9bae1c5412b24a23 |
1.5 | import torch
from torch import nn
from torch.nn import init
from torch.utils.data import DataLoader
from overrides import overrides
import numpy as np
import time
from models.BaseModel import BaseModel
class PCAModel(BaseModel):
def __init__(self, configs: object):
super().__init__(configs.model.model_na... | [
"torch.flatten"
] | 1.5.0 | madcpt/MachineWontLie | 992156f3916bafeaa01a3685eae285550391132e |
1.8 | # Copyright (C) 2021, Mindee.
# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
from typing import Any, List, Tuple, Union
import numpy as np
import torch
from torch import nn
from doctr.models.preprocess... | [
"torch.no_grad"
] | 1.8.0 | thentgesMindee/doctr | f97e92ba1b7bcb785a60f2cf549f13f88e510609 |
0.4 | from __future__ import print_function
import torch
import torch.nn as nn
import torch.utils.data
from torch.autograd import Variable
import torch.nn.functional as F
import numpy as np
def convbn(in_planes, out_planes, kernel_size, stride, pad, dilation):
return nn.Sequential(nn.Conv2d(in_planes, out_planes, kerne... | [
"torch.cat",
"torch.nn.Sequential",
"torch.nn.AvgPool2d",
"torch.nn.BatchNorm2d",
"torch.nn.ReLU",
"torch.nn.Conv2d",
"torch.nn.Conv3d",
"torch.nn.BatchNorm3d",
"torch.sum"
] | 0.4.0 | wangqingyu985/OpenStereo | 91d605357d65281b99b0d8cf45e3f15f0543c9fa |
1.1 | import signal
import time
from typing import Any, Callable
import torch
from easydict import EasyDict
from .time_helper_base import TimeWrapper
from .time_helper_cuda import get_cuda_time_wrapper
def build_time_helper(cfg: EasyDict = None, wrapper_type: str = None) -> Callable[[], 'TimeWrapper']:
r"""
Overvi... | [
"torch.cuda.is_available"
] | 1.1.0 | sailxjx/DI-engine | c6763f8e2ba885a2a02f611195a1b5f8b50bff00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.