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
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/models/cifar/resnet_model.py
''' Properly implemented ResNet-s for CIFAR10 as described in paper [1]. The implementation and structure of this file is hugely influenced by [2] which is implemented for ImageNet and doesn't have option A for identity. Moreover, most of the implementations on the web is copy-paste from torchvision's resnet and has w...
5,001
30.459119
120
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/models/cifar/wrn.py
import math import torch import torch.nn as nn import torch.nn.functional as F __all__ = ['wrn'] class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, stride, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes) self.relu1 = nn.ReLU(inplac...
4,080
41.510417
116
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/models/celeba/celeb_id_class_model.py
import torch import torch.nn.functional as F import torch.utils.model_zoo # It was 93.5940, 104.7624, 129.1863 before dividing by 255 MEAN_RGB = [ 0.367035294117647, 0.41083294117647057, 0.5066129411764705 ] def vggface(pretrained=False, **kwargs): """VGGFace model. Args: pretrained (b...
3,372
27.108333
69
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/autograd_lib/autograd_lib.py
from contextlib import contextmanager from typing import List, Optional, Callable, Tuple import torch import torch.nn as nn import torch.nn.functional as F from . import util as u class Settings(object): forward_hooks: List[Callable] # forward subhooks called by the global hook backward_hooks: List[Callab...
7,234
39.875706
219
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/autograd_lib/util.py
# Take simple example, plot per-layer stats over time import random from typing import List import numpy as np import torch import torch.nn as nn import torchvision.datasets as datasets from PIL import Image _pytorch_floating_point_types = (torch.float16, torch.float32, torch.float64) _numpy_type_map = { 'float6...
9,474
33.580292
127
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/setup.py
import numpy as np import os.path as osp from setuptools import setup, find_packages from distutils.extension import Extension from Cython.Build import cythonize def readme(): with open('README.rst') as f: content = f.read() return content def find_version(): version_file = 'torchreid/__init__.p...
1,504
24.948276
78
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/tools/visualize_actmap.py
"""Visualizes CNN activation maps to see where the CNN focuses on to extract features. Reference: - Zagoruyko and Komodakis. Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer. ICLR, 2017 - Zhou et al. Omni-Scale Feature Learning for Pers...
5,959
33.252874
92
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/tools/parse_test_res.py
""" This script aims to automate the process of calculating average results stored in the test.log files over multiple splits. How to use: For example, you have done evaluation over 20 splits on VIPeR, leading to the following file structure log/ eval_viper/ split_0/ test.log-xxxx spli...
2,976
27.625
82
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/tools/compute_mean_std.py
""" Compute channel-wise mean and standard deviation of a dataset. Usage: $ python compute_mean_std.py DATASET_ROOT DATASET_KEY - The first argument points to the root path where you put the datasets. - The second argument means the specific dataset key. For instance, your datasets are put under $DATA and you wanna ...
1,509
24.166667
72
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/__init__.py
from __future__ import print_function, absolute_import from torchreid import data, optim, utils, engine, losses, models, metrics __version__ = '1.4.0' __author__ = 'Kaiyang Zhou' __homepage__ = 'https://kaiyangzhou.github.io/' __description__ = 'Deep learning person re-identification in PyTorch' __url__ = 'https://gi...
359
35
73
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/shufflenetv2.py
""" Code source: https://github.com/pytorch/vision """ from __future__ import division, absolute_import import torch import torch.utils.model_zoo as model_zoo from torch import nn __all__ = [ 'shufflenet_v2_x0_5', 'shufflenet_v2_x1_0', 'shufflenet_v2_x1_5', 'shufflenet_v2_x2_0' ] model_urls = { 'shufflene...
8,011
29.463878
103
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/mudeep.py
from __future__ import division, absolute_import import torch from torch import nn from torch.nn import functional as F __all__ = ['MuDeep'] class ConvBlock(nn.Module): """Basic convolutional block. convolution + batch normalization + relu. Args: in_c (int): number of input channels. ...
6,297
29.425121
80
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/inceptionv4.py
from __future__ import division, absolute_import import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['inceptionv4'] """ Code imported from https://github.com/Cadene/pretrained-models.pytorch """ pretrained_settings = { 'inceptionv4': { 'imagenet': { 'url': ...
11,271
28.507853
86
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/inceptionresnetv2.py
""" Code imported from https://github.com/Cadene/pretrained-models.pytorch """ from __future__ import division, absolute_import import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['inceptionresnetv2'] pretrained_settings = { 'inceptionresnetv2': { 'imagenet': { ...
11,194
29.925414
89
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/resnet.py
""" Code source: https://github.com/pytorch/vision """ from __future__ import division, absolute_import import torch.utils.model_zoo as model_zoo from torch import nn __all__ = [ 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'resnet50_fc512' ] model_urls ...
15,281
27.617978
106
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/mobilenetv2.py
from __future__ import division, absolute_import import torch.utils.model_zoo as model_zoo from torch import nn from torch.nn import functional as F __all__ = ['mobilenetv2_x1_0', 'mobilenetv2_x1_4'] model_urls = { # 1.0: top-1 71.3 'mobilenetv2_x1_0': 'https://mega.nz/#!NKp2wAIA!1NH1pbNzY_M2hVk_hdsxNM1NU...
8,515
29.523297
99
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/squeezenet.py
""" Code source: https://github.com/pytorch/vision """ from __future__ import division, absolute_import import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['squeezenet1_0', 'squeezenet1_1', 'squeezenet1_0_fc512'] model_urls = { 'squeezenet1_0': 'https://download.pytorch.org...
7,617
31.14346
99
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/mlfn.py
from __future__ import division, absolute_import import torch import torch.utils.model_zoo as model_zoo from torch import nn from torch.nn import functional as F __all__ = ['mlfn'] model_urls = { # training epoch = 5, top1 = 51.6 'imagenet': 'https://mega.nz/#!YHxAhaxC!yu9E6zWl0x5zscSouTdbZu8gdFFytDdl-RAd...
8,661
29.935714
86
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/osnet_ain.py
from __future__ import division, absolute_import import warnings import torch from torch import nn from torch.nn import functional as F __all__ = [ 'osnet_ain_x1_0', 'osnet_ain_x0_75', 'osnet_ain_x0_5', 'osnet_ain_x0_25' ] pretrained_urls = { 'osnet_ain_x1_0': 'https://drive.google.com/uc?id=1-CaioD9NaqbH...
17,731
28.068852
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/densenet.py
""" Code source: https://github.com/pytorch/vision """ from __future__ import division, absolute_import import re from collections import OrderedDict import torch import torch.nn as nn from torch.nn import functional as F from torch.utils import model_zoo __all__ = [ 'densenet121', 'densenet169', 'densenet201', 'd...
11,627
29.519685
104
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/senet.py
from __future__ import division, absolute_import import math from collections import OrderedDict import torch.nn as nn from torch.utils import model_zoo __all__ = [ 'senet154', 'se_resnet50', 'se_resnet101', 'se_resnet152', 'se_resnext50_32x4d', 'se_resnext101_32x4d', 'se_resnet50_fc512' ] """ Code imported fr...
20,684
29.021771
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/shufflenet.py
from __future__ import division, absolute_import import torch import torch.utils.model_zoo as model_zoo from torch import nn from torch.nn import functional as F __all__ = ['shufflenet'] model_urls = { # training epoch = 90, top1 = 61.8 'imagenet': 'https://mega.nz/#!RDpUlQCY!tr_5xBEkelzDjveIYBBcGcovNCOrg...
6,264
30.482412
86
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/nasnet.py
from __future__ import division, absolute_import import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo __all__ = ['nasnetamobile'] """ NASNet Mobile Thanks to Anastasiia (https://github.com/DagnyT) for the great help, support and motivation! --------------------...
36,186
30.967314
137
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/__init__.py
from __future__ import absolute_import import torch from .pcb import * from .mlfn import * from .hacnn import * from .osnet import * from .senet import * from .mudeep import * from .nasnet import * from .resnet import * from .densenet import * from .xception import * from .osnet_ain import * from .resnetmid import * f...
3,642
28.617886
81
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/xception.py
from __future__ import division, absolute_import import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo __all__ = ['xception'] pretrained_settings = { 'xception': { 'imagenet': { 'url': 'http://data.lip6.fr/cadene/pretrainedmodels/xception-4...
9,687
27.081159
124
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/resnet_ibn_a.py
""" Credit to https://github.com/XingangPan/IBN-Net. """ from __future__ import division, absolute_import import math import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['resnet50_ibn_a'] model_urls = { 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', ...
8,598
28.651724
99
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/resnet_ibn_b.py
""" Credit to https://github.com/XingangPan/IBN-Net. """ from __future__ import division, absolute_import import math import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['resnet50_ibn_b'] model_urls = { 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', 'resnet101'...
8,261
29.043636
99
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/osnet.py
from __future__ import division, absolute_import import warnings import torch from torch import nn from torch.nn import functional as F __all__ = [ 'osnet_x1_0', 'osnet_x0_75', 'osnet_x0_5', 'osnet_x0_25', 'osnet_ibn_x1_0' ] pretrained_urls = { 'osnet_x1_0': 'https://drive.google.com/uc?id=1LaG1EJpHrxdAxK...
17,037
27.444073
108
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/resnetmid.py
from __future__ import division, absolute_import import torch import torch.utils.model_zoo as model_zoo from torch import nn __all__ = ['resnet50mid'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth'...
9,165
28.75974
99
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/pcb.py
from __future__ import division, absolute_import import torch.utils.model_zoo as model_zoo from torch import nn from torch.nn import functional as F __all__ = ['pcb_p6', 'pcb_p4'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/...
9,125
27.971429
86
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/models/hacnn.py
from __future__ import division, absolute_import import torch from torch import nn from torch.nn import functional as F __all__ = ['HACNN'] class ConvBlock(nn.Module): """Basic convolutional block. convolution + batch normalization + relu. Args: in_c (int): number of input channels. ...
13,761
32.161446
105
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/optim/lr_scheduler.py
from __future__ import print_function, absolute_import import torch AVAI_SCH = ['single_step', 'multi_step', 'cosine'] def build_lr_scheduler( optimizer, lr_scheduler='single_step', stepsize=1, gamma=0.1, max_epoch=1 ): """A function wrapper for building a learning rate scheduler. Args: optimize...
2,461
34.681159
97
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/optim/radam.py
""" Imported from: https://github.com/LiyuanLucasLiu/RAdam Paper: https://arxiv.org/abs/1908.03265 @article{liu2019radam, title={On the Variance of the Adaptive Learning Rate and Beyond}, author={Liu, Liyuan and Jiang, Haoming and He, Pengcheng and Chen, Weizhu and Liu, Xiaodong and Gao, Jianfeng and Han, Jiawei}...
11,626
34.126888
129
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/optim/optimizer.py
from __future__ import print_function, absolute_import import warnings import torch import torch.nn as nn from .radam import RAdam AVAI_OPTIMS = ['adam', 'amsgrad', 'sgd', 'rmsprop', 'radam'] def build_optimizer( model, optim='adam', lr=0.0003, weight_decay=5e-04, momentum=0.9, sgd_dampening...
5,307
32.594937
97
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/metrics/rank.py
from __future__ import division, print_function, absolute_import import numpy as np import warnings from collections import defaultdict try: from torchreid.metrics.rank_cylib.rank_cy import evaluate_cy IS_CYTHON_AVAI = True except ImportError: IS_CYTHON_AVAI = False warnings.warn( 'Cython evalu...
6,955
32.442308
112
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/metrics/accuracy.py
from __future__ import division, print_function, absolute_import def accuracy(output, target, topk=(1, )): """Computes the accuracy over the k top predictions for the specified values of k. Args: output (torch.Tensor): prediction matrix with shape (batch_size, num_classes). target (torch....
1,134
28.868421
86
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/metrics/distance.py
from __future__ import division, print_function, absolute_import import torch from torch.nn import functional as F def compute_distance_matrix(input1, input2, metric='euclidean'): """A wrapper function for computing distance matrix. Args: input1 (torch.Tensor): 2-D feature matrix. input2 (tor...
2,446
29.209877
73
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/metrics/rank_cylib/test_cython.py
from __future__ import print_function import sys import numpy as np import timeit import os.path as osp from torchreid import metrics sys.path.insert(0, osp.dirname(osp.abspath(__file__)) + '/../../..') """ Test the speed of cython-based evaluation code. The speed improvements can be much bigger when using the real r...
2,746
31.702381
125
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/engine/engine.py
from __future__ import division, print_function, absolute_import import time import numpy as np import os.path as osp import datetime from collections import OrderedDict import torch from torch.nn import functional as F from torch.utils.tensorboard import SummaryWriter from torchreid import metrics from torchreid.util...
18,705
34.973077
120
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/engine/video/softmax.py
from __future__ import division, print_function, absolute_import import torch from torchreid.engine.image import ImageSoftmaxEngine class VideoSoftmaxEngine(ImageSoftmaxEngine): """Softmax-loss engine for video-reid. Args: datamanager (DataManager): an instance of ``torchreid.data.ImageDataManager``...
3,479
30.636364
93
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/engine/video/triplet.py
from __future__ import division, print_function, absolute_import import torch from torchreid.engine.image import ImageTripletEngine class VideoTripletEngine(ImageTripletEngine): """Triplet-loss engine for video-reid. Args: datamanager (DataManager): an instance of ``torchreid.data.ImageDataManager``...
4,038
31.837398
93
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/engine/image/softmax.py
from __future__ import division, print_function, absolute_import from torchreid import metrics from torchreid.losses import CrossEntropyLoss from ..engine import Engine class ImageSoftmaxEngine(Engine): r"""Softmax-loss engine for image-reid. Args: datamanager (DataManager): an instance of ``torchr...
2,860
28.193878
93
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/engine/image/triplet.py
from __future__ import division, print_function, absolute_import from torchreid import metrics from torchreid.losses import TripletLoss, CrossEntropyLoss from ..engine import Engine class ImageTripletEngine(Engine): r"""Triplet-loss engine for image-reid. Args: datamanager (DataManager): an instanc...
3,877
30.528455
93
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/torchtools.py
from __future__ import division, print_function, absolute_import import pickle import shutil import os.path as osp import warnings from functools import partial from collections import OrderedDict import torch import torch.nn as nn from .tools import mkdir_if_missing __all__ = [ 'save_checkpoint', 'load_checkpoin...
9,672
29.904153
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/avgmeter.py
from __future__ import division, absolute_import from collections import defaultdict import torch __all__ = ['AverageMeter', 'MetricMeter'] class AverageMeter(object): """Computes and stores the average and current value. Examples:: >>> # Initialize a meter to record loss >>> losses = Averag...
1,983
25.810811
71
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/feature_extractor.py
from __future__ import absolute_import import numpy as np import torch import torchvision.transforms as T from PIL import Image from torchreid.utils import ( check_isfile, load_pretrained_weights, compute_model_complexity ) from torchreid.models import build_model class FeatureExtractor(object): """A simple ...
4,564
28.836601
83
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/tools.py
from __future__ import division, print_function, absolute_import import os import sys import json import time import errno import numpy as np import random import os.path as osp import warnings import PIL import torch from PIL import Image __all__ = [ 'mkdir_if_missing', 'check_isfile', 'read_json', 'write_json', ...
3,532
23.534722
90
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/loggers.py
from __future__ import absolute_import import os import sys import os.path as osp from .tools import mkdir_if_missing __all__ = ['Logger', 'RankLogger'] class Logger(object): """Writes console output to external text file. Imported from `<https://github.com/Cysu/open-reid/blob/master/reid/utils/logging.py>...
4,373
28.755102
90
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/__init__.py
from __future__ import absolute_import from .tools import * from .rerank import re_ranking from .loggers import * from .avgmeter import * from .reidtools import * from .torchtools import * from .model_complexity import compute_model_complexity from .feature_extractor import FeatureExtractor
293
25.727273
54
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/model_complexity.py
from __future__ import division, print_function, absolute_import import math import numpy as np from itertools import repeat from collections import namedtuple, defaultdict import torch __all__ = ['compute_model_complexity'] """ Utility """ def _ntuple(n): def parse(x): if isinstance(x, int): ...
9,470
25.019231
101
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/GPU-Re-Ranking/main.py
""" Understanding Image Retrieval Re-Ranking: A Graph Neural Network Perspective Xuanmeng Zhang, Minyue Jiang, Zhedong Zheng, Xiao Tan, Errui Ding, Yi Yang Project Page : https://github.com/Xuanmeng-Zhang/gnn-re-ranking Paper: https://arxiv.org/abs/2012.07620v2 ==================================...
1,998
26.383562
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/GPU-Re-Ranking/utils.py
""" Understanding Image Retrieval Re-Ranking: A Graph Neural Network Perspective Xuanmeng Zhang, Minyue Jiang, Zhedong Zheng, Xiao Tan, Errui Ding, Yi Yang Project Page : https://github.com/Xuanmeng-Zhang/gnn-re-ranking Paper: https://arxiv.org/abs/2012.07620v2 ==================================...
3,691
25.753623
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/GPU-Re-Ranking/gnn_reranking.py
""" Understanding Image Retrieval Re-Ranking: A Graph Neural Network Perspective Xuanmeng Zhang, Minyue Jiang, Zhedong Zheng, Xiao Tan, Errui Ding, Yi Yang Project Page : https://github.com/Xuanmeng-Zhang/gnn-re-ranking Paper: https://arxiv.org/abs/2012.07620v2 ==================================...
1,804
29.083333
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/GPU-Re-Ranking/extension/propagation/setup.py
""" Understanding Image Retrieval Re-Ranking: A Graph Neural Network Perspective Xuanmeng Zhang, Minyue Jiang, Zhedong Zheng, Xiao Tan, Errui Ding, Yi Yang Project Page : https://github.com/Xuanmeng-Zhang/gnn-re-ranking Paper: https://arxiv.org/abs/2012.07620v2 ==================================...
1,200
31.459459
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/utils/GPU-Re-Ranking/extension/adjacency_matrix/setup.py
""" Understanding Image Retrieval Re-Ranking: A Graph Neural Network Perspective Xuanmeng Zhang, Minyue Jiang, Zhedong Zheng, Xiao Tan, Errui Ding, Yi Yang Project Page : https://github.com/Xuanmeng-Zhang/gnn-re-ranking Paper: https://arxiv.org/abs/2012.07620v2 ==================================...
1,236
32.432432
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/losses/hard_mine_triplet_loss.py
from __future__ import division, absolute_import import torch import torch.nn as nn class TripletLoss(nn.Module): """Triplet loss with hard positive/negative mining. Reference: Hermans et al. In Defense of the Triplet Loss for Person Re-Identification. arXiv:1703.07737. Imported from `<h...
1,770
35.142857
101
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/torchreid/losses/cross_entropy_loss.py
from __future__ import division, absolute_import import torch import torch.nn as nn class CrossEntropyLoss(nn.Module): r"""Cross entropy loss with label smoothing regularizer. Reference: Szegedy et al. Rethinking the Inception Architecture for Computer Vision. CVPR 2016. With label smoothing...
1,923
36.72549
92
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/OSNet_AIN/main.py
import os import sys import time import os.path as osp import argparse import torch import torch.nn as nn import torchreid from torchreid.utils import ( Logger, check_isfile, set_random_seed, collect_env_info, resume_from_checkpoint, compute_model_complexity ) import osnet_search as osnet_models from softmax_...
4,193
27.726027
79
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/OSNet_AIN/softmax_nas.py
from __future__ import division, print_function, absolute_import from torchreid import metrics from torchreid.engine import Engine from torchreid.losses import CrossEntropyLoss class ImageSoftmaxNASEngine(Engine): def __init__( self, datamanager, model, optimizer, schedul...
2,108
27.5
73
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/OSNet_AIN/osnet_search.py
from __future__ import division, absolute_import import torch from torch import nn from torch.nn import functional as F EPS = 1e-12 NORM_AFFINE = False # enable affine transformations for normalization layer ########## # Basic layers ########## class IBN(nn.Module): """Instance + Batch Normalization.""" def...
18,586
30.77265
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/OSNet_AIN/osnet_child.py
from __future__ import division, absolute_import from torch import nn from torch.nn import functional as F ########## # Basic layers ########## class ConvLayer(nn.Module): """Convolution layer (conv + bn + relu).""" def __init__( self, in_channels, out_channels, kernel_size, ...
16,436
29.666045
91
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/attribute_recognition/main.py
from __future__ import division, print_function import sys import copy import time import numpy as np import os.path as osp import datetime import warnings import torch import torch.nn as nn import torchreid from torchreid.utils import ( Logger, AverageMeter, check_isfile, open_all_layers, save_checkpoint, set...
12,430
30.0775
79
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/attribute_recognition/models/osnet.py
from __future__ import division, absolute_import import torch from torch import nn from torch.nn import functional as F __all__ = ['osnet_avgpool', 'osnet_maxpool'] ########## # Basic layers ########## class ConvLayer(nn.Module): """Convolution layer.""" def __init__( self, in_channels, ...
11,484
26.674699
80
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/attribute_recognition/datasets/dataset.py
from __future__ import division, print_function, absolute_import import os.path as osp from torchreid.utils import read_image class Dataset(object): def __init__( self, train, val, test, attr_dict, transform=None, mode='train', verbose=True, ...
2,563
28.136364
69
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/DML/main.py
import sys import copy import time import os.path as osp import argparse import torch import torch.nn as nn import torchreid from torchreid.utils import ( Logger, check_isfile, set_random_seed, collect_env_info, resume_from_checkpoint, load_pretrained_weights, compute_model_complexity ) from dml import ImageD...
4,789
27.682635
79
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/projects/DML/dml.py
from __future__ import division, print_function, absolute_import import torch from torch.nn import functional as F from torchreid.utils import open_all_layers, open_specified_layers from torchreid.engine import Engine from torchreid.losses import TripletLoss, CrossEntropyLoss class ImageDMLEngine(Engine): def _...
4,430
28.54
72
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/scripts/main.py
import sys import time import os.path as osp import argparse import torch import torch.nn as nn import torchreid from torchreid.utils import ( Logger, check_isfile, set_random_seed, collect_env_info, resume_from_checkpoint, load_pretrained_weights, compute_model_complexity ) from default_config import ( i...
5,871
29.583333
81
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/scrub/deep-person-reid-master/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
5,646
30.027473
79
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/tester.py
import argparse import numpy as np import pandas as pd import json import os import torch import torchvision from torch import nn import torch.nn.functional as F from torch.utils.data import DataLoader from torchvision.datasets import MNIST from torchvision.transforms import Compose, ToTensor import torchvision.transf...
14,898
45.41433
174
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/test.py
""" Implements RevGrad: Unsupervised Domain Adaptation by Backpropagation, Ganin & Lemptsky (2014) Domain-adversarial training of neural networks, Ganin et al. (2016) """ import argparse import numpy as np import pandas as pd import torch from torch import nn import torch.nn.functional as F from torch.utils.data impor...
5,893
36.069182
155
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/utils.py
import torch from torch.autograd import Function class GradientReversalFunction(Function): """ Gradient Reversal Layer from: Unsupervised Domain Adaptation by Backpropagation (Ganin & Lempitsky, 2015) Forward pass is the identity function. In the backward pass, the upstream gradients are multiplied by -lambda (...
815
23
77
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/dataset.py
from __future__ import print_function import os import os.path import numpy as np import pandas as pd import sys from scipy import ndimage as nd import torch import torch.utils.data as data from PIL import Image class OurCelebA(data.Dataset): """ Args: root (string): Root directory of dataset where dir...
3,880
36.317308
197
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/spureg_train.py
import argparse import numpy as np import pandas as pd import json import os import torch from torch import nn import torch.nn.functional as F from torch.utils.data import DataLoader from torchvision.datasets import MNIST from torchvision.transforms import Compose, ToTensor import torchvision.transforms as transforms ...
14,527
44.974684
174
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/models.py
from torch import nn from utils import GradientReversal class Net(nn.Module): def __init__(self): super().__init__() self.feature_extractor = nn.Sequential( nn.Conv2d(3, 20, kernel_size=3), # nn.MaxPool2d(2), # nn.ReLU(), nn.Conv2d(20, 30, kernel_size=3), # nn.MaxPool2d(2), # nn.ReLU(), nn.Co...
1,454
21.045455
46
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/spurious/train_feature_ext.py
import argparse import numpy as np import torch from torch.utils.data import DataLoader from torch.utils.data.sampler import SubsetRandomSampler from torchvision.datasets import MNIST from torchvision.datasets import CelebA from torchvision.transforms import Compose, ToTensor import torchvision.transforms as transform...
3,133
35.44186
123
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/roc_gen.py
import numpy as np import pandas as pd import time import h5py import pickle import json import torch import os import sys sys.path.append("../pycit-master/") sys.path.append("../../") from codec import codec2, codec3, foci import argparse from pycit import * from bullseye import bullseye_network, get_ci_dict from ...
6,767
29.763636
154
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/run_bullseye3d.py
import numpy as np import h5py import pickle import json import torch import os import sys sys.path.append("../pycit-master/") import argparse from pycit import * from bullseye import bullseye_network, get_ci_dict from mapping import ModelManager # from graph_synth import createFOCIGraph parser = argparse.Argumen...
4,803
25.988764
104
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model_manager.py
import glob import os import json import argparse import torch import numpy as np import matplotlib.pyplot as plt import pickle from .utils import Logger from . import model as module_model from . import data_loader as module_data from .evaluation import loss as module_loss from .evaluation import metric as module_me...
3,631
34.607843
116
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/trainer/trainer_lasso.py
import numpy as np import torch from torchvision.utils import make_grid from ..base import BaseTrainer import time import os import torch.nn.functional as F from torch.nn.utils import clip_grad_norm_ from torch.autograd.gradcheck import zero_gradients from torch.autograd import Variable import scipy.interpolate impor...
6,575
31.078049
109
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/trainer/trainer_pushpull.py
import numpy as np import torch from torchvision.utils import make_grid from ..base import BaseTrainer import time import os import torch.nn.functional as F from torch.nn.utils import clip_grad_norm_ from torch.autograd.gradcheck import zero_gradients from torch.autograd import Variable import scipy.interpolate impor...
9,531
33.164875
109
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/evaluation/loss.py
import torch def mse_loss(output, target): """ Inputs have shape: (N,d) """ if output.dim() == 1 or target.dim() == 1: return torch.mean((output.view(-1) - target.view(-1))**2) else: return torch.mean(torch.sum((output - target)**2, dim=1)) def gaussian_loss(output, target, offse...
859
28.655172
75
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/evaluation/metric.py
import torch def detection_rate(output, target, thresh=0.5): output = output.view(-1) target = target.view(-1) correct = 0 n_one = 0 with torch.no_grad(): pred = output >= thresh assert pred.shape[0] == len(target) correct += torch.sum((pred==1)*(target==1)).item() ...
1,780
28.683333
90
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/data_loader/np_supervised.py
import numpy as np import torch from torch.utils import data from torchvision import datasets, transforms from ..base import BaseDataLoader class NpSupervisedDataset(data.Dataset): """docstring for SupervisedDataset""" def __init__(self, x_path, y_path, selected_features=None, bit16=False): x_data = ...
1,542
35.738095
113
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/data_loader/h5_supervised.py
from torchvision import datasets, transforms from ..base import BaseDataLoader from torch.utils import data import h5py import numpy as np import torch class SupervisedDataset(data.Dataset): """docstring for SupervisedDataset""" def __init__(self, h5_path, selected_features=None): df = h5py.File(h5_pa...
1,691
33.530612
113
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/data_loader/h5_timeseries.py
from torchvision import datasets, transforms from ..base import BaseDataLoader from torch.utils import data import h5py import numpy as np import torch class TimeseriesDataset(data.Dataset): """docstring for BackBlazeDataset""" def __init__(self, h5_path, feat_list=None, time_trimmed=0, tia=0): df = h...
2,148
32.578125
82
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/base/base_model.py
import logging import torch.nn as nn import numpy as np class BaseModel(nn.Module): """ Base class for all models """ def __init__(self): super(BaseModel, self).__init__() self.logger = logging.getLogger(self.__class__.__name__) def forward(self, *input): """ Forwa...
1,075
27.315789
93
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/base/base_trainer.py
import os import math import json import logging import datetime import torch from ..utils.util import ensure_dir class BaseTrainer: """ Base class for all trainers """ def __init__(self, model, loss, metrics, optimizer, resume, config, train_logger=None): self.config = config self.log...
8,107
40.367347
157
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/base/base_data_loader.py
import numpy as np from torch.utils.data import DataLoader from torch.utils.data.dataloader import default_collate from torch.utils.data.sampler import SubsetRandomSampler class BaseDataLoader(DataLoader): """ Base class for all data loaders """ def __init__(self, dataset, batch_size, shuffle, validat...
2,434
32.356164
132
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/delta_dropout.py
""" Drop out random number of features from 1 to delta+1 """ import torch.nn as nn from torch.autograd import Variable import numpy as np class DeltaDropout(nn.Module): """ Inverted dropout, except drops out entire dimensions with same probability """ def __init__(self, delta): super().__i...
959
26.428571
82
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/jeffreys.py
""" Jeffreys divergences """ import torch def jeffreys_normal(mu1, lv1, mu2, lv2): mu1, lv1 = mu1.view(mu1.shape[0], -1), lv1.view(lv1.shape[0], -1) mu2, lv2 = mu2.view(mu2.shape[0], -1), lv2.view(lv2.shape[0], -1) return (0.25*((-lv1).exp() + (-lv2).exp())*(mu1-mu2)**2 + 0.25*((lv1-lv2).exp() + (lv2-lv1)...
551
35.8
120
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/mapping_feedforward_gaussian.py
import numpy as np import torch import torch.nn.functional as F import torch.nn as nn from torch.autograd import Variable from collections import OrderedDict from ..base import BaseModel from .delta_dropout import DeltaDropout from .diagonal_linear import DiagonalLinear from .jeffreys import * class MappingFFGaussia...
2,946
32.488636
126
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/input_weighting.py
import torch import torch.nn as nn class InputWeighting(nn.Module): """ Input weighting for lasso-type feature selection """ def __init__(self, num_features): super().__init__() self.num_features = num_features self.weight = nn.Parameter(torch.randn(num_features)) ...
638
24.56
61
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/mapping_sequence_binary.py
import numpy as np import torch import torch.nn.functional as F import torch.nn as nn from torch.autograd import Variable from collections import OrderedDict from ..base import BaseModel from .jeffreys import * from .delta_dropout import DeltaDropout class MappingRNNBinary(BaseModel): """ Data has di...
3,330
33.697917
121
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/lasso_recurrent_binary.py
import numpy as np import torch import torch.nn.functional as F import torch.nn as nn from torch.autograd import Variable from collections import OrderedDict from ..base import BaseModel from .input_weighting import * class LassoRNNBinary(BaseModel): """ Data has dimension (N, T, M) - N samples ...
1,192
30.394737
125
py
LCODEC-deep-unlearning
LCODEC-deep-unlearning-main/bullseye/model-augmented-mutual-information-master/mapping/model/diagonal_linear.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class DiagonalLinear(nn.Module): """ keep track of nonzero parameters separately Flow: self.optimizer.zero_grad() output = self.model(data) loss = self.loss(o...
1,967
29.75
104
py
splade
splade-main/splade/train.py
import os import hydra import torch from omegaconf import DictConfig, open_dict from torch.utils import data from conf.CONFIG_CHOICE import CONFIG_NAME, CONFIG_PATH from .datasets.dataloaders import CollectionDataLoader, SiamesePairsDataLoader, DistilSiamesePairsDataLoader from .datasets.datasets import PairsDatasetP...
11,507
58.015385
119
py
splade
splade-main/splade/models/transformer_rep.py
from abc import ABC import torch from transformers import AutoTokenizer, AutoModelForMaskedLM, AutoModel from ..tasks.amp import NullContextManager from ..utils.utils import generate_bow, normalize """ we provide abstraction classes from which we can easily derive representation-based models with transformers like S...
8,892
44.605128
120
py
splade
splade-main/splade/datasets/dataloaders.py
""" custom dataloaders (for dynamic batching) """ import torch from torch.utils.data.dataloader import DataLoader from transformers import AutoTokenizer from ..utils.utils import rename_keys class DataLoaderWrapper(DataLoader): def __init__(self, tokenizer_type, max_length, **kwargs): self.max_length = ...
5,633
44.804878
104
py
splade
splade-main/splade/datasets/datasets.py
import gzip import json import os import pickle import random from torch.utils.data import Dataset from tqdm.auto import tqdm class PairsDatasetPreLoad(Dataset): """ dataset to iterate over a collection of pairs, format per line: q \t d_pos \t d_neg we preload everything in memory at init """ de...
6,073
36.263804
108
py
splade
splade-main/splade/utils/utils.py
import os import random import numpy as np import torch from omegaconf import DictConfig, OmegaConf from ..losses.pairwise import DistilKLLoss, PairwiseNLL, DistilMarginMSE, InBatchPairwiseNLL from ..losses.pointwise import BCEWithLogitsLoss def parse(d, name): return {k.replace(name + "_", ""): v for k, v in d...
4,722
30.278146
115
py