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.1
import configargparse as cfargparse import os import torch import onmt.opts as opts from onmt.utils.logging import logger class ArgumentParser(cfargparse.ArgumentParser): def __init__( self, config_file_parser_class=cfargparse.YAMLConfigFileParser, formatter_clas...
[ "torch.cuda.is_available" ]
1.1
ACL2020-Submission/ACL2020
2a3d6e26d22c650cad823c68b65ee315aa1fe22c
1.4
import time from typing import Optional, Dict import torch from torch import nn, optim from torch.utils.data import DataLoader from torch.nn.utils.rnn import pack_padded_sequence from utils import TensorboardWriter, AverageMeter, save_checkpoint, accuracy, \ clip_gradient, adjust_learning_rate from metrics import ...
[ "torch.no_grad", "torch.nn.utils.rnn.pack_padded_sequence", "torch.max" ]
1.4.0
Renovamen/Image-Captioning
de8d4f553a22e967fa56a01d5b4a2206b9431771
0.3
""" Baseline CNN, losss function and metrics Also customizes knowledge distillation (KD) loss function here """ import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class Flatten(nn.Module): def forward(self, input): return input.view(input.size(0), -1) """ This is t...
[ "torch.nn.Linear", "torch.nn.BatchNorm2d", "torch.nn.functional.log_softmax", "torch.nn.Conv2d", "torch.nn.BatchNorm1d", "torch.nn.functional.cross_entropy", "torch.nn.KLDivLoss", "torch.nn.functional.softmax", "torch.nn.functional.max_pool2d", "torch.nn.CrossEntropyLoss" ]
0.3.0
eungbean/knowledge-distillation-cifar10
683379804c8724d097a845cee85f130b6767dbd7
1.0
import torch from torch import nn, Tensor from typing import Union, Tuple, List, Iterable, Dict from ..SentenceTransformer import SentenceTransformer import logging class TripleSoftmaxLoss(nn.Module): def __init__(self, model: SentenceTransformer, sentence_embedding_dimension: int...
[ "torch.nn.Linear", "torch.cosine_similarity", "torch.cat", "torch.nn.ReLU", "torch.abs", "torch.nn.CrossEntropyLoss" ]
1.0.1
jaimeenahn/COVID-sentence-bert
2f47d116f7d9b774946fbf3c0724b721d1b88225
1.6
import os import sys sys.path.append(os.getcwd()) import numpy as np import torch import flow from utils import cdfDiscreteLogitstic, cdfMixDiscreteLogistic from utils import logDiscreteLogistic, logMixDiscreteLogistic nbins = 4096 _bins = torch.arange(-nbins // 2, nbins // 2).reshape(-1, 1, 1, 1, 1) decimal = flow....
[ "torch.arange", "torch.tensor" ]
1.6.0
li012589/NeuralWavelet
6e593ded5cb4ae80579cbf56eb9c346d808669cb
1.6
# Source: https://gist.github.com/redknightlois/c4023d393eb8f92bb44b2ab582d7ec20 from torch.optim.optimizer import Optimizer import torch import math class Ralamb(Optimizer): def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=1e-4): defaults = dict(lr=lr, betas=betas, eps=eps...
[ "torch.zeros_like" ]
1.6.0
achaiah/pywick
9d663faf0c1660a9b8359a6472c164f658dfc8cb
1.6
""" PyTorch MADGRAD optimizer MADGRAD: https://arxiv.org/abs/2101.11075 Code from: https://github.com/facebookresearch/madgrad """ # 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 math...
[ "torch.zeros_like", "torch.no_grad", "torch.clone", "torch.enable_grad" ]
1.6.0
achaiah/pywick
9d663faf0c1660a9b8359a6472c164f658dfc8cb
1.4
# 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.isfinite" ]
1.4
neggert/pytorch-lightning
8208c330eb1a4e8cca243ee525882854dd366921
1.4
import os import sys import numpy as np import random import math from PIL import Image, ImageOps, ImageFilter import torch import torch.utils.data as data import torchvision.transforms as transform from .base import BaseDataset class NYUv2Segmentation(BaseDataset): BASE_DIR = 'nyuv2' NUM_CLAS...
[ "torch.from_numpy" ]
1.4.0
etmwb/cvsegmentation
c283a79f4cf4e78d057f598944b1c252f6533f00
1.8
from __future__ import absolute_import import os from collections import namedtuple import time from torch.nn import functional as F from baseline.fast_rcnn.model.utils.creator_tool import AnchorTargetCreator, ProposalTargetCreator from torch import nn import torch as t from baseline.fast_rcnn.utils import array_tool ...
[ "torch.zeros", "torch.device", "torch.arange", "torch.save", "torch.load", "torch.nn.CrossEntropyLoss" ]
1.8.1
ITMO-NSS-team/LightObjRecEnsembler
1375400f0a681aefdd3ab484e828257fd7aed318
1.6
import copy from functools import wraps import numpy as np import wandb import torchvision import torch import torch.nn.functional as F from kornia import enhance, filters from torchvision.transforms import RandomApply, RandomChoice from atariari.methods.utils import EarlyStopping from torch import nn from torch.u...
[ "torch.nn.Linear", "torch.nn.functional.normalize", "torch.rand", "torch.stack", "torch.no_grad", "torch.nn.ReLU", "torch.nn.BatchNorm1d", "torch.cuda.is_available" ]
1.6
mariodoebler/byol-pytorch
4c1b6d27d86e0a9a39ecef6f6888038355943cd0
1.4
# Copyright 2020 MONAI Consortium # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, s...
[ "torch.load" ]
1.4
BRAINSia/MONAI
04e1c345fc840f5a1b6504ee5857d5a9feb27d84
0.6
import torch import torch.nn as nn import torch.nn.functional as F from segmentation_models_pytorch.base import modules as md class DecoderBlock(nn.Module): def __init__( self, in_channels, skip_channels, out_channels, use_batchnorm=True, attention_type=None, )...
[ "torch.nn.functional.interpolate", "torch.cat", "torch.nn.Identity", "torch.nn.ModuleList" ]
0.6.3
navivokaj/segmentation_models.pytorch
5dbb5f6733515097cecc93f078c09e59ccbeb0c0
1.6
import math import torch import torch.nn as nn import torch.nn.functional as F from .base import Loss class AdaCos(Loss): """PyTorch implementation of AdaCos. See Ref[1] for paper This implementation is different from the most open-source implementations in following ways: 1) expects raw logits of size ...
[ "torch.zeros", "torch.cos", "torch.nn.functional.normalize", "torch.no_grad", "torch.nn.init.xavier_uniform_", "torch.zeros_like" ]
1.6
YevheniiSemendiak/pytorch-tools
11f895ac7af796ca786a3d94bb46de70d7fce87a
1.5
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch from detr.models.backbone import Backbone, Joiner from detr.models.detr import DETR, PostProcess from detr.models.position_encoding import PositionEmbeddingSine from detr.models.segmentation import DETRsegm, PostProcessPanoptic from de...
[ "torch.hub.load_state_dict_from_url" ]
1.5.0
kcetskcaz/detr_package
0f5cad16c72ec37d7b596d37e12dc32cfb5ef6aa
1.5
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ DETR model and criterion classes. """ import torch import torch.nn.functional as F from torch import nn from detr.util import box_ops from detr.util.misc import (NestedTensor, nested_tensor_from_tensor_list, accuracy, get...
[ "torch.nn.Linear", "torch.device", "torch.cat", "torch.stack", "torch.nn.functional.l1_loss", "torch.no_grad", "torch.ones", "torch.full_like", "torch.nn.Conv2d", "torch.full", "torch.distributed.all_reduce", "torch.nn.functional.softmax", "torch.nn.Embedding" ]
1.5.0
kcetskcaz/detr_package
0f5cad16c72ec37d7b596d37e12dc32cfb5ef6aa
1.4
import logging import torch.nn as nn from . import arch as archs logger = logging.getLogger() def build_model(cfg_model): if cfg_model.get('pretrained', False): info = "=> building pre-trained model {}".format(cfg_model['arch']) model = archs.__dict__[cfg_model.arch](pretrained=True) in_...
[ "torch.nn.Linear" ]
1.4
ChaseMonsterAway/vedacls
91657f688dcaf3f9f4c58eb40a8f5c8f34a4bd73
1.10
import os import logging from typing import Dict, Union from datetime import timedelta import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pandas as pd import mlflow import torch import pytorch_lightning as pl import pprint pp = pprint.PrettyPrinter(indent=4) from arnet i...
[ "torch.cat", "torch.stack", "torch.isnan", "torch.tensor" ]
1.10.0
ZeyuSun/flare-prediction-smarp
ad60163eb83b47ba39e898beb387031d349e2ed6
1.4
import numpy as np import torch import torch.nn as nn import torch.nn.functional as functional from .noisy_linear import NoisyLinear class Enet(nn.Module): def __init__(self) -> None: super(Enet, self).__init__() return def get_max_action(self, observation: torch.Tensor) -> int: """ ...
[ "torch.nn.Linear", "torch.nn.init.xavier_uniform_", "torch.argmax" ]
1.4.0
hbutsuak95/iv_rl
0f72a8f077a238237027ea96b7d1160c35ac9959
1.1
"""Trains a hypergraph machine on MNIST and generates Figure 1 panels b and c of Discrete and continuous learning machines """ import numpy as np import torch import torch.nn.functional as F from torchvision import datasets, transforms from torch.optim.lr_scheduler import StepLR from hypergraph_machines.hypergraph_mach...
[ "torch.device" ]
1.1.0
Veos-Digital/hypergraph_machines
0d24cd89766c45c6c1ffb2967438ef82288a5d3c
1.4
import time import copy import pickle import warnings import numpy as np import scipy.sparse as sp import torch import torch.nn.functional as F from sklearn.metrics import roc_auc_score, average_precision_score, precision_recall_curve, auc def sparse_to_tuple(sparse_mx): if not sp.isspmatrix_coo(sparse_mx): ...
[ "torch.nn.functional.binary_cross_entropy_with_logits", "torch.sigmoid", "torch.no_grad", "torch.exp" ]
1.4.0
coodest/GAug
ef6ab307e3dfd3e9e0a653d385dc1f41963f9ba8
1.1
import torch import torch.nn as nn import torch.nn.functional as F from starter_code.modules.networks import MLP, MinigridCNN from mnist.embedded_mnist import MNIST_CNN class SimpleValueFn(nn.Module): def __init__(self, state_dim, hdim): super(SimpleValueFn, self).__init__() self.value_net = MLP(d...
[ "torch.nn.Linear" ]
1.1.0
mbchang/societal-decision-making
23fd6de4df33f985d360330a9d5a2c29faeb8e52
1.2
# MIT License # # Copyright (C) IBM Corporation 2019 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the "Software"), to deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge...
[ "torch.cuda.is_available", "torch.nn.CrossEntropyLoss", "torch.load" ]
1.2.0
virkt25/adversarial-robustness-toolbox
3cfa6de196cb32a3efafab2ff6bbf44247c9ddbd
1.8
import numpy as np from torch import nn import torch.optim as optim import torch import matplotlib.pyplot as plt import pandas as pd import data_loader as dl import time import copy import utility import yaml import trainer from PIL import Image from os import path Image.MAX_IMAGE_PIXELS = None from scipy.io import sav...
[ "torch.optim.SGD", "torch.cuda.is_available", "torch.optim.lr_scheduler.ReduceLROnPlateau", "torch.nn.CrossEntropyLoss" ]
1.8.1
micqu/hotel-challenge
9373d5bd69a48e22b043b1410a57ec051f63dd45
1.5
""" Copyright (c) 2019-2020 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.zeros", "torch.nn.BatchNorm2d", "torch.ones", "torch.nn.Conv2d", "torch.load", "torch.empty" ]
1.5.0
evgeniya-egupova/nncf
39a3c5b2e5cc7d33723154d2e622d4d7882a99a4
1.5
""" Copyright (c) 2019 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.ReLU", "torch.nn.Conv2d", "torch.nn.BatchNorm2d", "torch.load" ]
1.5.0
evgeniya-egupova/nncf
39a3c5b2e5cc7d33723154d2e622d4d7882a99a4
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.load" ]
1.7
lemairecarl/pytorch-lightning
85304d4672a9ed24a16f7f5b2abaa34148ab86f4
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 contextlib import copy import enum import json import logging import math import multiprocessing as mp import ti...
[ "torch.cuda.amp.autocast", "torch.nn.SyncBatchNorm.convert_sync_batchnorm", "torch.no_grad", "torch.enable_grad", "torch.cuda.device_count", "torch.cuda.is_available", "torch.tensor", "torch.cuda.amp.GradScaler", "torch.distributed.broadcast" ]
1.4
shinianzhihou/ClassyVision
b3f714ef94275b3e9753ab3f3c8256cb852b96fc
1.1
#!/usr/bin/env python """ Translator Class and builder """ from __future__ import print_function import codecs import os import math import torch from tensorboardX import SummaryWriter from others.utils import rouge_results_to_str, test_rouge, tile from translate.beam import GNMTGlobalScorer def build_predictor(ar...
[ "torch.no_grad", "torch.full", "torch.arange" ]
1.1.0
SebastianVeile/PreSumm
780c340e04fd5911badb4a8b2af2284c5cdbb8b5
0.1
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, List, NamedTuple, Tuple import numpy as np import plotly.graph_objs as go import torch from torch import Tenso...
[ "torch.var" ]
0.1.0
facebookresearch/beanmachine
225114d9964b90c3a49adddc4387b4a47d1b4262
0.1
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import inspect import math import operator from types import MethodType from typing import Any, Callable, Dict, List, NoReturn, Optional, S...
[ "torch.__dict__.items", "torch.tensor" ]
0.1.0
facebookresearch/beanmachine
225114d9964b90c3a49adddc4387b4a47d1b4262
1.7
from collections import OrderedDict import torch import torch.nn as nn import numpy as np from torch.nn import functional as F from .SubLayers import MultiHeadAttention, PositionwiseFeedForward class FFTBlock(torch.nn.Module): """FFT Block""" def __init__(self, d_model, n_head, d_k, d_v, d_inner, kernel_si...
[ "torch.nn.BatchNorm1d", "torch.nn.ModuleList", "torch.nn.Conv1d" ]
1.7.1
richarai9/FastSpeech2
d044c00a44cbfa3e1c89a22c8285a374a00e27a9
1.1
import argparse import os import os.path as osp import shutil import tempfile import json import pdb import numpy as np import pickle import pandas as pd import mmcv import torch import torch.distributed as dist from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, l...
[ "torch.norm", "torch.no_grad", "torch.pow", "torch.full", "torch.distributed.barrier", "torch.distributed.broadcast" ]
1.1
ydiller/BalancedGroupSoftmax
6fecf9fbb8ed1f54540787188e212ab39cd2b501
1.3
"""A training script of TD3 on OpenAI Gym Mujoco environments. This script follows the settings of http://arxiv.org/abs/1802.09477 as much as possible. """ import argparse import logging import sys import gym import gym.wrappers import numpy as np import torch from torch import nn import pfrl from pfrl import exper...
[ "torch.nn.Linear", "torch.nn.Tanh", "torch.nn.ReLU" ]
1.3.0
yhisaki/pfrl
d89ddf66201bcfaaae6130bdee704d56ee4b7b76
1.10
# Copyright 2021 solo-learn development team. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to use, # copy, modify, merge, publ...
[ "torch.randn", "torch.mm" ]
1.10.0
xwyzsn/solo-learn
16d021d8053439a3de205337ab2a11d191500b09
1.10
# Copyright 2021 solo-learn development team. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to use, # copy, modify, merge, publ...
[ "torch.nn.Linear", "torch.zeros", "torch.nn.ReLU", "torch.nn.BatchNorm1d", "torch.randn" ]
1.10.0
xwyzsn/solo-learn
16d021d8053439a3de205337ab2a11d191500b09
0.4
import torch.nn as nn import torch.nn.functional as F class RNNAgent(nn.Module): def __init__(self, input_shape, args): super(RNNAgent, self).__init__() self.args = args self.fc1 = nn.Linear(input_shape, args.rnn_hidden_dim) self.rnn = nn.GRUCell(args.rnn_hidden_dim, args.rnn_hidd...
[ "torch.nn.Linear", "torch.nn.GRUCell" ]
0.4.1
halleanwoo/AGMA
a1c4980e05150a9cfa1be338e7c8cbd8ccd6b002
1.0
import unittest import torch from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, BertConfig, BertForSequenceClassification, GlueDataset, GlueDataTrainingArguments, Trainer, TrainingArguments, ) from transformers.adapters.composition import Fuse from transforme...
[ "torch.equal" ]
1.0
AngadSethi/adapter-transformers
b147bba9107a5a561aca28c99f4e4ec2816a6e4f
4
import torch.nn as nn import math import torch import torch.nn.functional as F def conv_bn(inp, oup, stride, k_size=3): return nn.Sequential( nn.Conv2d(inp, oup, k_size, stride, 1, bias=False), nn.BatchNorm2d(oup), nn.PReLU() ) def conv_1x1_bn(inp, oup): return nn.Sequential( ...
[ "torch.cat", "torch.nn.MaxPool2d", "torch.nn.Sequential", "torch.nn.AvgPool2d", "torch.nn.BatchNorm2d", "torch.nn.Conv2d", "torch.nn.PReLU" ]
4
GzuPark/EXTD_Pytorch
e99af10f282d07054c1cf7c4b8c035084daaff78
1.2
import math import torch import torch.nn as nn import torch.nn.functional as F #-------------------------------------------------# # MISH激活函数 #-------------------------------------------------# class Mish(nn.Module): def __init__(self): super(Mish, self).__init__() def forward(self, x): re...
[ "torch.cat", "torch.nn.functional.softplus", "torch.nn.BatchNorm2d", "torch.nn.Conv2d", "torch.load" ]
1.2.0
Arcofcosmos/MyYolov4_Pytorch
14c445503d0fc69b8a8b64ecdc87256ac4c1fce1
1.2
from collections import OrderedDict import torch import torch.nn as nn from nets.CSPdarknet import darknet53 #---------------------------------------------------# # 卷积块 -> 卷积 + 标准化 + 激活函数 # Conv2d + BatchNormalization + LeakyRelu #---------------------------------------------------# def CBL(filter_in, filter_o...
[ "torch.cat", "torch.nn.MaxPool2d", "torch.nn.BatchNorm2d", "torch.nn.LeakyReLU", "torch.nn.Upsample", "torch.nn.Conv2d" ]
1.2.0
Arcofcosmos/MyYolov4_Pytorch
14c445503d0fc69b8a8b64ecdc87256ac4c1fce1
1.6
import torch from utils.distmat import compute_distmat def init_feedback_indices(q, g, device=None): return torch.zeros((q, g), dtype=torch.bool, device=device) def init_feedback_indices_qg(q, g, positive=False, device=None): indices = torch.zeros(q, q + g, dtype=torch.bool, device=device) if positive:...
[ "torch.zeros", "torch.arange" ]
1.6.0
itsnamgyu/reid-metric
437e02ebad510b482f620a293fd8c7baa4f42ad6
1.4
import torch import numpy as np from torch import nn import torch.nn.functional as F class Actor(nn.Module): """For advanced usage (how to customize the network), please refer to :ref:`build_the_network`. """ def __init__(self, preprocess_net, action_shape, hidden_layer_size=128): super().__i...
[ "torch.nn.Linear", "torch.nn.BatchNorm2d", "torch.nn.Conv2d", "torch.tensor" ]
1.4.0
FightingSrain/tianshou
bd9c3c7f8d144448c44a350828b2c5222298bd8e
1.10
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import sys sys.path.append('./') from update import BasicUpdateBlock, SmallUpdateBlock from extractor import BasicEncoder, SmallEncoder from corr import CorrBlock, AlternateCorrBlock from util import bilinear_sampler, coords_grid, u...
[ "torch.nn.functional.unfold", "torch.relu", "torch.split", "torch.softmax", "torch.tanh", "torch.sum" ]
1.10.0
aharley/track_check_repeat
564c3065a758deea11acdcaeea7a187ce376d564
1.3
import torch import os import os.path import shutil import numpy as np import soundfile as sf from pathlib import PurePath from torch import nn from torch.utils.data import DataLoader, random_split from asteroid.data import TimitDataset from asteroid.data.utils import CachedWavSet, RandomMixtureSet, FixedMixtureSet fr...
[ "torch.optim.lr_scheduler.ReduceLROnPlateau", "torch.Generator", "torch.utils.data.DataLoader" ]
1.3.0
flyingleafe/asteroid
1c3c68ffc83f4b0bf7b00893083e4eff1f577b88
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. """ from collections import defaultdict from pathlib import Path import numpy as np import pandas as pd import pytorch_lightning as pl import to...
[ "torch.utils.data.sampler.RandomSampler", "torch.utils.data.DataLoader", "torch.Tensor" ]
1.4.0
ygrepo/fastMRI
cb9a2019f1833bfffe4969023113189abcbad0f7
1.8
# -*- coding: utf-8 -*- """ Created on Mon Jun 7 14:34:39 2021 @author: Eric """ #%% from model import Unet from utils import random_fliplr, random_crop import torch import torch.nn as nn import torch.optim as optim from torchvision import transforms from torch.utils.data import DataLoader from torch.utils.data impo...
[ "torch.cat", "torch.nn.MSELoss", "torch.no_grad", "torch.cuda.empty_cache", "torch.cuda.is_available", "torch.utils.data.DataLoader", "torch.utils.tensorboard.SummaryWriter" ]
1.8.0
yuchen071/Normal-map-generator
40f92a38a75a35dcf4b8309517bf83b6a52b4fbb
1.7
""" --- title: Train Feedback Transformer summary: This is training code with notes for a feedback transformer. --- # Train Feedback Transformer This trains a [feedback transformer](index.html) model for auto-regression. You can pick the original feedback transformer or the new version where the keys and values are p...
[ "torch.nn.Linear", "torch.nn.Embedding" ]
1.7
lc0/nn
0de7e343a11685de37a03ae4ee2510d18fc07369
1.0
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof class Foo(torch.jit.ScriptModule): def __init__(self, size): super(Foo, self).__init__() self.n = torch.nn.Parameter(torch.ones(size)) self.m = torch.nn.Parameter(torch.ones(size)) @torc...
[ "torch.cuda.profiler.start", "torch.autograd.profiler.emit_nvtx", "torch.cuda.profiler.stop", "torch.ones" ]
1.0
oyj0594/apex
b66ffc1d952d0b20d6706ada783ae5b23e4ee734
1.0
#!/usr/bin/env python3 """ Example to run pyprof with imagenet models. """ import sys import torch import torch.nn as nn import torchvision.models as models import torch.cuda.profiler as profiler import argparse from apex import pyprof from apex.optimizers import FusedAdam def parseArgs(): parser = argparse.Argume...
[ "torch.rand", "torch.autograd.profiler.emit_nvtx", "torch.cuda.profiler.stop", "torch.cuda.profiler.start", "torch.empty", "torch.nn.CrossEntropyLoss" ]
1.0
oyj0594/apex
b66ffc1d952d0b20d6706ada783ae5b23e4ee734
1.1
#!/usr/bin/python # -*- encoding: utf-8 -*- from logger import setup_logger from models.model_stages import BiSeNet from cityscapes import CityScapes from loss.loss import OhemCELoss from loss.detail_loss import DetailAggregateLoss from evaluation import MscEvalV0 from optimizer_loss import Optimizer import torch impo...
[ "torch.save", "torch.no_grad", "torch.nn.parallel.DistributedDataParallel", "torch.cuda.device_count", "torch.cuda.set_device", "torch.squeeze", "torch.utils.data.DataLoader", "torch.utils.data.distributed.DistributedSampler", "torch.load", "torch.distributed.get_rank" ]
1.1.0
Toby-SZZ/STDC-Seg
9273e03b02241fda107962bfc7bd366310a8d23b
1.3
import string import numpy as np import torch as th from ttools.training import ModelInterface from . import utils class VectorizerInterface(ModelInterface): def __init__(self, model, lr, n_primitives, canvas_size, w_surface, w_alignment, csg, rounded, cuda=True): self.model = model self.cuda =...
[ "torch.sum", "torch.cat", "torch.mean", "torch.max" ]
1.3.1
dmsm/DeepParametricShapes
2e0de365191b29c61796f7cd6cbd2bdf631eae2c
1.1
###################################################################################### #FSSNet: Fast Semantic Segmentation for Scene Perception #Paper-Link: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8392426 ###################################################################################### import to...
[ "torch.nn.MaxPool2d", "torch.nn.BatchNorm2d", "torch.nn.functional.interpolate", "torch.nn.ConvTranspose2d", "torch.add", "torch.nn.Conv2d", "torch.cuda.is_available", "torch.nn.Dropout2d" ]
1.1.0
ZAKAUDD/Segmentation-Networks
7e006809a7345819ebc50326175df156beeca618
1.4
from abc import ABC, abstractmethod import random import torch import torch.nn as nn import torch.nn.functional as F class mab_user(ABC): def __init__(self, n_arms, lamb=1): super(mab_user, self).__init__() self.t = torch.tensor(1.0) self.r = torch.zeros(n_arms) self.n = torch.zero...
[ "torch.zeros", "torch.ceil", "torch.tensor", "torch.log", "torch.randn" ]
1.4.0
tginart/competing-ai
75c456854e4770adf8be7cd56e58177d50f74a24
1.0
import numpy as np import tempfile import os import pytest import torch from anndata import AnnData from scvi.dataset import ( AnnDatasetFromAnnData, CortexDataset, SyntheticDataset, GeneExpressionDataset, Dataset10X, ) from scvi.inference import ( JointSemiSupervisedTrainer, AlternateSemi...
[ "torch.rand", "torch.manual_seed", "torch.randn_like", "torch.ones_like", "torch.randint_like" ]
1.0.1
shaoxin0801/scVI
f439eeb7b696b01a281af2f0e2f49592318614cb
1.0
import argparse import pandas as pd from tqdm import tqdm import torch import torch.nn.parallel from contextlib import suppress import os from effdet import create_model, create_loader from effdet.data import resolve_input_config from timm.utils import setup_default_logging from timm.models.layers import set_layer_con...
[ "torch.flip", "torch.save", "torch.no_grad" ]
1.0.3
yellowdolphin/SIIM-COVID19-Detection
31e8653b467ac35a8b1d92330ad5f15a12622676
1.3
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from torchvision import models import numpy as np device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') def weights_init_normal(m): classname = m.__class__.__name__ if classname.find('Conv') != -1: ...
[ "torch.nn.Linear", "torch.cat", "torch.nn.BatchNorm2d", "torch.nn.init.kaiming_normal_", "torch.inverse", "torch.bmm", "torch.cuda.is_available", "torch.mul", "torch.nn.init.constant_", "torch.FloatTensor", "torch.nn.init.normal_", "torch.div", "torch.nn.init.xavier_normal_", "torch.nn.Seq...
1.3.0
levindabhi/SieveNet
a5e2263acf28b52a551d4e139328957cf454e7e8
1.7
# -*- coding: utf-8 -*- # """*********************************************************************************************""" # FileName [ split_long_utter_to_short.py ] # Synopsis [ preprocess long audio / speech to shorter versions ] # Author [ Andy T. Liu (Andi611) ] # Copyright [ Copyleft(c...
[ "torch.split" ]
1.7.0
hhhaaahhhaa/s3prl
a469787f05c42196c4d989555082f5fd9dcbe8a6
1.10
import os from easydict import EasyDict import torch # architecture from basicts.archs.DCRNN_arch import DCRNN # runner from basicts.runners.DCRNN_runner import DCRNNRunner from basicts.data.base_dataset import BaseDataset from basicts.metrics.mae import masked_mae from basicts.metrics.mape import masked_mape from bas...
[ "torch.tensor" ]
1.10.0
zezhishao/BasicTS
584ca6f8215a6fc9976789b600996934ba2d499e
1.2
#!/usr/bin/env python # coding: utf-8 import os import yaml import torch import argparse import numpy as np from torch.distributed import get_rank, get_world_size # For reproducibility, comment these may speed up training torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # Arguments par...
[ "torch.cuda.manual_seed_all", "torch.distributed.init_process_group", "torch.hub.set_dir", "torch.manual_seed", "torch.cuda.set_device", "torch.cuda.is_available" ]
1.2.0
s3prl/End-to-end-ASR-Pytorch
64e3d844cebca1eb442b9327f43145c95c9a6088
1.7
import time from pathlib import Path from tqdm import tqdm import hydra from omegaconf import DictConfig # 言語処理 # import fasttext # import fasttext.util from transformers import BertTokenizer, BertModel # データ処理 import numpy as np import torch def extract_feats(config): start = time.time() # FPs with ope...
[ "torch.no_grad", "torch.Tensor" ]
1.7.0
ndkgit339/filledpause_prediction_group
db511c081f155ec2c23afe82bc44c03c38618590
1.7
import pytest from typing import Any import torch from torchtyping import TensorType import typeguard a = b = c = None def test_fixed_int_dim(): @typeguard.typechecked def _3_dim_checker(x: TensorType[3]): pass @typeguard.typechecked def _3m1_dim_checker(x: TensorType[3, -1]): pass ...
[ "torch.rand" ]
1.7.0
olliethomas/torchtyping
81e1cffa841307d700b11e9a2c970a5face65020
1.7
# -*- coding: utf-8 -*- # """*********************************************************************************************""" # FileName [ model.py ] # Synopsis [ the 1-hidden model ] # Author [ S3PRL ] # Copyright [ Copyleft(c), Speech Lab, NTU, Taiwan ] """************************************...
[ "torch.nn.Linear", "torch.nn.Dropout", "torch.cat", "torch.nn.ModuleList", "torch.nn.Conv1d", "torch.nn.functional.relu" ]
1.7.1
OlegJakushkin/s3prl
c0e41f07fa56f0f79b5bf3839b4d0a4cf7c421bf
0.4
#!/usr/bin/env python import argparse import logging import os from shutil import copyfile, rmtree import numpy as np import torch import torch.nn as nn from ase.data import atomic_numbers from torch.optim import Adam from torch.utils.data.sampler import RandomSampler import schnetpack as spk from schnetpack.datasets...
[ "torch.device", "torch.utils.data.sampler.RandomSampler", "torch.optim.Adam", "torch.nn.DataParallel" ]
0.4
heytitle/schnetpack
6facf724e6e220053f4ba8d5b81744744d1abef3
1.6
""" 2020.06.09-Changed for building GhostNet Huawei Technologies Co., Ltd. <foss@huawei.com> Creates a GhostNet Model as defined in: GhostNet: More Features from Cheap Operations By Kai Han, Yunhe Wang, Qi Tian, Jianyuan Guo, Chunjing Xu, Chang Xu. https://arxiv.org/abs/1911.11907 Modified from https://github.com/d-li1...
[ "torch.cat", "torch.nn.functional.relu6", "torch.nn.Sigmoid", "torch.nn.Conv1d", "torch.nn.Sequential", "torch.nn.BatchNorm2d", "torch.nn.init.constant_", "torch.nn.ReLU6", "torch.nn.Conv2d", "torch.nn.init.normal_", "torch.hub.load_state_dict_from_url", "torch.nn.AdaptiveAvgPool2d" ]
1.6
samcw/nanodet
dc7c4f6021199d6988221b516d49af392a52d748
1.7
import torch from torch.nn.parallel import DistributedDataParallel as DDP import torch.distributed as dist import logging import pandas as pd import traceback from ...core import models from ..misc import utils class BaseManager: """ Manager all modules and computation devices. Support three kinds of comput...
[ "torch.distributed.get_world_size", "torch.nn.parallel.DistributedDataParallel", "torch.cuda.empty_cache", "torch.cuda.is_available", "torch.nn.DataParallel" ]
1.7.0
wangck20/GeDML
1f76ac2094d7b88be7fd4eb6145e5586e547b9ca
1.7
import torch import torchvision import collections import numpy as np ''' _sparsity_ratios is a dictionary to save the sparsity ratios of each layer, Key - the layer name Value - list of sparsity ratios for the executed forward passes ''' _sparsity_ratios_per_layer = collections.defaultdict(list) _sparsity_ratios_per_...
[ "torch.abs", "torch.numel" ]
1.7.1
scale-lab/BitTrain
3a15f96cc32222e3d6fceb00a622521e31745d4c
1.8
import typing from typing import Dict, Union, Tuple, Iterator, Any from typing import Optional import numpy as np import torch from gym.utils import seeding from advisor_losses import AlphaScheduler, AdvisorWeightedStage from allenact.algorithms.offpolicy_sync.losses.abstract_offpolicy_loss import ( AbstractOffPo...
[ "torch.ones", "torch.from_numpy" ]
1.8.0
allenai/advisor
6849755042c6dab1488f64cf21bde2322add3cc1
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.Size", "torch.rand", "torch.nn.Linear", "torch.nn.MSELoss", "torch.tensor" ]
1.7
charlesjhill/lightning-flash
2b19acbb5d627c609f2f7e13b48006e157781718
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.nn.Linear", "torch.nn.MSELoss", "torch.arange" ]
1.7
charlesjhill/lightning-flash
2b19acbb5d627c609f2f7e13b48006e157781718
1.5
import torch as to BASE_GRAPH = to.tensor([[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 1], [0, 0, 1, 0]]) BASE_GRAPH_NODE_FEATURES = to.tensor([[1, 2], [1, 1], [2, 0.5], [0.5, 0.5]]) BASE_GRAPH_EDGE_FEATURES = to.tensor([[[0.0, 0.0], [1.0, 2.0], [2.0, 0...
[ "torch.tensor" ]
1.5.0
kovanostra/message-passing-nn
6617a4753173c8fffc60140b9d8d0f497b33aed4
1.3
# 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.tensor" ]
1.3.1
bibinwils/metrics
e1c3fda24f90367803c2b04315ad7c8bced719db
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.nn.Linear", "torch.zeros", "torch.nn.Dropout", "torch.nn.LayerNorm", "torch.cat", "torch.nn.MSELoss", "torch.arange", "torch.einsum", "torch.nn.Tanh", "torch.nn.CrossEntropyLoss", "torch.ones", "torch.nn.BCEWithLogitsLoss", "torch.nn.functional.softmax", "torch.tanh", "torch.matmu...
1.0
khoih-prog/transformers
77321481247787c97568c3b9f64b19e22351bab8
1.2
# encoding: utf-8 # Sample-based Monte Carlo Denoising using a Kernel-Splatting Network # Michaël Gharbi Tzu-Mao Li Miika Aittala Jaakko Lehtinen Frédo Durand # Siggraph 2019 # # Copyright (c) 2019 Michaël Gharbi # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in c...
[ "torch.abs", "torch.mean", "torch.clamp", "torch.pow" ]
1.2.0
milebril/Temporal-SBMC-extension
57c56b73786e49d233facffde4ba80f212a00fa8
1.6
import os import pandas as pd import numpy as np import torch import json import joblib from ..scripts.compute_normalization_factors import annotate_kmer_information, create_kmer_mapping_df, create_norm_dict from torch.utils.data import DataLoader, Dataset from torch.utils.data._utils.collate import default_collate fro...
[ "torch.utils.data._utils.collate.default_collate", "torch.LongTensor", "torch.Tensor" ]
1.6.0
GoekeLab/m6anet
be3148a6404bdd2a4e5e9544b3e618e836c6483c
1.6
import torch from torch import nn def get_activation(activation): activation_func = None if activation == 'tanh': activation_func = nn.Tanh() elif activation == 'sigmoid': activation_func = nn.Sigmoid() elif activation == 'relu': activation_func = nn.ReLU() elif activation ...
[ "torch.nn.Linear", "torch.nn.Dropout", "torch.nn.Softmax", "torch.nn.Sigmoid", "torch.nn.Sequential", "torch.nn.Tanh", "torch.nn.ReLU", "torch.nn.BatchNorm1d", "torch.nn.Embedding", "torch.nn.Flatten" ]
1.6.0
GoekeLab/m6anet
be3148a6404bdd2a4e5e9544b3e618e836c6483c
1.8
import os import torch import numpy as np class Exp_Basic(object): def __init__(self, args): self.args = args self.device = self._acquire_device() self.model = self._build_model().cuda() def _build_model(self): raise NotImplementedError def _acquire_device(self): i...
[ "torch.device" ]
1.8.0
MarcAntoineAlex/SCINet
4ac582cd717ba1c0c6c6d31a9a824235d35563ed
0.4
# 새로운 참고링크: https://github.com/eriklindernoren/PyTorch-GAN/tree/master/implementations/context_encoder # 우리랑 같은 3채널에 하고자하는 바도 비슷함. shape 참고하기 좋을듯하여 첨부함 # 나(소현)는 사진 11개 -> batch_size=11, num_classes=11이니 주의바람! import argparse import os import numpy as np from dataloader import OAGandataset import math import torchvisi...
[ "torch.nn.BatchNorm2d", "torch.nn.LeakyReLU", "torch.ones", "torch.cuda.is_available", "torch.nn.functional.pad", "torch.nn.Softmax", "torch.nn.MaxPool2d", "torch.nn.init.constant_", "torch.nn.ConvTranspose2d", "torch.nn.init.normal_", "torch.utils.data.DataLoader", "torch.nn.BCELoss", "torc...
0.4.0
gun8474/face-recognition-by-OAGAN
54c67a29a22e25b14a24fb8aa3badba5444653ac
0.4
import argparse import os import numpy as np from dataloader import OAGandataset from torchvision.utils import save_image from torch.utils.data import DataLoader from torchvision import datasets from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch import torchvision.m...
[ "torch.nn.BatchNorm2d", "torch.nn.LeakyReLU", "torch.ones", "torch.cuda.is_available", "torch.nn.functional.pad", "torch.nn.Softmax", "torch.nn.MaxPool2d", "torch.nn.init.constant_", "torch.nn.ConvTranspose2d", "torch.nn.init.normal_", "torch.utils.data.DataLoader", "torch.nn.BCELoss", "torc...
0.4.0
gun8474/face-recognition-by-OAGAN
54c67a29a22e25b14a24fb8aa3badba5444653ac
1.4
# -*- coding: utf-8 -*- __author__ = 'S.I. Mimilakis' __copyright__ = 'MacSeNet' # imports import numpy as np import torch import torch.nn as nn class ConvEncoder(nn.Module): """ Class for building the analysis part of the Front-End ('Fe'), with randomly initialized dictionaries. """ ...
[ "torch.nn.init.kaiming_uniform_", "torch.nn.ConvTranspose1d", "torch.nn.Conv1d", "torch.nn.Tanh", "torch.nn.ReLU" ]
1.4.0
TUIlmenauAMS/rl_singing_voice
60204c698d48f27b44588c9d6c8dd2c66a13fcd5
1.1
import torch import torch.nn as nn from torchvision import models, transforms class Resnet18(object): ''' pretrained Resnet18 from torchvision ''' def __init__(self, args, eval=True, share_memory=False, use_conv_feat=True): self.model = models.resnet18(pretrained=True) if args.gpu: ...
[ "torch.device", "torch.cat", "torch.set_grad_enabled" ]
1.1.0
jzhanson/alfred
d5b540e7c9b53d3f70cc2907503935fecff00018
1.4
# -*- coding: utf-8 -* # ***************************************************************************** # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: #...
[ "torch.cuda.manual_seed", "torch.optim.lr_scheduler.StepLR", "torch.no_grad", "torch.cuda.device_count", "torch.manual_seed", "torch.utils.data.DataLoader", "torch.load", "torch.utils.data.distributed.DistributedSampler" ]
1.4.1
ruaruaruabick/waveglow
636d2ba2bda4f4efd5f13f8e46aef23d8b7881bd
1.5
# Copyright 2020 - 2021 MONAI Consortium # 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 wri...
[ "torch.jit.load", "torch.load" ]
1.5
finalelement/MONAI
8e8e1b391fa649d1227087164dba208008d00bc4
1.7
import torch import torch.nn as nn def soft_update(target, source, t): for target_param, source_param in zip(target.parameters(), source.parameters()): target_param.data.copy_( (1 - t) * target_param.data + t * source_param.data ) def hard_update(target, source): for target_param, source_param in zi...
[ "torch.nn.init.orthogonal_", "torch.no_grad", "torch.nn.init.constant_", "torch.svd" ]
1.7.1
zhangdongkun98/rl-lib
50e36c18b130cff40abc6621923becd6cdc48e2b
1.3
"""Compute the gradient with PyTorch and the variance with BackPACK.""" from torch.nn import CrossEntropyLoss, Flatten, Linear, Sequential from backpack import backpack, extend, extensions from backpack.utils.examples import load_mnist_data B = 4 X, y = load_mnist_data(B) print("# Gradient with PyTorch, individual ...
[ "torch.nn.Linear", "torch.nn.CrossEntropyLoss", "torch.nn.Flatten" ]
1.3.0
paulkogni/backpack
3122de062d5bbcdcba8f8e02d24adb1bd2cdada6
1.6
import errno import os import time import urllib.request import sys import numpy as np import pkg_resources import torch import torch.nn as nn import torch.nn.functional as F import torchvision from PIL import Image from skimage import transform from torchvision import transforms from tqdm import tqdm from . import d...
[ "torch.device", "torch.min", "torch.max", "torch.no_grad", "torch.cuda.is_available", "torch.load" ]
1.6.0
0xflotus/rembg
7fb6683169d588f653281d53c3c258838194c950
0.4
from collections import OrderedDict import torch.nn as nn import torchvision.models as models class LinkNet(nn.Module): def __init__(self, num_classes, resnet_size=18, pretrained_encoder=True): super().__init__() self.num_classes = num_classes # The LinkNet encoder is a ResNet18 without t...
[ "torch.nn.ReLU", "torch.nn.BatchNorm2d", "torch.nn.ConvTranspose2d", "torch.nn.Conv2d" ]
0.4.1
liyingben/kaggle-airbus-ship-detection
21d89b2f1273b31a6ffafb4fe5f7e643ffbbc567
0.4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Python version: 3.6 import copy import os import pickle import pandas as pd import numpy as np import torch from torch import nn from torch.utils.data import DataLoader from utils.options import args_parser from utils.train_utils import get_data, get_model from models.U...
[ "torch.cuda.is_available", "torch.nn.CrossEntropyLoss" ]
0.4.1
yhyeh/LG-FedAvg
f64a2943c7f1fed214412033e0fa0a63f3c03fb8
1.0
""" Unit tests for various optimization related utilities. """ import unittest import torch from texar.core.optimization import * class OptimizationTest(unittest.TestCase): r"""Test optimization. """ def setUp(self): N, D_in, H, D_out = 64, 100, 10, 1 self.x = torch.randn(N, D_in) ...
[ "torch.nn.Linear", "torch.nn.MSELoss", "torch.nn.ReLU", "torch.tensor", "torch.randn" ]
1.0.0
lunayach/texar-pytorch
ac3e334e491f524dd01654b07af030fa20c88b34
1.0
# Copyright 2019 The Texar Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
[ "torch.zeros", "torch.nn.Dropout", "torch.nn.LayerNorm", "torch.nn.ModuleList", "torch.ones_like", "torch.empty", "torch.argmax", "torch.where" ]
1.0.0
lunayach/texar-pytorch
ac3e334e491f524dd01654b07af030fa20c88b34
1.0
""" Unit tests for attention mechanism. """ import unittest import numpy as np import torch from texar.core.attention_mechanism import * class AttentionMechanismTest(unittest.TestCase): r"""Tests attention mechanism. """ def setUp(self): self._batch_size = 8 self._max_time = 16 ...
[ "torch.Size", "torch.rand" ]
1.0.0
lunayach/texar-pytorch
ac3e334e491f524dd01654b07af030fa20c88b34
1.2
import time from typing import Any, Callable, Dict, List, Optional import torch import torch.nn as nn from torch.utils.data import DataLoader from captum._utils.models.linear_model.model import LinearModel def l2_loss(x1, x2, weights=None): if weights is None: return torch.mean((x1 - x2) ** 2) / 2.0 ...
[ "torch.stack", "torch.norm", "torch.FloatTensor", "torch.no_grad", "torch.nn.init.xavier_uniform_", "torch.isclose", "torch.optim.lr_scheduler.ReduceLROnPlateau", "torch.mean" ]
1.2
edward-io/captum
8f959950baaad00f2f9a3404d583b9f9292e35c7
1.0
import torch from . import Metric class MeanAbsoluteError(Metric): def __init__(self): super().__init__("mae", default_value=float('inf')) self._absolute_error_sum = 0. self._total = 0 def step(self, y: torch.Tensor, y_pred: torch.Tensor): absolute_errors = torch.abs(y - y_pr...
[ "torch.abs", "torch.sum" ]
1.0.0
benoitmartin88/pytorchtrainer
7d73acd0802e00c3589d28bce6c42a489dcd46ea
1.9
"""Convert the model to ONN format """ __author__ = "Likith Reddy" __version__ = "1.0.0" __email__ = "likith012@gmail.com" import torch import torch.nn as nn import torch.onnx import sys, os sys.path.insert(0, os.path.join(sys.path[0], '../')) from configs import config from src.dataset import BERTDataset if __n...
[ "torch.nn.DataParallel", "torch.onnx.export", "torch.cuda.device_count" ]
1.9.1
likith012/distill-grammar
04ff5e07337789edfe57f21f85e30e7992ae90d9
1.1
import pytest import torch import torch.nn as nn import torch.nn.functional as F from foresight import ei ################################## #### H #### ################################## def test_H_0(): x = torch.zeros((4,)) x[1] = 1 assert ei.H(x).item() == 0 def test_H_1(): ...
[ "torch.zeros", "torch.nn.Linear", "torch.nn.AvgPool2d", "torch.ones", "torch.nn.Conv2d", "torch.tensor", "torch.flatten", "torch.randn" ]
1.1.0
ejmichaud/torch-foresight
e36a8fdd65f0432b9fa25a5127412b081159956b
1.4
# Taken from https://github.com/psclklnk/spdl # Copy of the license at TeachMyAgent/teachers/LICENSES/SPDL import torch import numpy as np def set_weights(parameters, weights, use_cuda): """ Function used to set the value of a set of torch parameters given a vector of values. Args: parameter...
[ "torch.cat", "torch.from_numpy", "torch.tensor" ]
1.4.0
flowersteam/TeachMyAgent
a8f71cbfce4cb8ca6da24d00ea690495e3afbd2e
1.11
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. #!/usr/bin/env python3 # pyre-strict import os import time import traceback from dataclasses import dataclass from typing import An...
[ "torch._C._log_api_usage_once" ]
1.11.0
laurencer/recipes
60b7c5f0304c7eb44a39295eba78da02608ae858
0.4
# From https://github.com/wjh720/QPLEX/, added here for convenience. import copy from components.episode_buffer import EpisodeBatch from modules.mixers.dmaq_general import DMAQer # from modules.mixers.dmaq_qatten import DMAQ_QattenMixer import torch.nn.functional as F import torch as th from torch.optim import RMSprop ...
[ "torch.stack", "torch.optim.RMSprop", "torch.gather", "torch.nn.utils.clip_grad_norm_", "torch.mean" ]
0.4.1
HDUAIS/MARL_Bench
f592d20ddbcb2039453cf56221083d4ac64dee46
1.7
""" 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 torch from torch import nn from torch.nn import functional as F from torch.autograd import Variable import torch.utils.data import tor...
[ "torch.nn.Linear", "torch.nn.AdaptiveAvgPool2d", "torch.nn.init.constant_", "torch.nn.Sequential", "torch.nn.init.kaiming_normal_", "torch.nn.GroupNorm", "torch.nn.Conv2d", "torch.nn.functional.relu" ]
1.7.1
sbelenki/fastMRI
9a359ffe340e9265491744e381d92241b36a6455
1.7
""" 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 h5py import torch from collections import OrderedDict from fastmri.data import transforms import numpy as np import random import pdb...
[ "torch.max", "torch.Tensor", "torch.mean" ]
1.7.1
sbelenki/fastMRI
9a359ffe340e9265491744e381d92241b36a6455