content
stringlengths
200
198k
repo
stringlengths
4
186
path
stringclasses
1 value
license
stringclasses
101 values
size
int64
200
198k
sha
stringlengths
40
40
lang
stringclasses
1 value
ext
stringclasses
1 value
#Script to load GRU model trained on all datasets and test # import relevant libraries import torch import torch.nn as nn import torch.optim as optim import matplotlib import numpy as np import trajectories import loader import argparse import gc import logging import os import sys import time from gru_prototype_v4_all...
RNN/data/gru_loadNtest.py
MIT
8,870
34534850b62dcaf2706a524824e2fba8da6957d4
Python
py
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author: Donny You(youansheng@gmail.com) from __future__ import absolute_import from __future__ import division from __future__ import print_function import math import numpy as np import torch from utils.tools.logger import Logger as Log class PafGenerator(object): ...
utils/layers/pose/paf_generator.py
Apache-2.0
3,078
b26bab0f95d7e8f459132d04d8adb5d7bbce114a
Python
py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import numpy as np import rasterio from rasterio.errors import RasterioIOError import rasterio.windows from torch.utils.data.dataset import Dataset class ZipDataset(Dataset): def __init__(self, ds1, ds2): assert ...
Damage Assessment Visualizer/utils/utils.py
MIT
4,867
12a9291b25b8e00122fff245a469da98174aa0a1
Python
py
import os import torch import numpy as np import torch.utils.data as data import torchvision.transforms as transforms from PIL import Image import binvox_rw from point_transforms import * class ShapeNet(data.Dataset): def __init__(self, img_root='/media/administrator/Dong1/ShapeNetCore.v1/renderin...
dataset.py
MIT
5,662
3ac459c54f59ddbfd52c8985994ba52bf488513d
Python
py
from functools import partial from itertools import repeat import collections.abc as container_abcs import logging import os from collections import OrderedDict import numpy as np import scipy import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from einops.layers.torch impo...
lib/models/cls_cvt/cls_cvt.py
MIT
21,555
7c7e2748265158d9aae941ae2964de701d3e7f95
Python
py
import warnings from typing import List, Sequence import torch import torch.nn as nn import torch.nn.functional as F from .regularizations import WeightDrop, LockedDropout, EmbeddingDropout from .attentions import Attention def repackage_var(h): """Wraps h in new Variables, to detach them from their history.""" ...
nobita/modules.py
MIT
9,101
3ac48a46c4d98e89f6959131bbcac9e9fadf11be
Python
py
import csv import threading from torch.utils.data.dataloader import DataLoader from src.lib.word_operator import str_format from src.data_process import get_dataloader from src.train_process import DL_Model class TaskThread(threading.Thread): def __init__( self, model: DL_Model, mode: str...
main.py
MIT
4,374
3ac48abb25911ba385f7f05e68360d143c8798db
Python
py
# coding=utf-8 # Copyright 2019 project LXRT. # 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 ...
src/lxrt/modeling_big.py
MIT
50,654
1ea16d9b6d7aa04c266480507de6f587dc121821
Python
py
from __future__ import division import argparse import torch from mmcv import Config from mmcv.runner import load_checkpoint from mmfashion.core import AttrPredictor, CatePredictor from mmfashion.models import build_predictor from mmfashion.utils import get_img_tensor def parse_args(): parser = argparse.Argumen...
demo/test_cate_attr_predictor.py
Apache-2.0
1,917
3ac4a1322f4f614ebd0f4f20b3afe9309a8a03d7
Python
py
import torch import torch.nn as nn from mmcv.cnn import constant_init, normal_init from .conv_module import ConvModule class NonLocal2D(nn.Module): """Non-local module. See https://arxiv.org/abs/1711.07971 for details. Args: in_channels (int): Channels of the input feature map. reductio...
SipMask-mmdetection/mmdet/ops/non_local.py
MIT
3,593
3ac4bf9f529ef33a50c2ff1642c213f9f2a42531
Python
py
import torch import torch.utils.data as data import random import math import os import logging from MIME.utils import config import pickle from tqdm import tqdm import numpy as np import pprint pp = pprint.PrettyPrinter(indent=1) import re import time import nltk from constants import MIME_HOME class Lang: def...
utils/data_reader.py
MIT
7,821
d7cec9ae175c5aeb697eb79adae09f052d514681
Python
py
# pylint: disable-all import argparse from animus import EarlyStoppingCallback, IExperiment from animus.torch.callbacks import TorchCheckpointerCallback from apto.utils.report import get_classification_report from catalyst import utils import numpy as np import optuna from sklearn.model_selection import train_test_spl...
src/scripts/tune_ts_lstm_oasis_cv_whole.py
Apache-2.0
9,173
3ac4d350db37631a50c583f2d20361269d3cdd5d
Python
py
from xmuda.models.quan_trainer_lmsc import RecNetLMSC from xmuda.models.quan_trainer import RecNet # from xmuda.models.quan_trainer_seg import RecNetSeg from xmuda.models.SSC2d import SSC2d from xmuda.data.semantic_kitti.semantic_kitti_quan import SemanticKITTISCN from torch.utils.data.dataloader import DataLoader impo...
xmuda/extract_results.py
Apache-2.0
2,508
3ac4f81f9cf4d5760c36022639311560ddb0af1a
Python
py
import torch import numpy as np from maskr.utils import box_utils from maskr.lib.nms.nms_wrapper import nms from maskr.utils.batch import batch_slice from maskr.test.baseline import saveall import logging log = logging.getLogger() @saveall @batch_slice(2) def proposals(rpn_class, rpn_bbox, proposal_count, anchors, co...
maskr/filters/proposals.py
MIT
2,207
b28ee69f293e0d91373cfd6c99a356300971f910
Python
py
import numpy as np import torch import torchvision from torch import nn from core import build_graph, cat, to_numpy torch.backends.cudnn.benchmark = True device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") @cat.register(torch.Tensor) def _(*xs): return torch.cat(xs) @to_numpy.register(torc...
examples/dist/CIFAR10-dawndist/torch_backend.py
BSD-2-Clause
4,574
28bbf3503c050dde32342a7905bf4fb62f189812
Python
py
""" Created on Thu Oct 26 14:19:44 2017 @author: Utku Ozbulak - github.com/utkuozbulak """ import os import numpy as np from torch.optim import SGD from torchvision import models from misc_functions import preprocess_image, recreate_image, save_image class ClassSpecificImageGeneration(): """ Produces a...
src/generate_class_specific_samples.py
MIT
2,187
12d526dd6a983cfe0fdbc6b387ef76b982621065
Python
py
import torch.nn as nn import math import torch from torch.autograd import Variable from scipy.linalg import hadamard class HadamardProj(nn.Module): def __init__(self, input_size, output_size, bias=True, fixed_weights=True, fixed_scale=None): super(HadamardProj, self).__init__() self.output_size = ...
models/modules/fixed_proj.py
MIT
2,828
3ac52d5faab36244a57b2c1a8d8fea00afde1627
Python
py
''' This code is mainly taken from the following github repositories: 1. parksunwoo/show_attend_and_tell_pytorch Link: https://github.com/parksunwoo/show_attend_and_tell_pytorch/blob/master/prepro.py 2. sgrvinod/a-PyTorch-Tutorial-to-Image-Captioning Link: https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Image-Capti...
KoBert_Based_Model/data_loader_kobert.py
Apache-2.0
3,107
456db50482489f82f7f6fb9f2e86d9e579ceda66
Python
py
import torch.cuda from LJ_surrogates.surrogates.collate_data import collate_physical_property_data from LJ_surrogates.parameter_modification import vary_parameters_lhc, create_evaluation_grid import time from LJ_surrogates.sampling.likelihood import likelihood_function from LJ_surrogates.surrogates.surrogate import co...
projects/examples/argon_single/argon_single.py
MIT
7,475
3ac544fdb31a2ded0bc6f6132c5d9218489c3c55
Python
py
""" Provide quantilized form of torch.nn.modules.linear """ import torch import torch.nn as nn import torch.nn.functional as F import math from .number import qsigned class Linear(nn.Linear): def __init__(self, in_features, out_features, bias=True, ...
tqt/function/linear.py
BSD-3-Clause
2,888
3ac55d8e4423ac7bb23b3580238d9a956a581f6d
Python
py
#!/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 argparse import os import random import sys import time from math import pi import numpy as np import orbslam2 i...
habitat_baselines/agents/slam_agents_aimas.py
MIT
22,958
5e1ff9de6d1924decdaefc6a28bfddcef4ca61f2
Python
py
#!/usr/bin/env python3 import builtins as __builtin__ import collections import datetime import faulthandler import math import multiprocessing.queues as mp_queues import os import queue import random import time from typing import Any, Callable, Dict, Optional, Tuple import numpy as np import torch from fairseq impo...
pytorch_translate/train.py
BSD-3-Clause
30,102
3ac5a57740f846dee854599d24d8044c9c946e6e
Python
py
import io, requests import torch import torch.nn as nn from dall_e.encoder import Encoder from dall_e.decoder import Decoder from dall_e.utils import map_pixels, unmap_pixels from dall_e._model_dl import models_path # Set up models directory from dall_e import models # Load implicit namespace module def load_model(...
dall_e/__init__.py
MIT
721
03ba9a374135173c9a160cecf83d9afc3879d33d
Python
py
# import minpy.numpy as np import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import math from torch.autograd import Function import cv2 class UnNormalizer(object): def __init__(self, mean=None, std=None): if mean == None: self.mean = [0.485, 0.456, 0.406] ...
Losses/Mask_bce_loss.py
MIT
6,795
3ac5b0b2d84d906582785c76c0276a8d178bb35b
Python
py
import argparse import os import shutil import torch import torch.nn as nn from torch.autograd import Variable from torch.utils.data.dataloader import DataLoader from dpp_nets.utils.io import make_embd, make_tensor_dataset from dpp_nets.layers.layers import KernelVar, ReinforceSampler, PredNet, ReinforceTrainer par...
train_reinforce_beer_cpu.py
MIT
10,702
12c63dc06cf443c8dc394597ea859f4027611499
Python
py
import numpy as np import torch import torch.nn as nn #__all__ = [ 'Conv', 'Deconv' ] __all__ = [ 'Conv', 'Conv1d' ] # Convolutional layer class class Conv(nn.Conv2d): ''' Convolutional layer:: conv0 = Conv([m,n,p], [c,r,s], [ystride,xstride], [ypadding, xpadding], bias, init) creates ...
ummon/modules/conv.py
BSD-3-Clause
25,457
5f356bd1d21855baa34f4c84b0b9d5da358a05be
Python
py
#copy of j25 import numpy as np from collections import namedtuple from functools import partial from PIL import Image import data_transforms import data_iterators import pathfinder import utils import app import torch import torchvision import torch.optim as optim import torch.nn as nn import torch.nn.functional...
configs/f68_pt.py
MIT
9,164
3ac629191c9a4574f1fa66bf0707ba461a0e6cfc
Python
py
# Copyright (c) Facebook, Inc. and its affiliates. """ Losses module contains implementations for various losses used generally in vision and language space. One can register custom losses to be detected by MMF using the following example. .. code:: from mmf.common.registry import registry from torch import nn ...
mmf/modules/losses.py
BSD-3-Clause
38,637
fcaca33a19799b4afa35cbe1eddf88bb307672a4
Python
py
import numpy as np import torch import os.path as osp import json from core.config import cfg from manopth.manolayer import ManoLayer class MANO(object): def __init__(self): self.layer = self.get_layer() self.vertex_num = 778 self.face = self.layer.th_faces.numpy() self.joint_regr...
lib/_mano.py
MIT
2,173
109c3f96ae5d13f4a4ad0689abca1cf5e11367a3
Python
py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import unittest import torch import torch.nn.functional as F from nni.algorithms.compression.v2.pytorch.pruning import ( LevelPruner, L1NormPruner, L2NormPruner, SlimPruner, FPGMPruner, ActivationAPoZRankPruner, Acti...
test/ut/compression/v2/test_pruner_torch.py
MIT
7,687
dfb7f0ba7c7deb6f3eb4250e56c710f40a4cb8ba
Python
py
from torch.utils.data import DataLoader from .collate_batch import train_collate_fn, val_collate_fn from .datasets import init_dataset, ImageDataset from .samplers import RandomIdentitySampler, RandomIdentitySampler_alignedreid from .transforms import build_transforms def make_data_loader(cfg, is_train): train_tra...
data/build.py
MIT
1,789
3ac66edf20267eb3344ef470333563138878cf59
Python
py
import torch import torch.nn as nn from . import utils from . import layers __all__ = ['rsunet_act'] nonlinearity = 'ReLU' params = {} def set_nonlinearity(act, **act_params): global nonlinearity assert act in ['LeakyReLU','PReLU','ELU','ReLU'] nonlinearity = act global params params = {} ...
emvision/models/rsunet_act.py
MIT
4,712
3ac67344e1a2dd3ea200bc946035031919332593
Python
py
# import os # os.environ['CUDA_VISIBLE_DEVICES']="1" from SOMDST_utils.eval_utils import compute_prf, compute_acc from pytorch_transformers import BertTokenizer, BertConfig from model.SOMDST import MGDST import torch.nn as nn import torch import torch.nn.functional as F from torch.utils.data import DataLoader import ...
MGL_SOMDST/SOMDST_evaluation.py
MIT
12,608
f9332319b1923433a55894c8f1e081b1efc4a1fb
Python
py
#!/usr/bin/env python3 from abc import ABC, abstractmethod from typing import Any from torch import Tensor from torch.nn import Module class Concept: r""" Concept features are human-friendly idea representations of target classes in a Machine Learning task, in a tensor format: they can be images such as...
captum/concept/_core/concept.py
BSD-3-Clause
2,645
3ac688aaf22ba459eda27adbbf22ee89b4f904f1
Python
py
# src: https://github.com/OpenNMT/OpenNMT-py/blob/master/onmt/utils/misc.py # -*- coding: utf-8 -*- import string import torch import subprocess from nltk.stem import PorterStemmer from c2nl.inputters import constants ps = PorterStemmer() def normalize_string(s, dostem=False): """Lower text and rem...
c2nl/utils/misc.py
MIT
5,415
3ac6975bb94f27cac1464bd59761becb3d58774d
Python
py
import torch.nn as nn class MLP(nn.Module): def __init__(self, input_size, hidden_size, out_size, norm_out=False, dropout_rate=0.8): super(MLP, self).__init__() self.norm_out = norm_out self.fc1 = nn.Linear(input_size, hidden_size) self.fc2 = nn.Linear(hidden_size, hidden_size) ...
src/models/mlp.py
MIT
754
3ac699c2f8cc1665ccb6d7477bd7db48a0df3275
Python
py
''' Retrieval Network, Written by Xiao For robot localization in a dynamic environment. ''' import numpy as np import os, sys, random, scipy import torch import matplotlib.pyplot as plt import matplotlib.image as mpimg from scipy.sparse import find as find_sparse_idx from torchvision import datasets, transforms from Ne...
Network/retrieval_network/datasets.py
MIT
11,178
e94b17c50563204dd09753dfd2303516947decf0
Python
py
import collections import glob import gzip import pathlib import torch from torch import nn from torch.nn import functional as F import numpy as np from pylego import ops from ..baseconditional import BaseGymTDVAE class PreProcess(nn.Module): """ The default preprocessing layer for 1d inputs. """ def ...
models/conditional/drqn.py
MIT
13,609
f99c1839d9a2ee0d4410229b65882ad3a9a85a35
Python
py
import torch import torch.nn as nn import torchvision.models.detection.backbone_utils as backbone_utils import torchvision.models.resnet as resnet import torchvision.models._utils as _utils import torch.nn.functional as F from collections import OrderedDict from models.mobilev1_width import MobileNetV1 as MobileNetV1 ...
models/retinaface_width.py
Apache-2.0
5,878
e602de1f9c8d65dfb97e7c0dfc281aa6280e7170
Python
py
# coding=utf-8 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # 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 u...
examples/run_finetune_cosmosqa_adapter.py
MIT
80,025
1e02007b0abd35ee6dd6a7eae151e941b404742a
Python
py
#!/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. from typing import Callable, Dict, List, Optional, Tuple, Type, Union import numpy as np import torch from ax.core.dat...
ax/modelbridge/torch.py
MIT
12,282
b2d1e3cd3d0df5f4f3a0154959ba4a45f495185e
Python
py
"""Pytorch Dataset object that loads perfectly balanced MNIST dataset in bag form.""" import numpy as np import torch import torch.utils.data as data_utils from PIL import Image from sklearn.model_selection import KFold from torch.utils.data import ConcatDataset from torchvision import datasets, transforms class Mni...
datasets/mnist_dataset.py
MIT
4,670
fdb098892c555c7d6b46cce4f31dad7526d18d0d
Python
py
import time from enum import Enum from functools import reduce import contextlib import numpy as np import torch from torch import nn from torch.nn import functional as F import torchplus from second.pytorch.core import box_torch_ops from second.pytorch.core.losses import (WeightedSigmoidClassificationLoss, ...
second/pytorch/models/voxelnet.py
MIT,BSD-3-Clause
38,769
e98277ddd0c19fdce4313023e1116645a2872ee0
Python
py
# -*- coding: utf-8 -*- import torch import Net import torch.nn as nn import torch.optim as optim from data_pipe import get_test_data, get_train_data import matplotlib.pyplot as plt from utils import visualize, visualize_cos, get_time,visualize_center import random import numpy as np import os from tqdm import tqdm fro...
train.py
MIT
4,704
3ac6e887ccf4b6d1faac7add00c93bd760b2bd1f
Python
py
import torch import numpy as np from torch_geometric.utils import (erdos_renyi_graph, stochastic_blockmodel_graph, barabasi_albert_graph) def test_erdos_renyi_graph(): torch.manual_seed(1234) edge_index = erdos_renyi_graph(5, 0.2, directed=...
test/utils/test_random.py
MIT
1,495
3ac7058a5fa967d509068a2b5fe67f1fb1a6a532
Python
py
import datetime import os import gym import numpy import torch from games.abstract_game import AbstractGame class MuZeroConfig: def __init__(self): self.seed = 0 # Seed for numpy, torch and the game ### Game self.observation_shape = (1, 1, 4) # Dimens...
games/per_cartpole.py
MIT
8,841
03b00dac126f744cfec71c79e25d2fd318f0653e
Python
py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import argparse import time import torch import sys sys.path.append("../..") import communication NUM_TRIALS = 20 if __name__ == '__main__': parser = argparse.ArgumentParser( description='Test lightweight communica...
runtime/tests/communication/gloo_communication_handler.py
MIT
4,830
3ac70eade0d5b4ac48e13d4ac0ca2c8ab01eff96
Python
py
import re import os import torch import pickle import random import numpy as np from soynlp.hangle import decompose from keras.preprocessing import text, sequence # 결과 재생산을 위한 시드값 고정을 위한 함수 def seed_everything(seed=42): random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) np.random.seed(seed) to...
utils.py
MIT
2,546
4222c4deaf1739f723f7a374bfd9a12d590dc646
Python
py
from __future__ import annotations import copy import attr import torch import numpy as np import typing from evocraft_ga.nn.linear import Linear from evocraft_ga.nn.cppn import CPPN model_dict = {"linear": Linear, "cppn": CPPN} @attr.s class Genome: noise_dims: int = attr.ib() cube_dims: int = attr.ib() ...
evocraft_ga/genome/genome.py
MIT
2,368
d7162fd4108dd4861f5ccc7ad70a2fd76d0f3072
Python
py
# 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...
tests/loggers/test_neptune.py
Apache-2.0
5,131
3ac763cc87b4f555d0416b71f947281643dba996
Python
py
# -------------------------------------------------------- # Tensorflow Faster R-CNN # Licensed under The MIT License [see LICENSE for details] # Written by Jiasen Lu, Jianwei Yang, based on code from Ross Girshick # -------------------------------------------------------- from __future__ import absolute_import from __...
test_net.py
MIT
36,213
5e859492dc6949fec7fc5a986b10f2e999e8a097
Python
py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import errno import os from functools import reduce import numpy as np import torch from torch.utils.data import DataLoader from pyro.contrib.examples.util import MNIST, get_data_directory # This file contains utilities for cach...
examples/vae/utils/mnist_cached.py
Apache-2.0
8,858
d7ad578fda8a5bb001699a012da197a0483eef52
Python
py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from cogdl.modules.conv import GATConv, SELayer from . import BaseModel, register_model @register_model("drgat") class DrGAT(BaseModel): @staticmethod def add_args(parser): """Add model-specific arguments to the pa...
cogdl/models/drgat.py
MIT
1,964
3ac78ac9b54ababe353d86ec0c4efee581c80986
Python
py
# 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...
pytorch_transformers/modeling_xlnet.py
Apache-2.0
58,149
3ac791b12194e1ab59c2dd6df74917e2be7da2ba
Python
py
import torch as th class Normalize(object): def __init__(self, mean, std): self.mean = th.FloatTensor(mean).view(1, 3, 1, 1) self.std = th.FloatTensor(std).view(1, 3, 1, 1) def __call__(self, tensor): tensor = (tensor - self.mean) / (self.std + 1e-8) return tensor class Pre...
resnets/preprocessing.py
MIT
1,323
4b6a5031e1439e173802bca534e7b21f76a21931
Python
py
""" kraken.lib.models ~~~~~~~~~~~~~~~~~ Wrapper around TorchVGSLModel including a variety of forward pass helpers for sequence classification. """ from os.path import expandvars, expanduser, abspath import torch import numpy as np import kraken.lib.lineest import kraken.lib.ctc_decoder from typing import List, Tuple...
kraken/lib/models.py
Apache-2.0
7,214
45d87b020fd86c8561ee575a8c6a7d37503aa267
Python
py
import pandas as pd import numpy as np import torch.utils.data as data from sklearn.preprocessing import MinMaxScaler import config class ElectricDataset(data.Dataset): def __init__(self, preprocessor): const = config.Constant hp = config.Hyperparameter df = pd.read_csv(const.RESERVE_MARG...
dataset/electric_dataset.py
MIT
1,097
7c6dcda5a6f15f9baeeed3e08a398f49dbed276c
Python
py
#!/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. from __future__ import annotations from typing import Optional import torch from gpytorch.constraints import Interval...
botorch/models/kernels/downsampling.py
MIT
4,143
3ac7c4ac16e6f3e2e320686a675075959a5e5460
Python
py
# python imports import signal, time, os, sys import pickle as pkl import argparse as ap # numpy imports import numpy as np # torch imports import torch import torch.autograd as ta import torch.nn.functional as F import torch.nn as nn from torch.utils import data # code imports import process_data as pd import code.dat...
analysis.py
Apache-2.0
3,234
3ac7d9d372434d203ad08596f7149bce6a847144
Python
py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from typing import List, Optional import torch import torch.nn as nn from pytorchvideo.layers.utils import set_attributes from pytorchvideo.models.weight_init import init_net_weights class Net(nn.Module): """ Build a general Net models ...
pytorchvideo/models/net.py
Apache-2.0
4,071
e990d57195904068432bdeb7b0eae02cedf1b071
Python
py
import argparse import os import torch import numpy as np from pgcn_dataset import PGCNDataSet from pgcn_models import PGCN from torch import multiprocessing from torch.utils import model_zoo from ops.utils import get_configs from ops.I3D_Pooling import I3D_Pooling from tqdm import tqdm import random parser = argparse...
pgcn_test.py
BSD-3-Clause
8,363
e92e45e26837b277c1801f6c1116ddf87873b272
Python
py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import glob import copy import re import pickle import random import sys import urllib import tarfile import zipfile import os.path as osp from scipy.io import loadmat import numpy as np import h5py i...
reid/data_manager/dukemtmcreid_tracklet.py
MIT
12,257
7c89fdf5215422383bd7f4f95dc84df2be90e4d8
Python
py
from daydayup_layer import GCN, My_APPNP, Cheb_Net, ARMA_Net, GAT_Net, SGC_Net, TAG_Net, DNA_Net import torch import torch.nn.functional as F import lightgbm as lgb from torch_geometric.nn import GCNConv, Node2Vec from torch.nn import PReLU from sklearn.linear_model import LogisticRegression from torch.utils.da...
daydayup_submit/daydayup_model.py
MIT
19,488
455cff1ee41050d4da2cdb44efe2cbea0850eeea
Python
py
# -*- coding: utf-8 -*- """ Pose models and loss functions for axis-angle representation """ import torch from torch import nn import torch.nn.functional as F import numpy as np from helperFunctions import eps """ Numpy functions """ # axis angle y = \theta v where theta is angle of rotation about axis v # y = logm...
axisAngle.py
MIT
3,286
5fbd044876babf33c265c4cb0afec031d78140f5
Python
py
# pylint: disable=E1101, E0401, E1102 import time import random import argparse import pickle import numpy as np import torch import sys from models import MNIST, CIFAR10, IMAGENET, load_model from utils import load_mnist_data, load_cifar10_data, load_imagenet_data from utils import proj, latent_proj, transform from ...
attack.py
MIT
13,234
3ac85b148500dddbc3e46e28ea21b014718f5506
Python
py
import torch from torch import nn from fsdet.modeling.roi_heads import build_roi_heads import logging from detectron2.modeling.backbone import build_backbone from detectron2.modeling.postprocessing import detector_postprocess from detectron2.modeling.proposal_generator import build_proposal_generator from detectron2....
fsdet/modeling/meta_arch/rcnn.py
Apache-2.0
13,506
a9098895175dd00dd5587f070536696f4e37db65
Python
py
import sys from itertools import product from math import ceil, floor import torch import numpy as np from seal import uIntVector, Plaintext, Ciphertext from comm import CommBase, CommFheBuilder, BlobFheRawCts, PhaseProtocolServer, PhaseProtocolClient, init_communicate, \ torch_sync, end_communicate, BlobTorch, P...
src/fully_connected.py
MIT
22,615
348154a17ddebae54cc407a7fe553b136d498b9e
Python
py
import logging from collections import defaultdict from typing import Dict, Any, List from overrides import overrides import numpy as np import torch from torch import Tensor from allennlp.common import Lazy from allennlp.data import Vocabulary from allennlp.models import Model from allennlp.modules import TextFiel...
zsee/models/sentence_level.py
Apache-2.0
11,787
652b6f2417286eed10e3f1e0c1ae6b553dea31cb
Python
py
import torch # from torch import distributed import torch.nn as nn # from apex import amp from torch.cuda import amp from functools import reduce from tqdm import tqdm from utils.loss import KnowledgeDistillationLoss, BCEWithLogitsLossWithIgnoreIndex, \ UnbiasedKnowledgeDistillationLoss, UnbiasedCrossEntropy, Icarl...
train.py
MIT
13,461
d7a046bfb1c071c595e4cf60312a8070fdfc187a
Python
py
import os from typing import Any, Callable, List import torch from ppq.core import (NetworkFramework, TargetPlatform, empty_ppq_cache, ppq_warning) from ppq.executor import TorchExecutor from ppq.IR import (BaseGraph, GraphCommand, GraphCommandType, GraphFormatter, GraphMerger...
ppq/api/interface.py
Apache-2.0
32,968
e938b658921adfb168040e7079afd89cab07d0ee
Python
py
# ==================================================== # Library # # ==================================================== import os import gc import sys import math import time import random import shutil from requests import get from pathlib import Path from contextlib import contextmanager from collections import def...
code/002/ver21/siim-002-train-effdet-ver21.py
CC-BY-4.0
35,782
7c153645b0762829101d42d8b37bd91903014504
Python
py
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license """ Experimental modules """ import math import numpy as np import torch import torch.nn as nn from .common import Conv from video_streamer.utils.downloads import attempt_download class CrossConv(nn.Module): # Cross Convolution Downsample def __init__(self, c1, c2...
video_streamer/models/experimental.py
MIT
4,672
4baa00aac5c7c244eeda1947ed11361c3dd9f6e0
Python
py
import math import torch from tqdm import tqdm from torch.utils.data import DataLoader from transformers import GPT2Config, GPT2Tokenizer, GPT2LMHeadModel from core.utils.parser import get_test_parser from core.models.huggingface.parser import add_cmdline_args_gen from core.data.empdataset import EmpatheticDataset fro...
experiments/baselines/test_gpt2.py
MIT
3,847
3ac8be379038300757a79c4084c38ae1e50416ad
Python
py
from functools import partial from collections import OrderedDict import torch.nn.init as init import torch import torch.nn as nn import torch.nn.functional as F import torchvision.models as models from Models.layers import ConvBnRelu from opts import _nostride2dilation # ResNet34 Based class PSPNet(nn.Module): ...
Models/PSPNet.py
MIT
4,058
65178f11422cd2833a89773115b1edfed0ba2fe7
Python
py
#!/usr/bin/python3 from __future__ import print_function import os import sys import torch import torch.backends.cudnn as cudnn import argparse import cv2 import numpy as np from collections import OrderedDict import time sys.path.append(os.getcwd() + '/../../src') from config import cfg from prior_box import PriorB...
tasks/task1/inference.py
MIT
10,208
24c703970fc1c3ea90ec59a79eaf8be20e04b3d9
Python
py
import torch import numpy as np import pdb class PatchAttacker: def __init__(self, model, mean, std, kwargs): std = torch.tensor(std) mean = torch.tensor(mean) self.epsilon = kwargs["epsilon"] / std self.steps = kwargs["steps"] self.step_size = kwargs["step_size"] / std ...
attacks/patch_attacker.py
BSD-2-Clause
4,693
b292278edbe85e5f3045bcff6fe45ff10d394210
Python
py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import logging from collections import defaultdict from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union import torch from fvcore.common.param_scheduler import CosineParamScheduler, MultiSt...
detectron2/solver/build.py
Apache-2.0
11,664
d79e23a60f24f1cbd0d2c98359d056bba419b1f1
Python
py
import torch import torch.nn as nn class PolypDet(nn.Module): def __init__(self): super(PolypDet, self).__init__() def CBR2d( input_channels: int, output_channels: int, kernel_size: int = 3, stride: int = 1, padding: int = 1, ...
medimodule/Abdomen/models/polyp_det.py
Apache-2.0
5,107
3ac926cc99fe68a27993f582ed0630800e4ce9fb
Python
py
""" @file : run_cls.py @author : xiaolu @email : luxiaonlp@163.com @time : 2022-01-05 """ import os import copy import torch import json import random from tqdm import tqdm import numpy as np from torch import nn from config import set_args from model import Model from sklearn import metrics import torch.nn.functi...
Roberta+RDrop/run_cls_iflytek.py
Apache-2.0
6,400
45bd5080a59b82626449bb1306ee93d12879db46
Python
py
"""Data processor for SMP-CAIL2020-Argmine. Author: Tsinghuaboy (tsinghua9boy@sina.com) In data file, each line contains 1 sc sentence and 5 bc sentences. The data processor convert each line into 5 samples, each sample with 1 sc sentence and 1 bc sentence. Usage: 1. Tokenizer (used for RNN model): from data imp...
CAIL2020/lbwjx/data.py
Apache-2.0
14,736
3ac933890a16d11871f262ac987aed299f7ea93f
Python
py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch class BalancedPositiveNegativeSampler(object): """ This class samples batches, ensuring that they contain a fixed proportion of positives """ def __init__(self, batch_size_per_image, positive_fraction): """ ...
maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py
BSD-2-Clause
2,764
701d4e78d79b13e44c69cfb7bb93de0c407ea7d7
Python
py
import argparse import os import numpy as np import math import itertools import torchvision.transforms as transforms from torchvision.utils import save_image from torch.utils.data import DataLoader from torchvision import datasets from torch.autograd import Variable from mnistm import MNISTM import torch.nn as nn ...
.history/implementations/pixelda/pixelda_try_20190106193210.py
MIT
18,277
fdabd5b70d1d5380a87819d468aa66e0632ba20b
Python
py
import yaml import argparse import os import sys import inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) print(sys.path) import gym import torch from rlkit.envs import get_env, get_envs from rlkit.envs...
run_scripts/ppo_exp_script.py
MIT
3,535
3ac96760096e5ff5e6af6938d71b30abd517c05c
Python
py
import torch import numpy as np import load_data import trainer import models import matplotlib.pyplot as plt from hyperparameters import * MODEL_PATH = './model.pt' SAMPLES = 10 def show_model_result_enc_dec(model, loader): image = load_data.get_dataset_image(loader) (x, target) = next(iter(loader)) r...
code/utils.py
MIT
3,364
5eb146b0795815e6d38f702c79e698e5cb80617e
Python
py
# -*- coding: utf-8 -*- """ Created on Fri Jan 29 11:39:53 2021 @author: ayman """ import joblib import torch import argparse import random import numpy as np from lib import game, mcts, model def get_action(game, net, mcts_, cur_state,cur_player, search_depth, batch_size, device): if net is None: action...
Connect4/play_human.py
MIT
4,979
3ac9a0702646907e73f0b838d2f5839242d7b7e1
Python
py
import torch import torch.nn as nn import torch.nn.functional as F from torchvision.models.resnet import BasicBlock, conv1x1, resnet34 from argparse import Namespace import sys sys.path.append("flownet2_pytorch") from flownet2_pytorch.networks import FlowNetC class FlowNet2C(FlowNetC.FlowNetC): def __init__(se...
models/flow_net_c.py
MIT
3,248
4590ff05fcf396e954a6834f634133650873cdbf
Python
py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # # 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 ...
wenet/transformer/label_smoothing_loss.py
Apache-2.0
3,459
428fedcb0eb4345cd1361c97008a9afcd94ac171
Python
py
from __future__ import division, print_function, absolute_import import torch def accuracy(output: torch.Tensor, target: torch.LongTensor, topk=(1, )): """Computes the accuracy over the k top predictions for the specified values of k. Args: output (torch.Tensor): prediction matrix with shape (bat...
torchreid/metrics/accuracy.py
MIT
1,179
3ac9bf135ad98d304051451ffa1098026441a918
Python
py
import math import torch import torch.nn as nn from models.common_utils import normalization, inv_forward __all__ = ['vgg11_inv', 'vgg13_inv', 'vgg16_inv', 'vgg19_inv'] cfg = { 'vgg11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'], 'vgg13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512,...
models/imagenet_models/vgg_inv.py
Apache-2.0
4,630
dfd3c0c124d7a3aef06e20093a03b9b78866bbe2
Python
py
import argparse import os from typing import Dict, List, Any import numpy as np import torch from torch.autograd import Variable from policies.models.actor_critic import ACTOR_CRITIC from policies.dqn import Policy as DQN_POLICY class Policy(DQN_POLICY): def __init__(self, params: argparse) -> None: sup...
policies/a2c.py
MIT
5,264
d7932c9ac2b09c725c3d8cb9b69bc5560300fb45
Python
py
import gym import torch import json import os import yaml from tqdm import trange import maml_rl.envs from maml_rl.metalearners import MAMLTRPO from maml_rl.baseline import LinearFeatureBaseline from maml_rl.samplers import MultiTaskSampler from maml_rl.utils.helpers import get_policy_for_env, get_input_size from maml...
train.py
MIT
4,735
dfbb0104f91bd03cf012eb491b0bda92d843c110
Python
py
# RAngerQH - @lessw2020 github # 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. # https://github.com/lessw2020/RangerQH-Testing/blob/master/rangerqh.py import torch from torch.optim.optimiz...
optimizers/rangerqh.py
MIT
8,723
3aca097848702730540ca8ca884e2780d6cb955e
Python
py
import tensorflow as tf import tensorboard as tb tf.io.gfile = tb.compat.tensorflow_stub.io.gfile import os import sys import time import torch import random import numpy as np from argparse import Namespace from options.train_options import TrainOptions from data import create_dataset from models import create_mode...
train_aerial.py
MIT
8,383
3aca0c519d1659b42bdbc7fcea2405f866c6c229
Python
py
#----------------------------------------------------------------------------- # Dataset and Dataloader related function and class #----------------------------------------------------------------------------- import torch, torchvision from collections import Counter from random import seed, choice, sample import json...
DataLoader.py
MIT
8,756
4263b5e80ed419dcb2078565a453be395657e7f5
Python
py
# -*- encoding: utf-8 -*- """ @File : mbv3.py @Time : 2021/5/11 15:35 @Author : Zhl @Desc : """ """ Creates a MobileNetV3 Model as defined in: Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, Quoc V. Le, Hartwig Adam. (20...
nets/mbv3.py
MIT
7,852
1e619ad0629b291bb6d188a7f662b2c194deeb18
Python
py
from tkinter import Place from numpy import dtype import park from PlotUtils import PlotHelper from stable_baselines3 import PPO, A2C, DDPG import torch from torch import nn import torch.nn.functional as F from torch_geometric.data import Data from torch_geometric.nn import GCNConv import numpy as np from stable_base...
agents/tf_placement.py
MIT
3,724
3aca4a6638201ff64f47000406ee39ec78f562b3
Python
py
# 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...
GraphCodeBERT/refinement/run.py
MIT
29,129
e6135bb27f8dcb45c5e3bd45c5bc78ee344df2ef
Python
py
import pytorch_lightning as pl import torch from PIL import Image from src.utils import transform_augmentation, transform_inference from torch.utils.data import DataLoader, Dataset class Covid19(Dataset): def __init__(self, x, y, transforms): self.x = x self.y = y self.transforms = transfo...
modeling/src/pl_datamodule.py
MIT
1,870
3aca5432e7d33f139aee8551fdf7c22d2594fba8
Python
py
import os import shutil import numpy as np import torch import torch.nn as nn import torch.optim as optim from torchvision.utils import save_image from torch.utils.data import DataLoader from torch.utils.tensorboard import SummaryWriter import pytorch_ssim from config import Config as _config from model.rgb_edsr imp...
train_rgb.py
MIT
3,407
3aca6259b7db754f5b50832810181384d8d92f2f
Python
py
import torch import random import os from PIL import Image from dataset.clip_generator import CHARACTER_ENCODING from training import BASE_SYMBOLS from training.tacotron2_model.utils import get_mask_from_lengths CHECKPOINT_SIZE_MB = 333 BATCH_SIZE_PER_GB = 2.5 LEARNING_RATE_PER_64 = 4e-4 MAXIMUM_LEARNING_RATE = 4e-4...
training/utils.py
BSD-3-Clause
5,197
3aca6a8baab5d3a4738da449c101b476ed120cac
Python
py