repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
AdaSVRG | AdaSVRG-master/dependencies.py | #!/usr/bin/env python
import math
import numpy as np
import random
import torch
import matplotlib.pyplot as plt
import os
from sklearn.model_selection import train_test_split
import pickle
from sklearn import datasets, metrics
import urllib
import numpy as np
from sklearn.svm import SVC
from sklearn.datasets import lo... | 338 | 18.941176 | 52 | py |
AdaSVRG | AdaSVRG-master/haven/haven_chk.py | import shutil
import os, torch
from . import haven_utils as hu
def delete_experiment(savedir, backup_flag=False):
"""Delete an experiment. If the backup_flag is true it moves the experiment
to the delete folder.
Parameters
----------
savedir : str
Directory of the experiment
back... | 3,598 | 29.243697 | 99 | py |
AdaSVRG | AdaSVRG-master/haven/tools/transformers.py |
# Transformers
import collections
import numpy as np
import torch
from torchvision import transforms
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
def get_transformer(transform, split):
if transform == "resize_normalize":
normalize_transform = transforms.Normalize(mean=mean, std=std)
... | 2,459 | 28.285714 | 85 | py |
AdaSVRG | AdaSVRG-master/haven/tools/ap_metrics.py |
import numpy as np
import copy
import pycocotools.mask as mask_util
from itertools import product
import torch
class APMonitor:
def __init__(self):
self.pred_ann_list = []
self.gt_ann_list = []
self.n_batches = 0.
self.iou_thr = 0.5
self.iou_thr_list = [0.5, 0.75]
de... | 19,983 | 31.760656 | 109 | py |
AdaSVRG | AdaSVRG-master/haven/haven_utils/__init__.py | import contextlib
import copy
import hashlib
import itertools
import json
from .. import haven_img as hi
import pprint
import os
import pickle
import shlex
import subprocess
import threading
import time
import numpy as np
import pylab as plt
import torch
from .image_utils import *
from .file_utils import *
from .strin... | 26,238 | 23.753774 | 120 | py |
DescEmb | DescEmb-master/main.py | import argparse
import logging
import logging.config
import random
import os
import sys
# should setup root logger before importing any relevant libraries.
logging.basicConfig(
format="%(asctime)s | %(levelname)s %(name)s %(message)s)))",
datefmt="%Y-%m-%d %H:%M:%S",
level = os.environ.get("LOGLEVEL", "INF... | 6,159 | 30.589744 | 118 | py |
DescEmb | DescEmb-master/modules/identity_layer.py | import torch.nn as nn
class IdentityLayer(nn.Module):
def __init__(self):
super().__init__()
def forward(self, source):
return source | 163 | 19.5 | 31 | py |
DescEmb | DescEmb-master/modules/subword_input_layer.py | import torch.nn as nn
class SubwordInputLayer(nn.Module):
def __init__(self, args):
super().__init__()
enc_embed_dim = args.enc_embed_dim
# index_size = subword_index_size_dict[concat_type][source_file]
index_size = 28996
self.embedding =nn.Embedding(index_size, enc_embed_d... | 423 | 27.266667 | 78 | py |
DescEmb | DescEmb-master/models/descemb.py | import logging
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
from transformers import AutoConfig, AutoModel
from models import register_model
from modules import (
SubwordInputLayer,
IdentityLayer
)
logger = logging.getLogger(__name__)
@register... | 8,091 | 36.290323 | 115 | py |
DescEmb | DescEmb-master/models/word2vec.py | import torch
import torch.nn as nn
from models import register_model
# reference: https://github.com/blackredscarf/pytorch-SkipGram/blob/a9fa5a888a7b0c6170eb1fe146e59f54041b2613/model.py
@register_model(name="word2vec")
class Word2VecModel(nn.Module):
"""
Word2Vec in skipgram
"""
def __init__(self, v... | 1,331 | 36 | 117 | py |
DescEmb | DescEmb-master/models/codeemb.py | import logging
import torch
import torch.nn as nn
from models import register_model
logger = logging.getLogger(__name__)
@register_model("codeemb")
class CodeEmb(nn.Module):
def __init__(self, args):
super().__init__()
index_size_dict = {
'nonconcat' : {
'mimic' : 188... | 2,165 | 26.769231 | 85 | py |
DescEmb | DescEmb-master/models/rnn.py | import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
from models import register_model
@register_model("rnn")
class RNNModel(nn.Module):
def __init__(self, args):
super().__init__()
self.pred_embed_dim = args.pred_embed_dim
self.pred_hidden_dim = a... | 1,489 | 28.215686 | 95 | py |
DescEmb | DescEmb-master/models/ehr_model.py | import os
import logging
import torch
from torch._C import Value
import torch.nn as nn
from models import register_model, MODEL_REGISTRY
logger = logging.getLogger(__name__)
@register_model("ehr_model")
class EHRModel(nn.Module):
def __init__(self, args):
super().__init__()
self.args = args
... | 3,300 | 33.030928 | 88 | py |
DescEmb | DescEmb-master/datasets/dataset.py | import os
import logging
import random
import collections
import torch
import torch.utils.data
import numpy as np
import pandas as pd
from transformers import AutoTokenizer
logger = logging.getLogger(__name__)
class BaseDataset(torch.utils.data.Dataset):
def __init__(
self,
input_path,
... | 15,091 | 31.179104 | 120 | py |
DescEmb | DescEmb-master/preprocess/prcs.py | import torch
import numpy as np
from joblib import Parallel, delayed
# tokenized DSVA df
def multi_prcs(input_ids, token_types, tokenizer):
valued_token_type_ids = []
for idcs, token_type in zip(input_ids, token_types):
def decode_transform(idx, n_digits, is_decimal):
try:
... | 2,258 | 35.435484 | 157 | py |
DescEmb | DescEmb-master/utils/trainer_utils.py | import os
import logging
import numpy as np
import torch
from collections import OrderedDict
from contextlib import contextmanager
logger = logging.getLogger(__name__)
def should_stop_early(patience, valid_auprc: float) -> bool:
if valid_auprc is None:
return False
if patience <= 0:
return Fa... | 2,988 | 32.965909 | 108 | py |
DescEmb | DescEmb-master/trainers/word2vec_trainer.py | import os
import logging
import torch
import torch.optim as optim
from torch.utils.data import DataLoader
from datasets.dataset import Word2VecDataset
from models.word2vec import Word2VecModel
from utils.trainer_utils import rename_logger, EarlyStopping
logger = logging.getLogger(__name__)
class Word2VecTrainer():
... | 3,436 | 32.696078 | 109 | py |
DescEmb | DescEmb-master/trainers/trainer.py | import os
import logging
import pprint
import tqdm
import torch
import torch.nn as nn
from sklearn.metrics import roc_auc_score, average_precision_score
from torch.nn.parallel.data_parallel import DataParallel
from torch.utils.data import DataLoader
from utils.trainer_utils import (
rename_logger,
should_sto... | 10,651 | 33.92459 | 105 | py |
FedForgery | FedForgery-main/test.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python version: 3.6
from tqdm import tqdm
import torch
import cv2
from torch import nn
from torch.autograd import Variable
from torch.utils.data import DataLoader, Dataset
import numpy as np
import torch.nn.functional as F
from options import args_parser
from src.models ... | 4,095 | 30.507692 | 86 | py |
FedForgery | FedForgery-main/networks/vae.py | from __future__ import print_function
import abc
import os
import math
import numpy as np
import logging
import torch
import torch.utils.data
from torch import nn
from torch.nn import init
from torch.nn import functional as F
from torch.autograd import Variable
import pdb
import sys
from .resnet import resnet50
from .n... | 7,668 | 30.559671 | 98 | py |
FedForgery | FedForgery-main/networks/nearest_embed.py | import numpy as np
import torch
from torch import nn
from torch.autograd import Function, Variable
import torch.nn.functional as F
class NearestEmbedFunc(Function):
"""
Input:
------
x - (batch_size, emb_dim, *)
Last dimensions may be arbitrary
emb - (emb_dim, num_emb)
"""
@staticme... | 5,195 | 37.776119 | 119 | py |
SymbolEmergence-VAE-GMM | SymbolEmergence-VAE-GMM-master/main.py | import os
import numpy as np
from scipy.stats import wishart, multivariate_normal
import matplotlib.pyplot as plt
from tool import calc_ari,cmx
from sklearn.metrics import cohen_kappa_score
from sklearn.metrics.cluster import adjusted_rand_score as ari
import torch
from torchvision import datasets, transforms
from torc... | 18,852 | 54.778107 | 200 | py |
SymbolEmergence-VAE-GMM | SymbolEmergence-VAE-GMM-master/cnn_vae_module_mnist.py | from __future__ import print_function
import torch
from torch import nn, optim
from torch.nn import functional as F
from torchvision.utils import save_image
import numpy as np
import matplotlib.pyplot as plt
from tool import visualize_ls, sample, get_param
device = torch.device('cuda:0' if torch.cuda.is_available() el... | 9,126 | 43.960591 | 300 | py |
SymbolEmergence-VAE-GMM | SymbolEmergence-VAE-GMM-master/recall_image.py | import os
import numpy as np
from scipy.stats import wishart
import matplotlib.pyplot as plt
from tool import calc_ari, visualize_gmm
from sklearn.metrics import cohen_kappa_score
import torch
from torchvision import datasets, transforms
from torchvision.utils import save_image
from torch.utils.data.dataset import Sub... | 7,084 | 58.537815 | 156 | py |
cddod | cddod-master/trainval_net_global_local.py | # coding:utf-8
# --------------------------------------------------------
# Pytorch multi-GPU 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 a... | 18,136 | 35.640404 | 167 | py |
cddod | cddod-master/vis_utils/vis_utils.py | import colorsys
import imghdr
import os
import random
# from keras import backend as K
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from matplotlib.pyplot import imshow
import PIL
import imageio
def read_classes(classes_path):
with open(classes_path) as f:
class_names = f.readlines()
... | 4,522 | 27.26875 | 143 | py |
cddod | cddod-master/lib/roi_data_layer/roibatchLoader.py |
"""The data layer used during training to train a Fast R-CNN network.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch.utils.data as data
from PIL import Image
import torch
from model.utils.config import cfg
from roi_data_layer.minibatch i... | 10,666 | 37.930657 | 144 | py |
cddod | cddod-master/lib/roi_data_layer/minibatch.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Xinlei Chen
# --------------------------------------------------------
"""Compute minibatch blobs for training a Fast R-CNN ne... | 3,606 | 29.82906 | 115 | py |
cddod | cddod-master/lib/model/roi_crop/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
#this_file = os.path.dirname(__file__)
sources = ['src/roi_crop.c']
headers = ['src/roi_crop.h']
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['sr... | 881 | 22.837838 | 75 | py |
cddod | cddod-master/lib/model/roi_crop/functions/gridgen.py | # functions/add.py
import torch
from torch.autograd import Function
import numpy as np
class AffineGridGenFunction(Function):
def __init__(self, height, width,lr=1):
super(AffineGridGenFunction, self).__init__()
self.lr = lr
self.height, self.width = height, width
self.grid = np.ze... | 2,233 | 46.531915 | 171 | py |
cddod | cddod-master/lib/model/roi_crop/functions/crop_resize.py | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
from cffi import FFI
ffi = FFI()
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1
self.input2 = input2
self.device_c = ffi.new("int *")
output = to... | 1,545 | 39.684211 | 126 | py |
cddod | cddod-master/lib/model/roi_crop/functions/roi_crop.py | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
import pdb
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1.clone()
self.input2 = input2.clone()
output = input2.new(input2.size()[0], input1.size()[1], in... | 1,002 | 44.590909 | 122 | py |
cddod | cddod-master/lib/model/roi_crop/modules/gridgen.py | from torch.nn.modules.module import Module
import torch
from torch.autograd import Variable
import numpy as np
from ..functions.gridgen import AffineGridGenFunction
import pyximport
pyximport.install(setup_args={"include_dirs":np.get_include()},
reload_support=True)
class _AffineGridGen(Module):
... | 16,532 | 38.838554 | 170 | py |
cddod | cddod-master/lib/model/roi_crop/modules/roi_crop.py | from torch.nn.modules.module import Module
from ..functions.roi_crop import RoICropFunction
class _RoICrop(Module):
def __init__(self, layout = 'BHWD'):
super(_RoICrop, self).__init__()
def forward(self, input1, input2):
return RoICropFunction()(input1, input2)
| 287 | 31 | 48 | py |
cddod | cddod-master/lib/model/roi_crop/_ext/crop_resize/__init__.py |
from torch.utils.ffi import _wrap_function
from ._crop_resize import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
locals[symbol] = _wrap_function(fn, _ffi)
__all__.append(symbol)
_import_symbols(locals())
| 310 | 22.923077 | 50 | py |
cddod | cddod-master/lib/model/roi_crop/_ext/roi_crop/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_crop import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] =... | 382 | 22.9375 | 53 | py |
cddod | cddod-master/lib/model/faster_rcnn/faster_rcnn.py | import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models as models
from torch.autograd import Variable
import numpy as np
from model.utils.config import cfg
from model.rpn.rpn import _RPN
from model.roi_pooling.modules.roi_pool import... | 5,788 | 40.949275 | 138 | py |
cddod | cddod-master/lib/model/faster_rcnn/loss.py | import torch
import torch.nn as nn
class SegmentationLosses(object):
def __init__(self, weight=None, size_average=True, batch_average=True, ignore_index=255, cuda=False):
self.ignore_index = ignore_index
self.weight = weight
self.size_average = size_average
self.batch_average = batc... | 1,936 | 29.746032 | 105 | py |
cddod | cddod-master/lib/model/faster_rcnn/faster_rcnn_local.py | import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models as models
from torch.autograd import Variable
import numpy as np
from model.utils.config import cfg
from model.rpn.rpn import _RPN
from model.roi_pooling.modules.roi_pool import... | 6,403 | 41.693333 | 138 | py |
cddod | cddod-master/lib/model/faster_rcnn/faster_rcnn_global_local.py | import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models as models
from torch.autograd import Variable
import numpy as np
from model.utils.config import cfg
from model.rpn.rpn import _RPN
from model.roi_pooling.modules.roi_pool import... | 6,953 | 40.891566 | 138 | py |
cddod | cddod-master/lib/model/faster_rcnn/faster_rcnn_global.py | import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models as models
from torch.autograd import Variable
import numpy as np
from model.utils.config import cfg
from model.rpn.rpn import _RPN
from model.roi_pooling.modules.roi_pool import... | 6,452 | 42.308725 | 138 | py |
cddod | cddod-master/lib/model/faster_rcnn/resnet_global_local.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from model.utils.config import cfg
from model.faster_rcnn.faster_rcnn_global_local import _fasterRCNN
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
... | 12,389 | 30.367089 | 104 | py |
cddod | cddod-master/lib/model/roi_align/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
sources = ['src/roi_align.c']
headers = ['src/roi_align.h']
extra_objects = []
#sources = []
#headers = []
defines = []
with_cuda = False
this_file = os.path.dirname(os.path.realpath(__file__))
print(this_file)
... | 902 | 22.153846 | 79 | py |
cddod | cddod-master/lib/model/roi_align/functions/roi_align.py | import torch
from torch.autograd import Function
from .._ext import roi_align
# TODO use save_for_backward instead
class RoIAlignFunction(Function):
def __init__(self, aligned_height, aligned_width, spatial_scale):
self.aligned_width = int(aligned_width)
self.aligned_height = int(aligned_height)
... | 2,006 | 37.596154 | 102 | py |
cddod | cddod-master/lib/model/roi_align/modules/roi_align.py | from torch.nn.modules.module import Module
from torch.nn.functional import avg_pool2d, max_pool2d
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, aligned_height, aligned_width, spatial_scale):
super(RoIAlign, self).__init__()
self.aligned_width = int(... | 1,945 | 36.423077 | 78 | py |
cddod | cddod-master/lib/model/roi_align/_ext/roi_align/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_align import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] ... | 383 | 23 | 53 | py |
cddod | cddod-master/lib/model/rpn/proposal_layer.py | from __future__ import absolute_import
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ---------------... | 7,132 | 38.849162 | 120 | py |
cddod | cddod-master/lib/model/rpn/rpn_fpn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from model.utils.config import cfg
from .proposal_layer_fpn import _ProposalLayer_FPN
from .anchor_target_layer_fpn import _AnchorTargetLayer_FPN
from model.utils.net_utils import _smooth_l1_loss
import numpy as np
... | 5,503 | 40.383459 | 114 | py |
cddod | cddod-master/lib/model/rpn/bbox_transform.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
# --------------------------------------------------------
# Reorganized... | 9,288 | 35.003876 | 100 | py |
cddod | cddod-master/lib/model/rpn/proposal_target_layer.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ------------------------------------------------------... | 9,571 | 43.110599 | 104 | py |
cddod | cddod-master/lib/model/rpn/proposal_layer_fpn.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ------------------------------------------------------... | 5,589 | 38.928571 | 145 | py |
cddod | cddod-master/lib/model/rpn/rpn.py | from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from model.utils.config import cfg
from .proposal_layer import _ProposalLayer
from .anchor_target_layer import _AnchorTargetLayer
from model.utils.net_utils import _smooth_l1_lo... | 4,336 | 37.380531 | 109 | py |
cddod | cddod-master/lib/model/rpn/anchor_target_layer_fpn.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ------------------------------------------------------... | 8,365 | 40.621891 | 128 | py |
cddod | cddod-master/lib/model/rpn/anchor_target_layer.py | from __future__ import absolute_import
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ---------------... | 8,999 | 39.909091 | 128 | py |
cddod | cddod-master/lib/model/rpn/proposal_target_layer_cascade.py | from __future__ import absolute_import
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
# ---------------... | 9,420 | 43.230047 | 104 | py |
cddod | cddod-master/lib/model/utils/config.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import os.path as osp
import numpy as np
# `pip install easydict` if you don't have it
from easydict import EasyDict as edict
__C = edict()
# Consumers can get config by:
# from fast_rcnn_config im... | 12,378 | 28.334123 | 91 | py |
cddod | cddod-master/lib/model/utils/net_utils.py | # coding:utf-8
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable,Function
import numpy as np
import torchvision.models as models
from model.utils.config import cfg
from model.roi_crop.functions.roi_crop import RoICropFunction
import cv2
import pdb
import random
from... | 18,195 | 34.539063 | 125 | py |
cddod | cddod-master/lib/model/utils/.ipynb_checkpoints/config-checkpoint.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import os.path as osp
import numpy as np
# `pip install easydict` if you don't have it
from easydict import EasyDict as edict
__C = edict()
# Consumers can get config by:
# from fast_rcnn_config im... | 12,026 | 28.769802 | 91 | py |
cddod | cddod-master/lib/model/roi_pooling/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
sources = ['src/roi_pooling.c']
headers = ['src/roi_pooling.h']
extra_objects = []
defines = []
with_cuda = False
this_file = os.path.dirname(os.path.realpath(__file__))
print(this_file)
if torch.cuda.is_availa... | 875 | 22.675676 | 79 | py |
cddod | cddod-master/lib/model/roi_pooling/functions/roi_pool.py | import torch
from torch.autograd import Function
from .._ext import roi_pooling
import pdb
class RoIPoolFunction(Function):
def __init__(ctx, pooled_height, pooled_width, spatial_scale):
ctx.pooled_width = pooled_width
ctx.pooled_height = pooled_height
ctx.spatial_scale = spatial_scale
... | 1,773 | 44.487179 | 108 | py |
cddod | cddod-master/lib/model/roi_pooling/modules/roi_pool.py | from torch.nn.modules.module import Module
from ..functions.roi_pool import RoIPoolFunction
class _RoIPooling(Module):
def __init__(self, pooled_height, pooled_width, spatial_scale):
super(_RoIPooling, self).__init__()
self.pooled_width = int(pooled_width)
self.pooled_height = int(pooled_... | 524 | 34 | 105 | py |
cddod | cddod-master/lib/model/roi_pooling/_ext/roi_pooling/__init__.py |
from torch.utils.ffi import _wrap_function
from ._roi_pooling import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol... | 385 | 23.125 | 53 | py |
cddod | cddod-master/lib/model/nms/nms_wrapper.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
import torch
from model.utils.config import cfg
if torch.cuda.is_availab... | 757 | 33.454545 | 81 | py |
cddod | cddod-master/lib/model/nms/nms_gpu.py | from __future__ import absolute_import
import torch
import numpy as np
from ._ext import nms
import pdb
def nms_gpu(dets, thresh):
keep = dets.new(dets.size(0), 1).zero_().int()
num_out = dets.new(1).zero_().int()
nms.nms_cuda(keep, dets, num_out, thresh)
keep = keep[:num_out[0]]
return keep
| 299 | 22.076923 | 47 | py |
cddod | cddod-master/lib/model/nms/nms_cpu.py | from __future__ import absolute_import
import numpy as np
import torch
def nms_cpu(dets, thresh):
dets = dets.numpy()
x1 = dets[:, 0]
y1 = dets[:, 1]
x2 = dets[:, 2]
y2 = dets[:, 3]
scores = dets[:, 4]
areas = (x2 - x1 + 1) * (y2 - y1 + 1)
order = scores.argsort()[::-1]
keep = []... | 862 | 23.657143 | 59 | py |
cddod | cddod-master/lib/model/nms/build.py | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
#this_file = os.path.dirname(__file__)
sources = []
headers = []
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['src/nms_cuda.c']
headers += ['... | 850 | 21.394737 | 75 | py |
cddod | cddod-master/lib/model/nms/_ext/nms/__init__.py |
from torch.utils.ffi import _wrap_function
from ._nms import lib as _lib, ffi as _ffi
__all__ = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
if callable(fn):
locals[symbol] = _wrap_function(fn, _ffi)
else:
locals[symbol] = fn
... | 377 | 22.625 | 53 | py |
cddod | cddod-master/log_utils/utils.py | from __future__ import print_function
import os
import os.path as osp
# import cPickle as pickle
from scipy import io
import datetime
import time
from contextlib import contextmanager
import torch
from torch.autograd import Variable
def time_str(fmt=None):
if fmt is None:
fmt = '%Y-%m-%d_%H:%M:%S'
return dat... | 18,113 | 28.792763 | 79 | py |
dien | dien-master/script/utils.py | import tensorflow as tf
from tensorflow.python.ops.rnn_cell import *
from tensorflow.python.ops.rnn_cell_impl import _Linear
from tensorflow import keras
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import v... | 16,378 | 39.542079 | 152 | py |
signatory | signatory-master/setup.py | # Copyright 2019 Patrick Kidger. 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 law... | 3,145 | 42.694444 | 179 | py |
signatory | signatory-master/command.py | # Copyright 2019 Patrick Kidger. 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 law... | 15,408 | 44.055556 | 141 | py |
signatory | signatory-master/examples/example2.py | # Copyright 2019 Patrick Kidger. 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 law o... | 2,379 | 43.074074 | 83 | py |
signatory | signatory-master/examples/example1.py | # Copyright 2019 Patrick Kidger. 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 law o... | 2,296 | 42.339623 | 84 | py |
signatory | signatory-master/examples/example3.py | # Copyright 2019 Patrick Kidger. 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 law o... | 3,381 | 45.972222 | 83 | py |
signatory | signatory-master/.github/workflows_templates/from_template.py | # Copyright 2019 Patrick Kidger. 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 law o... | 14,882 | 39.008065 | 186 | py |
signatory | signatory-master/src/signatory/signature_module.py | # Copyright 2019 Patrick Kidger. 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 law... | 21,887 | 47.64 | 280 | py |
signatory | signatory-master/src/signatory/logsignature_module.py | # Copyright 2019 Patrick Kidger. 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 law... | 17,758 | 42.633907 | 120 | py |
signatory | signatory-master/src/signatory/deprecated.py | # Copyright 2019 Patrick Kidger. 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 law o... | 1,734 | 37.555556 | 115 | py |
signatory | signatory-master/src/signatory/augment.py | # Copyright 2019 Patrick Kidger. 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 law... | 9,175 | 45.110553 | 119 | py |
signatory | signatory-master/src/signatory/signature_inversion_module.py | import torch
from . import signature_module as smodule
from typing import Optional
def get_insertion_matrix(signature, insertion_position, depth, channels):
"""This function creates the matrix corresponding to the insertion map, used in the optimization problem.
Arguments:
signature (:class:`torch... | 5,304 | 44.732759 | 120 | py |
signatory | signatory-master/src/signatory/path.py | # Copyright 2019 Patrick Kidger. 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 law o... | 26,438 | 46.2125 | 120 | py |
signatory | signatory-master/src/signatory/__init__.py | # Copyright 2019 Patrick Kidger. 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 law... | 2,692 | 41.746032 | 119 | py |
signatory | signatory-master/test/test_signature_to_logsignature.py | # Copyright 2019 Patrick Kidger. 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 law o... | 12,356 | 47.649606 | 120 | py |
signatory | signatory-master/test/test_logsignature.py | # Copyright 2019 Patrick Kidger. 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 law o... | 19,387 | 43.46789 | 120 | py |
signatory | signatory-master/test/test_examples.py | # Copyright 2019 Patrick Kidger. 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 law o... | 1,497 | 26.740741 | 89 | py |
signatory | signatory-master/test/test_signature.py | # Copyright 2019 Patrick Kidger. 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 law o... | 21,145 | 46.626126 | 120 | py |
signatory | signatory-master/test/test_signature_inversion.py | import torch
from helpers import validation as v
tests = ['invert_signature']
depends = ['signature']
signatory = v.validate_tests(tests, depends)
def test_inverted_path_shape():
"""Tests that the inverted path is of the right shape"""
for batch_size in (1, 2, 5):
for input_stream in (2, 3, 10):
... | 2,275 | 42.769231 | 128 | py |
signatory | signatory-master/test/test_path.py | # Copyright 2019 Patrick Kidger. 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 law o... | 16,046 | 39.420655 | 120 | py |
signatory | signatory-master/test/test_signature_combine.py | # Copyright 2019 Patrick Kidger. 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 law o... | 12,620 | 45.400735 | 118 | py |
signatory | signatory-master/test/helpers/reimplementation.py | # Copyright 2019 Patrick Kidger. 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 law o... | 3,122 | 41.202703 | 118 | py |
signatory | signatory-master/test/helpers/helpers.py | # Copyright 2019 Patrick Kidger. 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 law o... | 5,067 | 36.264706 | 119 | py |
signatory | signatory-master/docs/conf.py | import os
import sys
sys.path.extend([os.path.abspath('mock'), # import torch, numpy
os.path.abspath('..'), # import metadata
os.path.abspath('../src')]) # import signatory
import metadata
project = metadata.project.title()
copyright = metadata.copyright
author = metada... | 1,198 | 28.975 | 110 | py |
signatory | signatory-master/docs/mock/torch/__init__.py | # I don't think any other approach can work in general: there's no way for something asking for e.g. torch.Tensor to
# know if that's a class, module, function...
class Tensor:
pass
class Size:
pass
| 211 | 18.272727 | 116 | py |
signatory | signatory-master/docs/_static/inversion/generate_images.py | import matplotlib
import matplotlib.pyplot as plt
import math
import signatory
import torch
matplotlib.rc('text', usetex=True)
matplotlib.rc('font', size=10)
def save(name):
plt.tight_layout()
plt.savefig(name)
plt.close()
time = torch.linspace(0, 1, 10)
path = torch.stack([torch.cos(math.pi * time), t... | 752 | 25.892857 | 112 | py |
signatory | signatory-master/benchmark/benchmark.py | # Copyright 2019 Patrick Kidger. 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 law o... | 18,157 | 42.966102 | 132 | py |
signatory | signatory-master/benchmark/memory.py | # Copyright 2019 Patrick Kidger. 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 law o... | 2,737 | 35.506667 | 120 | py |
signatory | signatory-master/benchmark/time_.py | # Copyright 2019 Patrick Kidger. 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 law o... | 1,714 | 31.358491 | 120 | py |
signatory | signatory-master/benchmark/functions/signatory_signature_backward_no_parallel.py | # Copyright 2019 Patrick Kidger. 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 law o... | 1,099 | 34.483871 | 79 | py |
signatory | signatory-master/benchmark/functions/signatory_signature_forward_no_parallel.py | # Copyright 2019 Patrick Kidger. 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 law o... | 876 | 31.481481 | 75 | py |
signatory | signatory-master/benchmark/functions/iisignature_signature_forward.py | # Copyright 2019 Patrick Kidger. 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 law o... | 852 | 33.12 | 75 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.