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
mmpretrain
mmpretrain-master/tests/test_data/test_datasets/test_common.py
# Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp import pickle import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import torch from mmcls.datasets import DATASETS from mmcls.datasets import BaseDataset as _BaseDataset from mmcls.datasets imp...
33,212
35.417763
79
py
mmpretrain
mmpretrain-master/tests/test_data/test_pipelines/test_transform.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp import random import mmcv import numpy as np import pytest import torch import torchvision from mmcv.utils import build_from_cfg from numpy.testing import assert_array_almost_equal, assert_array_equal from PIL import Image from torchvisi...
48,968
36.610599
79
py
mmpretrain
mmpretrain-master/tests/test_utils/test_device.py
# Copyright (c) OpenMMLab. All rights reserved. from unittest import TestCase from unittest.mock import patch import mmcv from mmcls.utils import auto_select_device class TestAutoSelectDevice(TestCase): @patch.object(mmcv, '__version__', '1.6.0') @patch('mmcv.device.get_device', create=True) def test_m...
831
27.689655
57
py
mmpretrain
mmpretrain-master/tests/data/retinanet.py
# Copyright (c) OpenMMLab. All rights reserved. # small RetinaNet num_classes = 3 # model settings model = dict( type='RetinaNet', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_g...
2,477
28.5
79
py
mmpretrain
mmpretrain-master/tests/test_metrics/test_losses.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcls.models import build_loss def test_asymmetric_loss(): # test asymmetric_loss cls_score = torch.Tensor([[5, -5, 0], [5, -5, 0]]) label = torch.Tensor([[1, 0, 1], [0, 1, 0]]) weight = torch.tensor([0.5, 0.5]) loss...
12,587
33.677686
79
py
mmpretrain
mmpretrain-master/tests/test_metrics/test_metrics.py
# Copyright (c) OpenMMLab. All rights reserved. from functools import partial import pytest import torch from mmcls.core import average_performance, mAP from mmcls.models.losses.accuracy import Accuracy, accuracy_numpy def test_mAP(): target = torch.Tensor([[1, 1, 0, -1], [1, 1, 0, -1], [0, -1, 1, -1], ...
3,587
37.170213
75
py
mmpretrain
mmpretrain-master/tests/test_metrics/test_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcls.models.losses.utils import convert_to_one_hot def ori_convert_to_one_hot(targets: torch.Tensor, classes) -> torch.Tensor: assert (torch.max(targets).item() < classes), 'Class Index must be less than number of classe...
1,937
37.76
75
py
mmpretrain
mmpretrain-master/configs/vision_transformer/vit-large-p32_ft-64xb64_in1k-384.py
# Refer to pytorch-image-models _base_ = [ '../_base_/models/vit-large-p32.py', '../_base_/datasets/imagenet_bs64_pil_resize_autoaug.py', '../_base_/schedules/imagenet_bs4096_AdamW.py', '../_base_/default_runtime.py' ] model = dict(backbone=dict(img_size=384)) img_norm_cfg = dict( mean=[127.5, 127...
1,172
29.868421
71
py
mmpretrain
mmpretrain-master/configs/_base_/models/seresnet50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='SEResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, i...
426
22.722222
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet101.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=101, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in...
425
22.666667
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnext101_32x4d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeXt', depth=101, num_stages=4, out_indices=(3, ), groups=32, width_per_group=4, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='Linea...
472
22.65
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet152.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=152, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in...
425
22.666667
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet34_cifar.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=34, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=10, ...
406
22.941176
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnetv1d50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNetV1d', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, ...
427
22.777778
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnext152_32x4d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeXt', depth=152, num_stages=4, out_indices=(3, ), groups=32, width_per_group=4, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='Linea...
472
22.65
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/seresnet101.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='SEResNet', depth=101, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, ...
427
22.777778
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnetv1d101.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNetV1d', depth=101, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, ...
428
22.833333
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_cifar_cutmix.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='MultiLabelLinearClsHead', num_classes=1...
549
27.947368
76
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet18_cifar.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=18, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=10, ...
406
22.941176
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet18.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=18, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_...
423
22.555556
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_cifar.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=10, ...
407
23
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet34_gem.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=34, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GeneralizedMeanPooling'), head=dict( type='LinearClsHead', num_classes=1000, i...
425
22.666667
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_mixup.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='MultiLabelLinearClsHead', num_classes=1000, ...
545
27.736842
76
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnetv1d152.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNetV1d', depth=152, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, ...
428
22.833333
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnetv1c50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, ...
427
22.777778
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/wide-resnet50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), stem_channels=64, base_channels=128, expansion=2, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head...
498
22.761905
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnest101.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeSt', depth=101, num_stages=4, stem_channels=128, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', ...
646
24.88
57
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnext101_32x8d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeXt', depth=101, num_stages=4, out_indices=(3, ), groups=32, width_per_group=8, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='Linea...
472
22.65
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet34.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=34, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_...
423
22.555556
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet101_cifar.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=101, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=10, ...
408
23.058824
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnext50_32x4d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeXt', depth=50, num_stages=4, out_indices=(3, ), groups=32, width_per_group=4, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='Linear...
471
22.6
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_...
424
22.611111
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/seresnext50_32x4d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='SEResNeXt', depth=50, num_stages=4, out_indices=(3, ), groups=32, width_per_group=4, se_ratio=16, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dic...
494
22.571429
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_label_smooth.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_...
458
23.157895
75
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnest50.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeSt', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in...
618
24.791667
57
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnest269.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeSt', depth=269, num_stages=4, stem_channels=128, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', ...
646
24.88
57
py
mmpretrain
mmpretrain-master/configs/_base_/models/seresnext101_32x4d.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='SEResNeXt', depth=101, num_stages=4, out_indices=(3, ), groups=32, width_per_group=4, se_ratio=16, style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=di...
495
22.619048
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet152_cifar.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=152, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=10, ...
408
23.058824
60
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnest200.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNeSt', depth=200, num_stages=4, stem_channels=128, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', ...
646
24.88
57
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_cutmix.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='MultiLabelLinearClsHead', num_classes=1000, ...
538
27.368421
76
py
mmpretrain
mmpretrain-master/configs/_base_/models/resnet50_cifar_mixup.py
# model settings model = dict( type='ImageClassifier', backbone=dict( type='ResNet_CIFAR', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='MultiLabelLinearClsHead', num_classes=1...
524
28.166667
77
py
mmpretrain
mmpretrain-master/configs/_base_/datasets/imagenet_bs64_mixer_224.py
# dataset settings dataset_type = 'ImageNet' # change according to https://github.com/rwightman/pytorch-image-models/blob # /master/timm/models/mlp_mixer.py img_norm_cfg = dict( mean=[127.5, 127.5, 127.5], std=[127.5, 127.5, 127.5], to_rgb=True) # training is not supported for now train_pipeline = [ dict(type...
1,601
31.693878
79
py
mmpretrain
mmpretrain-master/configs/_base_/datasets/pipelines/rand_aug.py
# Refers to `_RAND_INCREASING_TRANSFORMS` in pytorch-image-models rand_increasing_policies = [ dict(type='AutoContrast'), dict(type='Equalize'), dict(type='Invert'), dict(type='Rotate', magnitude_key='angle', magnitude_range=(0, 30)), dict(type='Posterize', magnitude_key='bits', magnitude_range=(4, ...
1,430
31.522727
79
py
mmpretrain
mmpretrain-master/configs/csra/resnet101-csra_1xb16_voc07-448px.py
_base_ = ['../_base_/datasets/voc_bs16.py', '../_base_/default_runtime.py'] # Pre-trained Checkpoint Path checkpoint = 'https://download.openmmlab.com/mmclassification/v0/resnet/resnet101_8xb32_in1k_20210831-539c63f8.pth' # noqa # If you want to use the pre-trained weight of ResNet101-CutMix from # the originary repo...
2,484
31.697368
123
py
mmpretrain
mmpretrain-master/configs/mobilenet_v3/mobilenet-v3-small_8xb32_in1k.py
# Refer to https://pytorch.org/blog/ml-models-torchvision-v0.9/#classification # ---------------------------- # -[x] auto_augment='imagenet' # -[x] batch_size=128 (per gpu) # -[x] epochs=600 # -[x] opt='rmsprop' # -[x] lr=0.064 # -[x] eps=0.0316 # -[x] alpha=0.9 # -[x] weight_decay=1e-05 # -[x] mome...
4,607
27.981132
78
py
mmpretrain
mmpretrain-master/configs/mobilenet_v3/mobilenet-v3-large_8xb32_in1k.py
# Refer to https://pytorch.org/blog/ml-models-torchvision-v0.9/#classification # ---------------------------- # -[x] auto_augment='imagenet' # -[x] batch_size=128 (per gpu) # -[x] epochs=600 # -[x] opt='rmsprop' # -[x] lr=0.064 # -[x] eps=0.0316 # -[x] alpha=0.9 # -[x] weight_decay=1e-05 # -[x] mome...
4,607
27.981132
78
py
mmpretrain
mmpretrain-master/docs/en/conf.py
# flake8: noqa # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup --------------------------------------------------------...
8,620
32.544747
158
py
mmpretrain
mmpretrain-master/docs/zh_CN/conf.py
# flake8: noqa # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup --------------------------------------------------------...
7,890
31.607438
164
py
robust-OT
robust-OT-main/robust CIFAR/GAN/losses.py
import torch import torch.nn as nn import torch.nn.functional as F from torch import autograd ############################################################################################## # Losses # DCGAN loss def loss_dcgan_dis(dis_real, dis_fake, weights): L1 = torch.mean(F.softplus(-dis_real * weights)) ...
3,439
29.175439
147
py
robust-OT
robust-OT-main/robust CIFAR/GAN/utils.py
import torch import torch.nn as nn import copy from torch.optim.lr_scheduler import _LRScheduler import torch.nn.functional as F class ConfigMapper(object): def __init__(self, args): for key in args: self.__dict__[key] = args[key] def toggle_grad(model, on_or_off): for param in model.param...
4,296
32.310078
157
py
robust-OT
robust-OT-main/robust CIFAR/GAN/datasets.py
# Dataset factory import torch import dataset_lib as datasets import torchvision.transforms as T import utils import os from random import shuffle from PIL import Image import numpy as np import math import pickle import random def resize_and_crop(img, size): img_w, img_h = img.size scale_factor = max((float...
9,259
36.188755
118
py
robust-OT
robust-OT-main/robust CIFAR/GAN/evaluation.py
# Code for evaluating trained GAN models. import torch import utils import losses import os.path as osp from pathlib import Path import torchvision.utils as vutils import math import numpy as np import copy import models from datasets import dataset_factory import torch.nn as nn import os import json _ATTR_CLS_MODEL...
8,547
30.083636
146
py
robust-OT
robust-OT-main/robust CIFAR/GAN/trainer.py
import torch.optim as optim import torch import torch.nn as nn import utils from datasets import dataset_factory import models import losses import os.path as osp from pathlib import Path import torchvision.utils as vutils import math #import inception import numpy as np import torch.nn.functional as F import copy impo...
22,178
41.165399
122
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/celeba_with_attributes.py
from .vision import VisionDataset from PIL import Image from random import shuffle import os import os.path import sys import numpy as np def has_file_allowed_extension(filename, extensions): """Checks if a file is an allowed extension. Args: filename (string): path to a file extensions (tu...
10,397
33.54485
108
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/phototour.py
import os import numpy as np from PIL import Image import torch from .vision import VisionDataset from .utils import download_url class PhotoTour(VisionDataset): """`Learning Local Image Descriptors Data <http://phototour.cs.washington.edu/patches/default.htm>`_ Dataset. Args: root (string): Root ...
7,263
33.590476
113
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/video_utils.py
import bisect import math import torch from torchvision.io import read_video_timestamps, read_video from .utils import tqdm def unfold(tensor, size, step, dilation=1): """ similar to tensor.unfold, but with the dilation and specialized for 1d tensors Returns all consecutive windows of `size` element...
8,343
37.62963
100
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/utils.py
import os import os.path import hashlib import gzip import errno import tarfile import zipfile import torch from torch.utils.model_zoo import tqdm def gen_bar_updater(): pbar = tqdm(total=None) def bar_update(count, block_size, total_size): if pbar.total is None and total_size: pbar.tota...
8,536
29.27305
109
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/svhn.py
from __future__ import print_function from .vision import VisionDataset from PIL import Image import os import os.path import numpy as np from .utils import download_url, check_integrity, verify_str_arg class SVHN(VisionDataset): """`SVHN <http://ufldl.stanford.edu/housenumbers/>`_ Dataset. Note: The SVHN dat...
4,533
38.426087
95
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/vision.py
import os import torch import torch.utils.data as data class VisionDataset(data.Dataset): _repr_indent = 4 def __init__(self, root, transforms=None, transform=None, target_transform=None): if isinstance(root, torch._six.string_classes): root = os.path.expanduser(root) self.root = ...
2,950
35.432099
86
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/celeba.py
from functools import partial import torch import os import PIL from .vision import VisionDataset from .utils import download_file_from_google_drive, check_integrity, verify_str_arg class CelebA(VisionDataset): """`Large-scale CelebFaces Attributes (CelebA) Dataset <http://mmlab.ie.cuhk.edu.hk/projects/CelebA.htm...
7,437
47.934211
120
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/folder.py
from .vision import VisionDataset from PIL import Image import os import os.path import sys def has_file_allowed_extension(filename, extensions): """Checks if a file is an allowed extension. Args: filename (string): path to a file extensions (tuple of strings): extensions to consider (lower...
7,457
34.345972
113
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/imagenet.py
from __future__ import print_function import os import shutil import tempfile import torch from .folder import ImageFolder from .utils import check_integrity, download_and_extract_archive, extract_archive, \ verify_str_arg ARCHIVE_DICT = { 'train': { 'url': 'http://www.image-net.org/challenges/LSVRC/20...
6,660
37.726744
100
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/coco.py
from .vision import VisionDataset from PIL import Image import os import os.path class CocoCaptions(VisionDataset): """`MS Coco Captions <http://mscoco.org/dataset/#captions-challenge2015>`_ Dataset. Args: root (string): Root directory where images are downloaded to. annFile (string): Path to...
4,530
35.540323
109
py
robust-OT
robust-OT-main/robust CIFAR/GAN/dataset_lib/mnist.py
from __future__ import print_function from .vision import VisionDataset import warnings from PIL import Image import os import os.path import numpy as np import torch import codecs from .utils import download_url, download_and_extract_archive, extract_archive, \ makedir_exist_ok, verify_str_arg class MNIST(Vision...
19,093
40.872807
119
py
robust-OT
robust-OT-main/robust CIFAR/GAN/inception/intra_fid.py
#!/usr/bin/env python3 ''' Calculates the Frechet Inception Distance (FID) to evalulate GANs. The FID metric calculates the distance between two distributions of images. Typically, we have summary statistics (mean & covariance matrix) of one of these distributions, while the 2nd distribution is given by a GAN. When r...
13,247
37.964706
111
py
robust-OT
robust-OT-main/robust CIFAR/GAN/models/base.py
import torch import torch.nn as nn from .layers import * import utils class BaseDiscriminator(nn.Module): def __init__(self, config): super(BaseDiscriminator, self).__init__() self.config = config linear_layer = linear_layers[config.D_linear] if self.config.conditioning == 'proje...
1,448
39.25
89
py
robust-OT
robust-OT-main/robust CIFAR/GAN/models/resnet.py
import torch import torch.nn as nn import utils from .layers import * from .base import * class ResBlockGenerator(nn.Module): def __init__(self, config, in_channels, out_channels, stride=1): super(ResBlockGenerator, self).__init__() conv_layer = cond_conv_layers[config.G_conv] norm_layer ...
7,720
34.74537
117
py
robust-OT
robust-OT-main/robust CIFAR/GAN/models/layers.py
import torch import torch.nn as nn ############################################################################### # Unconditional layers class SpectralConv2d(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=T...
8,576
30.649446
119
py
robust-OT
robust-OT-main/robust CIFAR/GAN/models/DCGAN.py
import torch import torch.nn as nn from .layers import * from .base import * import utils import torch.nn.functional as F class Generator(nn.Module): def __init__(self, config): super(Generator, self).__init__() self.ngpu = int(config.ngpu) nz = int(config.nz) ngf = int(config.ngf)...
6,777
35.637838
117
py
robust-OT
robust-OT-main/robust StyleGAN 2/main.py
""" --- title: StyleGAN 2 Model Training summary: > An annotated PyTorch implementation of StyleGAN2 model training code. --- # [StyleGAN 2](index.html) Model Training This is the training code for [StyleGAN 2](index.html) model. ![Generated Images](generated_64.png) *<small>These are $64 \times 64$ images generat...
18,195
36.286885
122
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/hypernetworks/hyper_lstm.py
""" --- title: HyperNetworks - HyperLSTM summary: A PyTorch implementation/tutorial of HyperLSTM introduced in paper HyperNetworks. --- # HyperNetworks - HyperLSTM We have implemented HyperLSTM introduced in paper [HyperNetworks](https://arxiv.org/abs/1609.09106), with annotations using [PyTorch](https://pytorch.org)...
11,626
41.746324
180
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/hypernetworks/experiment.py
import torch import torch.nn as nn from labml import experiment from labml.configs import option from labml.utils.pytorch import get_modules from labml_helpers.module import Module from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs from labml_nn.hypernetworks.hyper_lstm import HyperLSTM from ...
2,825
26.436893
80
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/sketch_rnn/__init__.py
""" --- title: Sketch RNN summary: > This is an annotated PyTorch implementation of the Sketch RNN from paper A Neural Representation of Sketch Drawings. Sketch RNN is a sequence-to-sequence model that generates sketches of objects such as bicycles, cats, etc. --- # Sketch RNN This is an annotated [PyTorch](https...
25,107
38.540157
118
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/capsule_networks/__init__.py
""" --- title: Capsule Networks summary: > PyTorch implementation and tutorial of Capsule Networks. Capsule network is a neural network architecture that embeds features as capsules and routes them with a voting mechanism to next layer of capsules. --- # Capsule Networks This is a [PyTorch](https://pytorch.org)...
7,602
39.441489
178
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/capsule_networks/mnist.py
""" --- title: Classify MNIST digits with Capsule Networks summary: Code for training Capsule Networks on MNIST dataset --- # Classify MNIST digits with Capsule Networks This is an annotated PyTorch code to classify MNIST digits with PyTorch. This paper implements the experiment described in paper [Dynamic Routing B...
6,498
35.307263
109
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/batch_norm/cifar10.py
""" --- title: CIFAR10 Experiment to try Group Normalization summary: > This trains is a simple convolutional neural network that uses group normalization to classify CIFAR10 images. --- # CIFAR10 Experiment for Group Normalization """ import torch.nn as nn from labml import experiment from labml.configs import ...
1,629
24.076923
99
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/batch_norm/__init__.py
""" --- title: Batch Normalization summary: > A PyTorch implementation/tutorial of batch normalization. --- # Batch Normalization This is a [PyTorch](https://pytorch.org) implementation of Batch Normalization from paper [Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift](h...
9,671
41.421053
186
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/batch_norm/mnist.py
""" --- title: MNIST Experiment to try Batch Normalization summary: > This trains is a simple convolutional neural network that uses batch normalization to classify MNIST digits. --- # MNIST Experiment for Batch Normalization """ import torch.nn as nn import torch.nn.functional as F import torch.utils.data from ...
2,425
27.880952
91
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/group_norm/experiment.py
""" --- title: CIFAR10 Experiment to try Group Normalization summary: > This trains is a simple convolutional neural network that uses group normalization to classify CIFAR10 images. --- # CIFAR10 Experiment for Group Normalization """ import torch.nn as nn from labml import experiment from labml.configs import ...
2,308
25.54023
95
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/group_norm/__init__.py
""" --- title: Group Normalization summary: > A PyTorch implementation/tutorial of group normalization. --- # Group Normalization This is a [PyTorch](https://pytorch.org) implementation of the [Group Normalization](https://arxiv.org/abs/1803.08494) paper. [Batch Normalization](../batch_norm/index.html) works well f...
6,451
35.451977
191
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/weight_standardization/conv2d.py
""" --- title: 2D Convolution Layer with Weight Standardization summary: > A PyTorch implementation/tutorial of a 2D Convolution Layer with Weight Standardization. --- # 2D Convolution Layer with Weight Standardization This is an implementation of a 2 dimensional convolution layer with [Weight Standardization](./ind...
1,879
29.819672
107
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/weight_standardization/experiment.py
""" --- title: CIFAR10 Experiment to try Weight Standardization and Batch-Channel Normalization summary: > This trains is a VGG net that uses weight standardization and batch-channel normalization to classify CIFAR10 images. --- # CIFAR10 Experiment to try Weight Standardization and Batch-Channel Normalization ""...
1,818
26.560606
99
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/weight_standardization/__init__.py
""" --- title: Weight Standardization summary: > A PyTorch implementation/tutorial of Weight Standardization. --- # Weight Standardization This is a [PyTorch](https://pytorch.org) implementation of Weight Standardization from the paper [Micro-Batch Training with Batch-Channel Normalization and Weight Standardizatio...
3,780
42.45977
203
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/instance_norm/experiment.py
""" --- title: CIFAR10 Experiment to try Instance Normalization summary: > This trains is a simple convolutional neural network that uses instance normalization to classify CIFAR10 images. --- # CIFAR10 Experiment for Instance Normalization This demonstrates the use of an instance normalization layer in a convolu...
1,824
25.838235
99
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/instance_norm/__init__.py
""" --- title: Instance Normalization summary: > A PyTorch implementation/tutorial of instance normalization. --- # Instance Normalization This is a [PyTorch](https://pytorch.org) implementation of [Instance Normalization: The Missing Ingredient for Fast Stylization](https://arxiv.org/abs/1607.08022). Instance norm...
4,232
33.137097
114
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/batch_channel_norm/__init__.py
""" --- title: Batch-Channel Normalization summary: > A PyTorch implementation/tutorial of Batch-Channel Normalization. --- # Batch-Channel Normalization This is a [PyTorch](https://pytorch.org) implementation of Batch-Channel Normalization from the paper [Micro-Batch Training with Batch-Channel Normalization and W...
10,047
41.218487
203
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/normalization/layer_norm/__init__.py
""" --- title: Layer Normalization summary: > A PyTorch implementation/tutorial of layer normalization. --- # Layer Normalization This is a [PyTorch](https://pytorch.org) implementation of [Layer Normalization](https://arxiv.org/abs/1607.06450). ### Limitations of [Batch Normalization](../batch_norm/index.html) * ...
5,224
35.284722
103
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/recurrent_highway_networks/__init__.py
""" --- title: Recurrent Highway Networks summary: A simple PyTorch implementation/tutorial of Recurrent Highway Networks. --- # Recurrent Highway Networks This is a [PyTorch](https://pytorch.org) implementation of [Recurrent Highway Networks](https://arxiv.org/abs/1607.03474). """ from typing import Optional import...
5,685
34.098765
122
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/lstm/__init__.py
""" --- title: Long Short-Term Memory (LSTM) summary: A simple PyTorch implementation/tutorial of Long Short-Term Memory (LSTM) modules. --- # Long Short-Term Memory (LSTM) This is a [PyTorch](https://pytorch.org) implementation of Long Short-Term Memory. """ from typing import Optional, Tuple import torch from tor...
5,990
36.679245
103
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/graphs/gatv2/experiment.py
""" --- title: Train a Graph Attention Network v2 (GATv2) on Cora dataset summary: > This trains is a Graph Attention Network v2 (GATv2) on Cora dataset --- # Train a Graph Attention Network v2 (GATv2) on Cora dataset [![View Run](https://img.shields.io/badge/labml-experiment-brightgreen)](https://app.labml.ai/run...
3,796
31.452991
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/graphs/gatv2/__init__.py
""" --- title: Graph Attention Networks v2 (GATv2) summary: > A PyTorch implementation/tutorial of Graph Attention Networks v2. --- # Graph Attention Networks v2 (GATv2) This is a [PyTorch](https://pytorch.org) implementation of the GATv2 operator from the paper [How Attentive are Graph Attention Networks?](https://ar...
11,024
44.9375
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/graphs/gat/experiment.py
""" --- title: Train a Graph Attention Network (GAT) on Cora dataset summary: > This trains is a Graph Attention Network (GAT) on Cora dataset --- # Train a Graph Attention Network (GAT) on Cora dataset [![View Run](https://img.shields.io/badge/labml-experiment-brightgreen)](https://app.labml.ai/run/d6c636cadf3511...
10,542
32.683706
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/graphs/gat/__init__.py
""" --- title: Graph Attention Networks (GAT) summary: > A PyTorch implementation/tutorial of Graph Attention Networks. --- # Graph Attention Networks (GAT) This is a [PyTorch](https://pytorch.org) implementation of the paper [Graph Attention Networks](https://arxiv.org/abs/1710.10903). GATs work on graph data. A g...
9,047
44.014925
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/experiments/nlp_autoregression.py
""" --- title: NLP auto-regression trainer summary: > This is a reusable trainer for auto-regressive tasks --- # Auto-regressive NLP model trainer """ from typing import Callable import torch import torch.nn as nn from torch.utils.data import DataLoader from labml import lab, monit, logger, tracker from labml.con...
9,188
28.834416
118
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/experiments/nlp_classification.py
""" --- title: NLP classification trainer summary: > This is a reusable trainer for classification tasks --- # NLP model trainer for classification """ from collections import Counter from typing import Callable import torch import torchtext from torch import nn from torch.utils.data import DataLoader from torchte...
8,615
29.338028
113
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/experiments/cifar10.py
""" --- title: CIFAR10 Experiment summary: > This is a reusable trainer for CIFAR10 dataset --- # CIFAR10 Experiment """ from typing import List import torch.nn as nn from labml import lab from labml.configs import option from labml_helpers.datasets.cifar10 import CIFAR10Configs as CIFAR10DatasetConfigs from labml...
3,522
29.903509
84
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/experiments/mnist.py
""" --- title: MNIST Experiment summary: > This is a reusable trainer for MNIST dataset --- # MNIST Experiment """ import torch.nn as nn import torch.utils.data from labml_helpers.module import Module from labml import tracker from labml.configs import option from labml_helpers.datasets.mnist import MNISTConfigs a...
3,383
27.923077
88
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/ada_belief.py
""" --- title: AdaBelief optimizer summary: A simple PyTorch implementation/tutorial of AdaBelief optimizer. --- # AdaBelief Optimizer This is based from AdaBelief [official implementation](https://github.com/juntang-zhuang/Adabelief-Optimizer) of the paper [AdaBelief Optimizer: Adapting Stepsizes by the Belief in Ob...
6,774
41.34375
128
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/amsgrad.py
""" --- title: AMSGrad Optimizer summary: A simple PyTorch implementation/tutorial of AMSGrad optimizer. --- # AMSGrad This is a [PyTorch](https://pytorch.org) implementation of the paper [On the Convergence of Adam and Beyond](https://arxiv.org/abs/1904.09237). We implement this as an extension to our [Adam optimiz...
8,022
38.136585
156
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/noam.py
""" --- title: Noam optimizer from Attention is All You Need paper summary: > This is a tutorial/implementation of Noam optimizer. Noam optimizer has a warm-up period and then an exponentially decaying learning rate. --- # Noam Optimizer This is the [PyTorch](https://pytorch.org) implementation of optimizer intro...
3,380
36.988764
117
py