version stringclasses 24
values | code stringlengths 396 135k | apis list | full_version stringlengths 1 6 | repo_name stringlengths 6 64 | hexsha stringlengths 40 40 |
|---|---|---|---|---|---|
1.7 | import math
import torch
import numpy as np
import torch.nn.functional as F
from PIL import Image
from tqdm import tqdm
from .floating_region import FloatingRegionScore
from .spatial_purity import SpatialPurity
def PixelSelection(cfg, feature_extractor, classifier, tgt_epoch_loader):
feature_extractor.eval()
... | [
"torch.nn.functional.one_hot",
"torch.max",
"torch.no_grad",
"torch.save",
"torch.nn.functional.interpolate",
"torch.softmax",
"torch.log",
"torch.argmax"
] | 1.7.1 | BIT-DA/RIPU | 125edf112c9ded1e7497aedb2a092331824df100 |
0.4 | import random
import cv2
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from model.roi_crop.functions.roi_crop import RoICropFunction
from model.utils.config import cfg
from torch.autograd import Variable
def save_net(fname, net):
import h5py
h5f = h5py.File(fname, mode... | [
"torch.cat",
"torch.save",
"torch.abs",
"torch.nn.functional.grid_sample",
"torch.nn.functional.max_pool2d",
"torch.pow"
] | 0.4.1 | sadjadasghari/3d-vehicle-tracking | f8433f72a51dd1a7190570e63e9fda4a924a81f0 |
0.4 | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
# --------------------------------------------------------
# Reorganized... | [
"torch.stack",
"torch.min",
"torch.max",
"torch.log",
"torch.exp"
] | 0.4.1 | sadjadasghari/3d-vehicle-tracking | f8433f72a51dd1a7190570e63e9fda4a924a81f0 |
0.4 | """
A stacked LSTM with LSTM layers which alternate between going forwards over
the sequence and going backwards.
"""
from typing import Optional, Tuple, Union, List
import torch
from torch.nn.utils.rnn import PackedSequence
from allennlp.modules.augmented_lstm import AugmentedLstm
from allennlp.common.checks import C... | [
"torch.cat"
] | 0.4.1 | rahular/joint-coref-srl | cd85fb4e11af1a1ea400ed657d0a4511c1d6c6be |
2.0 | """
Copyright (c) 2019-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 w... | [
"torch.nn.Conv2d",
"torch.nn.BatchNorm2d",
"torch.ones_like"
] | 2.0 | MaximProshin/nncf | 2290d2f4cebcf6749e419dc76850e7bd8b7d8da1 |
2.0 | """
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.nn.Linear",
"torch.cat",
"torch.nn.functional.avg_pool2d",
"torch.nn.init.constant_",
"torch.nn.functional.dropout",
"torch.nn.BatchNorm2d",
"torch.utils.model_zoo.load_url",
"torch.nn.functional.adaptive_avg_pool2d",
"torch.unsqueeze",
"torch.nn.Conv2d",
"torch.nn.functional.relu",
"to... | 2.0 | MaximProshin/nncf | 2290d2f4cebcf6749e419dc76850e7bd8b7d8da1 |
2.0 | """
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.zeros"
] | 2.0 | MaximProshin/nncf | 2290d2f4cebcf6749e419dc76850e7bd8b7d8da1 |
1.0 | import os
import logging
from dotenv import load_dotenv
load_dotenv(verbose=True)
logger = logging.getLogger(__name__)
# The Root Directory of the project
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
POSENET_PATH = os.path.join(ROOT_DIR, 'data','raw','posenet.pth')
POSTURENET_PATH = os.path... | [
"torch.cuda.is_available"
] | 1.0.1 | Sushil-Thapa/rectif.ai | b308f613402097dca9734806a8c27ba3eef6a358 |
1.5 | import os
import os
print(os.getcwd())
# os.path.dirname(os.path.abspath("__file__"))
path = '/Volumes/Extreme SSD/MLWork/DocAI/PICK-pytorch'
os.chdir(path)
# os.chdir('../')
# path = '/Users/neerajyadav/Documents/pycv/PICK-pytorch/'
"""Convert files of a selected directory in jpg format"""
import converter
# !pip ins... | [
"torch.device",
"torch.no_grad",
"torch.load"
] | 1.5.1 | NeerajAI/PICK-pytorch | 61deb7c1e11df30c8f03726c061a2866234ac770 |
1.5 | import warnings
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from .utils import load_state_dict_from_url
__all__ = ['GoogLeNet', 'googlenet']
model_urls = {
# GoogLeNet ported from TensorFlow
'googlenet': 'https://download.pytorch.org/models/... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.cat",
"torch.flatten",
"torch.nn.MaxPool2d",
"torch.nn.init.constant_",
"torch.nn.functional.dropout",
"torch.nn.BatchNorm2d",
"torch.nn.functional.adaptive_avg_pool2d",
"torch.no_grad",
"torch.nn.functional.relu",
"torch.unsqueeze",
"torch.nn.Co... | 1.5.1 | GreenCUBIC/GasBotty | 158f5991201c80bf4cbbbb9deabc9954ff19bbb1 |
1.7 | import sys
import argparse
import torch
from ModelLoader import load_model
def main():
parser = argparse.ArgumentParser(prog='gentool')
parser.add_argument("--training", action='store_true', help="Whether or not to start the model in training mode.")
parser.add_argument("--model", type=str, help="The mo... | [
"torch.set_default_tensor_type"
] | 1.7.1 | TheDudeFromCI/generative-toolkit | 4a0aed629b72e6eea807dadc460afa90dd330f7f |
1.4 | import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
from torch.utils import model_zoo
from torchvision import models
from utils.spp_layer import spatial_pyramid_pool
class CIS_VGGBN(nn.Module):
def __init__(self, backbone='vgg16_bn', pretrained=True, freeze_backbone=Fal... | [
"torch.nn.Linear",
"torch.cat",
"torch.nn.Softmax",
"torch.nn.Sequential",
"torch.nn.BatchNorm2d",
"torch.nn.ReLU",
"torch.nn.Conv2d"
] | 1.4.0 | rfww/EfficientChangeDetection | 42d466c56ed262980c27fd6cde6ffe65314e638f |
1.4 | import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
import os
from torch.utils import model_zoo
from torchvision import models
class SegNetEnc(nn.Module):
def __init__(self, in_channels, out_channels, scale, num_layers):
super().__init__()
... | [
"torch.cat",
"torch.nn.Sequential",
"torch.nn.BatchNorm2d",
"torch.nn.Upsample",
"torch.nn.ReLU",
"torch.nn.Conv2d"
] | 1.4.0 | rfww/EfficientChangeDetection | 42d466c56ed262980c27fd6cde6ffe65314e638f |
1.0 | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# 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 ag... | [
"torch.no_grad",
"torch.from_numpy"
] | 1.0 | wilcoln/transformers | 6331d4fe59e85840bb5693837e791f4caedcd53b |
1.4 | import kornia
import kornia.testing as utils # test utils
from test.common import device
import torch
from torch.autograd import gradcheck
from torch.testing import assert_allclose
import pytest
class TestRgbToRgba:
def test_smoke(self, device):
data = torch.rand(3, 4, 4).to(device)
assert korni... | [
"torch.rand",
"torch.Tensor",
"torch.tensor",
"torch.testing.assert_allclose"
] | 1.4.0 | connorlee77/kornia | af5b1f76bedf2a7fc0e0da2386b1be3032b6534f |
1.6 | from typing import Type
import torch
import torch.nn
import torch.distributions.distribution
import n3ml.population
import n3ml.learning
class Synapse(torch.nn.Module):
def __init__(self,
source: n3ml.population.Population,
target: n3ml.population.Population,
w... | [
"torch.zeros",
"torch.matmul"
] | 1.6.0 | chatterboy/n3ml | 28b4e25a277e55e734e6054e8239237a5ff7d1f1 |
1.5 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import datetime
import json
import random
import time
from pathlib import Path
import numpy as np
import torch
from torch.utils.data import DataLoader, DistributedSampler
import datasets
import util.misc as utils
from datasets impo... | [
"torch.device",
"torch.utils.data.SequentialSampler",
"torch.manual_seed",
"torch.utils.data.DataLoader"
] | 1.5.0 | leimao/detr | cd88c4ea01257831ac677b6268e1aef7cd37eca4 |
1.10 | # Copyright 2020 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# Adapted by Florian Lux 2021
import numpy as np
import pyworld
import torch
import torch.nn.functional as F
from scipy.interpolate import interp1d
from Utility.utils import pad_list
class Dio(torch.nn.Mo... | [
"torch.stack",
"torch.tensor"
] | 1.10.1 | Adamantcat/IMS-Toucan | 1ae02026a2a3233aaacc9d3a63d391918a2581e8 |
1.0 | import csv
import os
import os.path
import shutil
import tempfile
import unittest
from unittest import mock
import torch
import pandas as pd
from jiant import evaluate
import jiant.tasks.tasks as tasks
from jiant.models import MultiTaskModel
from jiant.__main__ import evaluate_and_write
from jiant.allennlp_mods.numer... | [
"torch.LongTensor",
"torch.Tensor"
] | 1.0 | YianZhang/jiant-v1-legacy-online-code | b6b1066de7cdbe1b95ca1ae3de6989d07b2e9629 |
1.0 | import unittest
import torch
from jiant.metrics.nli_metrics import NLITwoClassAccuracy
class TestNLIMetric(unittest.TestCase):
def test_two_class_acc_w_two_class_data_and_model(self):
nli_scorer = NLITwoClassAccuracy()
# Note: predictions are of shape num_batches x batch_size x num_classes
... | [
"torch.Tensor"
] | 1.0 | YianZhang/jiant-v1-legacy-online-code | b6b1066de7cdbe1b95ca1ae3de6989d07b2e9629 |
1.8 | import torch
from ...utils import box_coder_utils, box_utils
from .point_head_template import PointHeadTemplate
class PointIntraPartOffsetHead(PointHeadTemplate):
"""
Point-based head for predicting the intra-object part locations.
Reference Paper: https://arxiv.org/abs/1907.03670
From Points to Part... | [
"torch.sigmoid"
] | 1.8 | Gltina/OpenPCDet | e32dc7f8f903a3f0e1c93effc68d74dbe16766e2 |
1.8 | import os
import torch
import torch.nn as nn
from ...ops.iou3d_nms import iou3d_nms_utils
from .. import backbones_2d, backbones_3d, dense_heads, roi_heads
from ..backbones_2d import map_to_bev
from ..backbones_3d import pfe, vfe
from ..model_utils import model_nms_utils
class Detector3DTemplate(nn.Module):
def... | [
"torch.zeros",
"torch.device",
"torch.cat",
"torch.sigmoid",
"torch.arange",
"torch.max",
"torch.LongTensor",
"torch.load"
] | 1.8 | Gltina/OpenPCDet | e32dc7f8f903a3f0e1c93effc68d74dbe16766e2 |
1.3 | """ Training augmented model """
import os
import torch
import torch.nn as nn
import numpy as np
from tensorboardX import SummaryWriter
from config import AugmentConfig
import utils
from models.augment_cnn import AugmentCNN
import copy
config = AugmentConfig()
device = torch.device("cuda")
# tensorboard
writer = Su... | [
"torch.device",
"torch.sigmoid",
"torch.cuda.manual_seed_all",
"torch.isnan",
"torch.optim.lr_scheduler.CosineAnnealingLR",
"torch.no_grad",
"torch.optim.SGD",
"torch.manual_seed",
"torch.cuda.set_device",
"torch.utils.data.DataLoader",
"torch.isinf",
"torch.utils.data.Subset",
"torch.div",
... | 1.3 | jkooy/darts_ignoring | 7ae7c769cffe81441af9e1a0e0b92552245ae1d1 |
1.8 | # CLI interface to decode task
import argparse
import sys
from argparse import ArgumentDefaultsHelpFormatter as ArgFormatter
import torch
from pathlib import Path
from rtg import TranslationExperiment as Experiment, log, yaml
from rtg.module.decoder import Decoder, ReloadEvent
from rtg.utils import IO
def parse_args... | [
"torch.set_grad_enabled"
] | 1.8.0 | XuezheMax/rtg | a4bfc81dc1874c6f43765eb588d1026a2296aa2f |
0.19 | import os
import os.path
import sys
sys.path.append('../..')
from utils.preprocessSMD import load_SMD
from transformers import (AdamW,WEIGHTS_NAME, CONFIG_NAME)
from utils.hugging_face import load_model,get_parser,top_filtering, SPECIAL_TOKENS, add_special_tokens_, average_distributed_scalar, make_logdir, build_input_... | [
"torch.cuda.manual_seed",
"torch.random.manual_seed",
"torch.multinomial",
"torch.tensor",
"torch.nn.functional.softmax",
"torch.topk"
] | 0.19.5 | HLTCHKUST/ke-dialogue | cb73237889860adedcfd381b28813feb267cef81 |
1.10 | import datetime
import os
import pprint
import time
import threading
import torch as th
from types import SimpleNamespace as SN
from utils.logging import Logger
from utils.timehelper import time_left, time_str
from os.path import dirname, abspath
from learners import REGISTRY as le_REGISTRY
from runners import REGISTR... | [
"torch.cuda.is_available"
] | 1.10.0 | hex-plex/GNN-MARL | ebe964a4eb749fd8d2780af18aead85e342d2988 |
1.7 | import torch.nn.functional as F
import torch
import json
# Setting the seed for Torch
import yaml
from fltk.nets import Cifar10CNN, FashionMNISTCNN, Cifar100ResNet, FashionMNISTResNet, Cifar10ResNet, Cifar100VGG
SEED = 1
torch.manual_seed(SEED)
class Arguments:
def __init__(self, logger):
self.logger ... | [
"torch.manual_seed"
] | 1.7.1 | tudelft-eemcs-dml/fltk-testbed-gr-5 | 72afa24a37cd1f8f5f49665c83ccbd730d76ad21 |
1.0 | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 License.
# You may obtain a cop... | [
"torch.distributed.get_world_size",
"torch.utils.data.RandomSampler",
"torch.cuda.is_available",
"torch.nn.DataParallel",
"torch.distributed.init_process_group",
"torch.manual_seed",
"torch.tensor",
"torch.utils.data.DataLoader",
"torch.distributed.get_rank",
"torch.device",
"torch.cuda.manual_s... | 1.0.0 | nabihach/pytorch-transformers | 4c99a4eda5459e36ebb45355fa789bb6cc0bce71 |
1.0 | import collections
from typing import Iterable, List
import torch
from torch import nn as nn
from torch.distributions import Normal
from torch.nn import ModuleList
from scvi.models.utils import one_hot
def reparameterize_gaussian(mu, var):
return Normal(mu, var.sqrt()).rsample()
class FCLayers(nn.Module):
... | [
"torch.nn.Linear",
"torch.cat",
"torch.nn.Dropout",
"torch.nn.Softmax",
"torch.is_tensor",
"torch.distributions.Normal",
"torch.softmax",
"torch.nn.ReLU",
"torch.nn.BatchNorm1d",
"torch.exp"
] | 1.0.1 | lgyzngc/scvi | b4472e7d02a3889c405078cdd7ab4d4378309c2c |
1.4 | import torch
from speechjoey.embeddings import Embeddings
from .test_helpers import TensorTestCase
class TestEmbeddings(TensorTestCase):
def setUp(self):
self.emb_size = 10
self.vocab_size = 11
self.pad_idx = 1
seed = 42
torch.manual_seed(seed)
def test_size(self):
... | [
"torch.Size",
"torch.rand",
"torch.zeros",
"torch.manual_seed",
"torch.index_select",
"torch.Tensor"
] | 1.4.0 | B-Czarnetzki/speechjoey | 97b0b98137bfaf0ffe15db9de6b38e37c7fb5572 |
1.4 | from torch.nn import GRU, LSTM
import torch
from torch import nn
import numpy as np
from speechjoey.encoders import RecurrentEncoder
from .test_helpers import TensorTestCase
from speechjoey.model import build_model
from speechjoey.vocabulary import Vocabulary
import copy
class TestModelInit(TensorTestCase):
def... | [
"torch.manual_seed",
"torch.zeros",
"torch.ones"
] | 1.4.0 | B-Czarnetzki/speechjoey | 97b0b98137bfaf0ffe15db9de6b38e37c7fb5572 |
1.5 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Modules to compute the matching cost and solve the corresponding LSAP.
"""
import torch
from scipy.optimize import linear_sum_assignment
from torch import nn
from util.box_ops import box_cxcywh_to_xyxy, generalized_box_iou
from IPython import e... | [
"torch.cat",
"torch.no_grad",
"torch.as_tensor",
"torch.cdist"
] | 1.5.0 | xieenze/detr | 13bdf0bf59fead571cd793a01eae50e7620fc6a2 |
1.8 | import torch
import torch.nn.functional as F
import cv2 as cv
import numpy as np
import os
from glob import glob
from icecream import ic
from scipy.spatial.transform import Rotation as Rot
from scipy.spatial.transform import Slerp
import pickle
import diffoptics as optics
from diffoptics import Rays
import sys
# Path... | [
"torch.isnan",
"torch.ones",
"torch.eye",
"torch.meshgrid",
"torch.sum",
"torch.randint",
"torch.tensor",
"torch.zeros",
"torch.device",
"torch.linspace",
"torch.matmul",
"torch.arange",
"torch.from_numpy",
"torch.ones_like",
"torch.linalg.norm"
] | 1.8.0 | magis-slac/NeuS | f3ef3c089b2076ea8d73679bf37a94ef44a08939 |
1.0 | """AttentionWalk class."""
import torch
import numpy as np
import pandas as pd
from tqdm import trange
from utils import read_graph, feature_calculator, adjacency_opposite_calculator
class AttentionWalkLayer(torch.nn.Module):
"""
Attention Walk Layer.
For details see the paper.
"""
def __init__(se... | [
"torch.sigmoid",
"torch.FloatTensor",
"torch.mm",
"torch.abs",
"torch.nn.functional.softmax",
"torch.nn.init.uniform_",
"torch.Tensor",
"torch.mean",
"torch.sum"
] | 1.0.0 | erdiolmezogullari/AttentionWalk | d8c8297018374d965c0a024c3f1833f54347504e |
1.1 | import torch
import torch.nn as nn
import torch.nn.functional as F
class DummyNet(nn.Module):
def __init__(self):
super(DummyNet, self).__init__()
self.conv1 = nn.Conv2d(3, 10, kernel_size=5, padding=2)
self.conv2 = nn.Conv2d(10, 5, kernel_size=5, padding=2)
self.softmax = nn.Softma... | [
"torch.nn.Conv2d",
"torch.nn.Softmax2d"
] | 1.1.0 | LendelTheGreat/weak-segmentation | 0ff6015f1af741cfb50ef8fb6f55cea822f68f7a |
1.6 | from abc import ABCMeta, abstractmethod
from typing import Any, Optional, Sequence
import numpy as np
import torch
from torch.optim import Optimizer
from ...augmentation import AugmentationPipeline
from ...gpu import Device
from ...models.builders import (
create_categorical_policy,
create_squashed_normal_pol... | [
"torch.no_grad"
] | 1.6.0 | YangRui2015/d3rlpy | da778b2a2b0afbafe25395296baecd0d4d0cd0d5 |
1.6 | import gym
import numpy as np
import pytest
import torch
from d3rlpy.dataset import Episode, MDPDataset
from d3rlpy.preprocessing import (
MinMaxScaler,
PixelScaler,
StandardScaler,
create_scaler,
)
@pytest.mark.parametrize("scaler_type", ["pixel", "min_max", "standard"])
def test_create_scaler(scale... | [
"torch.rand",
"torch.randint",
"torch.all",
"torch.tensor"
] | 1.6.0 | YangRui2015/d3rlpy | da778b2a2b0afbafe25395296baecd0d4d0cd0d5 |
1.7 | # -*- coding: utf-8 -*-
"""CBOW Embedding"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
from models.base_model import BaseModel
from models.networks.cbow_embedder import Net as CBOW
class Net(nn.Module):
"""Network for CBOW"""
""" CBOW """
... | [
"torch.nn.Linear",
"torch.device",
"torch.nn.Dropout",
"torch.nn.Softmax",
"torch.cuda.is_available",
"torch.load",
"torch.sum"
] | 1.7.1 | Piko-Piko-Pon-Taro/navict-recommender | 7eeaf0f77e500c1c0ecb15f9613aa08c2ef5c83c |
1.7 | import torch.nn as nn
class Network(nn.Module):
def __init__(self):
super().__init__()
self.layer1 = nn.Sequential(
nn.Conv2d(in_channels=1, out_channels=8,
kernel_size=5, stride=1, padding=2),
nn.BatchNorm2d(num_features=8),
nn.ReLU(),
... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.nn.MaxPool2d",
"torch.nn.BatchNorm2d",
"torch.nn.ReLU",
"torch.nn.Conv2d",
"torch.nn.BatchNorm1d"
] | 1.7.0 | priyavrat-misra/fashion-mnist | 9e9d18612b7556dbff5849be87cb35c296993d9e |
1.1 | from __future__ import print_function, absolute_import
import argparse
import os.path as osp
import random
import numpy as np
import sys
from sklearn.cluster import KMeans
from sklearn.preprocessing import normalize
import torch
from torch import nn
from torch.backends import cudnn
from torch.utils.data import DataLo... | [
"torch.optim.Adam",
"torch.manual_seed",
"torch.nn.DataParallel"
] | 1.1.0 | Dingyuan-Zheng/ctf-UDA | 3e3c67f68d7eb0b52a16a259e5a77e153062c4fd |
1.6 | import torch
from torch import nn
from transformers import BertModel, ElectraModel
from transformers.models.bert.modeling_bert import BertLayer
from capreolus import ConfigOption, Dependency
from capreolus.reranker import Reranker
class PTParade_Class(nn.Module):
def __init__(self, extractor, config, *args, **kw... | [
"torch.nn.Linear",
"torch.zeros",
"torch.nn.Parameter",
"torch.nn.init.normal_",
"torch.tensor"
] | 1.6.0 | nimasadri11/capreolus | 27b081ec1a37d2af6afa6b61eb1cb7cc4ec9db1c |
1.7 |
import os
from imageio import imread, imsave
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
def plot_text(txt, size=224):
fig = plt.figure(figsize=(1,1), dpi=size)
fontsize = size//len(txt) if len(txt) < 15 else 8
plt.text(0.5, 0.5, txt, fontsize=fontsize,... | [
"torch.min",
"torch.max",
"torch.load"
] | 1.7.1 | Adamkomar95/gans-clip-pw | 14694abd3a793b3e0fdfed76e2e12908e91ea484 |
1.7 | import torch
import math
from torch_geometric.nn.pool import fps
from lightconvpoint.knn import knn
import importlib
knn_c_func_spec = importlib.util.find_spec('lightconvpoint.knn_c_func')
if knn_c_func_spec is not None:
knn_c_func = importlib.util.module_from_spec(knn_c_func_spec)
knn_c_func_spec.loader.exec... | [
"torch.arange"
] | 1.7.1 | valeoai/3DGenZ | 3368585e10f127f7a0d71af98994a6cff5235dab |
0.4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 19 18:40:39 2020
@author: kratochvila
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from base.base_net import BaseNet
class MY_LeNet(BaseNet):
def __init__(self):
super().__init__()
self.rep_dim = 1... | [
"torch.nn.Linear",
"torch.sigmoid",
"torch.nn.MaxPool2d",
"torch.nn.BatchNorm2d",
"torch.nn.ConvTranspose2d",
"torch.nn.Conv2d",
"torch.nn.BatchNorm1d",
"torch.nn.init.calculate_gain",
"torch.nn.functional.leaky_relu"
] | 0.4.1 | LukasKratochvila/Deep-SVDD-PyTorch | a94bd9b6be4d953706daf969b061ddf55d6cbf4c |
1.6 | import unittest
from onmt.translate import GeneratorLM
import torch
class TestGeneratorLM(unittest.TestCase):
def test_split_src_to_prevent_padding_target_prefix_is_none_when_equal_size( # noqa: E501
self,
):
src = torch.randint(0, 10, (5, 6))
src_lengths = 5 * torch.ones(5)
(... | [
"torch.randint",
"torch.ones"
] | 1.6.0 | l-k-11235/OpenNMT-py | 4815f07fcd482af9a1fe1d3b620d144197178bc5 |
1.6 | import torch
class PenaltyBuilder(object):
"""Returns the Length and Coverage Penalty function for Beam Search.
Args:
length_pen (str): option name of length pen
cov_pen (str): option name of cov pen
Attributes:
has_cov_pen (bool): Whether coverage penalty is None (applying it
... | [
"torch.zeros"
] | 1.6.0 | l-k-11235/OpenNMT-py | 4815f07fcd482af9a1fe1d3b620d144197178bc5 |
1.0 | from torch import nn
class PositionWise(nn.Module):
def __init__(self, dim_m, dim_i, dropout=0.1):
"""Position-wise Feed-Forward Network.
Args:
dim_m (int): input and output dimension.
dim_i (int): inner dimension.
dropout (float, optional): dropout probability... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.nn.LayerNorm",
"torch.nn.ReLU"
] | 1.0.0 | khucnam/Efflux_TransVAE | 7da1cc614f016d5520648f4853e34e2362181aa7 |
1.4 | #!/usr/bin/env python3
# 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 copy
import shutil
import tempfile
import unittest
from test.generic.config_utils import get_fast_test_task_conf... | [
"torch.cuda.is_available"
] | 1.4 | jlin27/ClassyVision-1 | 113ddb0b66471eb84add9af53751d9067786a7f0 |
1.6 | import os
from pytorch_lightning import LightningDataModule
from torch.utils.data import DataLoader
from pl_bolts.datasets.imagenet_dataset import UnlabeledImagenet
from pl_bolts.transforms.dataset_normalizations import imagenet_normalization
from pl_bolts.utils import _TORCHVISION_AVAILABLE
from pl_bolts.utils.warni... | [
"torch.utils.data.DataLoader"
] | 1.6 | btwardow/pytorch-lightning-bolts | 4a7b6ffe0fcbeee37f8bac6af1e926469b2052bf |
1.8 | import torch.nn as nn
import torch.nn.functional as F
import torch
def get_loss(loss_type):
if loss_type == 'focal_loss':
return FocalLoss(ignore_index=255, size_average=True)
elif loss_type == 'cross_entropy':
return nn.CrossEntropyLoss(ignore_index=255, reduction='mean')
class FocalLoss(nn... | [
"torch.nn.functional.binary_cross_entropy_with_logits",
"torch.nn.functional.one_hot",
"torch.log_softmax",
"torch.softmax",
"torch.logsumexp",
"torch.sum",
"torch.mean",
"torch.nn.functional.cross_entropy",
"torch.tensor",
"torch.zeros_like",
"torch.nn.functional.nll_loss",
"torch.exp",
"to... | 1.8.1 | edornd/satellite-mib | a4423dc866ecfb77dc62548764917c048006dd8a |
0.4 | import os
import sys
import yaml
import time
import shutil
import torch
import random
import argparse
import datetime
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
# import torchvision.models as models
# import torchvision
import matplotlib.pyplot as plt
import matplotlib.cm as c... | [
"torch.cuda.empty_cache",
"torch.cuda.is_available",
"torch.no_grad",
"torch.load"
] | 0.4.1 | RogerZhangzz/CAG_UDA | 422f99e2e0a5cb26a40d4f17ee5832f81580f7f0 |
0.4 | import os
import abc
import sys
from copy import deepcopy
from functools import reduce
import numpy as np
import torch
from torchvision import utils as vutils
from tqdm.autonotebook import tqdm
from autokeras.constant import Constant
from autokeras.utils import get_device
class ModelTrainerBase(abc.ABC):
def __i... | [
"torch.no_grad",
"torch.full",
"torch.load",
"torch.randn"
] | 0.4.1 | wpsliu123/AUTOKERAS | 172fb3cf705126e4c3d86b41292463e30ecf3c15 |
1.6 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
class MLPRepresentation(nn.Module):
"""
Deep Q network.
Choose multi-layer full connection with dropout as the basic network architecture.
"""
def __init__(self, name: str, input_dim: ... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.nn.Sequential",
"torch.nn.LeakyReLU",
"torch.cuda.is_available"
] | 1.6.0 | zhawan/maro | d8c98deea4296cdcb90efd1fb59bc571cec3a2ef |
1.4 | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and 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 License.
# You may obtain a copy of the License... | [
"torch.nn.Linear",
"torch.nn.Dropout",
"torch.cat",
"torch.nn.LayerNorm",
"torch.nn.Softmax",
"torch.arange",
"torch.nn.CrossEntropyLoss",
"torch.ones",
"torch.from_numpy",
"torch.matmul",
"torch.nn.Embedding"
] | 1.4.0 | kimhyoil/KoGPT2_Ai_Eassay | da7d160f6815dc8ec3dfd635495978409c2a897c |
1.2 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
''' Utilities file
This file contains utility functions for bookkeeping, logging, and data loading.
Methods which directly affect training should either go in layers, the model,
or train_fns.py.
'''
from __future__ import print_function
import sys
import os
import numpy a... | [
"torch.cat",
"torch.cuda.manual_seed",
"torch.stack",
"torch.randperm",
"torch.eye",
"torch.nn.parallel.data_parallel",
"torch.norm",
"torch.manual_seed",
"torch.randint",
"torch.utils.data.DataLoader",
"torch.tensor",
"torch.zeros",
"torch.linspace",
"torch.nn.ReLU",
"torch.arange",
"... | 1.2.0 | liuqk3/BigGAN-PyTorch | 9b4491f5d68f34a1fe55bc0e8171fa3d3ad7bb08 |
1.6 | import logging
from typing import List, Dict, Any, Optional, TYPE_CHECKING
import torch
from allennlp.training.callbacks.callback import TrainerCallback
from allennlp.training.util import get_train_and_validation_metrics
from allennlp.data import TensorDict
if TYPE_CHECKING:
from allennlp.training.trainer import... | [
"torch.set_printoptions"
] | 1.6.0 | jbrry/allennlp | d906175d953bebcc177567ec0157220c3bd1b9ad |
1.6 | # The MIT License
#
# Copyright (c) 2020 Vincent Liu
#
# 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, mer... | [
"torch.nn.Sequential",
"torch.nn.AvgPool2d",
"torch.nn.Tanh",
"torch.nn.LeakyReLU",
"torch.ones",
"torch.nn.ReLU",
"torch.nn.Upsample",
"torch.nn.Conv2d",
"torch.nn.ReflectionPad2d",
"torch.nn.InstanceNorm2d",
"torch.nn.AdaptiveAvgPool2d"
] | 1.6.0 | vliu15/munit | 5789d96590519d729f89c9501eba7692fa7054ef |
0.1 | # -*- coding: utf-8 -*-
import os
from glob import glob
from os.path import join
from datetime import datetime
import torch
import torchvision
import transformers
import more_itertools
import numpy as np
import torch.nn.functional as F
import matplotlib.pyplot as plt
import torchvision.transforms as T
from tqdm.auto i... | [
"torch.zeros",
"torch.cat",
"torch.stack",
"torch.unique",
"torch.no_grad",
"torch.ones",
"torch.multinomial",
"torch.nn.functional.cross_entropy",
"torch.nn.functional.softmax",
"torch.exp",
"torch.where"
] | 0.1.3 | WildGenie/ru-dolph | c80a320a60dcb60ccb66b86c3421e16e33235d97 |
1.7 | import os
import json
import torch
import onir
from onir import util, spec, predictors, datasets
from onir.interfaces import trec, plaintext
@predictors.register('reranker')
class Reranker(predictors.BasePredictor):
name = None
@staticmethod
def default_config():
return {
'batch_size'... | [
"torch.is_tensor",
"torch.no_grad"
] | 1.7.1 | tgeral68/OpenNIR | 225b26185bd67fdc00f24de3ef70d35768e22243 |
1.6 | import numpy as np
import torch
import pytest
import copy
from unittest.mock import Mock
from d3rlpy.algos.torch.utility import soft_sync, hard_sync
from d3rlpy.algos.torch.utility import set_eval_mode, set_train_mode
from d3rlpy.algos.torch.utility import freeze, unfreeze
from d3rlpy.algos.torch.utility import torch_... | [
"torch.nn.Linear",
"torch.tensor",
"torch.allclose"
] | 1.6.0 | alxlampe/d3rlpy | af7e6bd018a51f95138d121f59c50dc36ec87e3a |
1.0 | # coding=utf-8
# Copyright 2020-present 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 ap... | [
"torch.distributed.get_world_size",
"torch.cat",
"torch.utils.data.sampler.RandomSampler",
"torch.utils.data.dataloader.DataLoader",
"torch.cuda.amp.autocast",
"torch.no_grad",
"torch.nn.parallel.DistributedDataParallel",
"torch.utils.data.sampler.SequentialSampler",
"torch.tensor",
"torch.utils.d... | 1.0 | rmroczkowski/transformers | c988db5af2a5f1ccfcb5ad19bd735b6a77516637 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.