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
ttfnet
ttfnet-master/mmdet/models/anchor_heads/fcos_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import distance2bbox, force_fp32, multi_apply, multiclass_nms from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule, Scale, bias_init_with_prob INF = 1e8 @HEADS.register_module class FCOSHead(n...
16,509
39.366748
79
py
ttfnet
ttfnet-master/mmdet/models/anchor_heads/guided_anchor_head.py
from __future__ import division import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import (AnchorGenerator, anchor_inside_flags, anchor_target, delta2bbox, force_fp32, ga_loc_target, ga_shape_target, multi_apply, multi...
25,226
39.820388
79
py
ttfnet
ttfnet-master/mmdet/models/anchor_heads/fovea_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from mmdet.core import multi_apply, multiclass_nms from mmdet.ops import DeformConv from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule, bias_init_with_prob INF = 1e8 class FeatureAlign(nn.Module): def ...
16,360
41.167526
79
py
ttfnet
ttfnet-master/mmdet/models/bbox_heads/bbox_head.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from mmdet.core import (auto_fp16, bbox_target, delta2bbox, force_fp32, multiclass_nms) from ..builder import build_loss from ..losses import accuracy from ..registry import HEADS @HEAD...
9,111
36.966667
79
py
ttfnet
ttfnet-master/mmdet/models/bbox_heads/convfc_bbox_head.py
import torch.nn as nn from ..registry import HEADS from ..utils import ConvModule from .bbox_head import BBoxHead @HEADS.register_module class ConvFCBBoxHead(BBoxHead): r"""More general bbox head, with shared conv and fc layers and two optional separated branches. /-> cls con...
6,943
36.333333
79
py
ttfnet
ttfnet-master/mmdet/models/bbox_heads/double_bbox_head.py
import torch.nn as nn from mmcv.cnn.weight_init import normal_init, xavier_init from ..backbones.resnet import Bottleneck from ..registry import HEADS from ..utils import ConvModule from .bbox_head import BBoxHead class BasicResBlock(nn.Module): """Basic residual block. This block is a little different from...
5,274
29.847953
78
py
ttfnet
ttfnet-master/mmdet/models/shared_heads/res_layer.py
import logging import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from mmdet.core import auto_fp16 from ..backbones import ResNet, make_res_layer from ..registry import SHARED_HEADS @SHARED_HEADS.register_module class ResLayer(nn.Module): def __init__...
2,236
29.643836
74
py
ttfnet
ttfnet-master/mmdet/models/utils/weight_init.py
import numpy as np import torch.nn as nn def xavier_init(module, gain=1, bias=0, distribution='normal'): assert distribution in ['uniform', 'normal'] if distribution == 'uniform': nn.init.xavier_uniform_(module.weight, gain=gain) else: nn.init.xavier_normal_(module.weight, gain=gain) i...
1,455
29.978723
71
py
ttfnet
ttfnet-master/mmdet/models/utils/norm.py
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) 'BN': ('bn', nn.BatchNorm2d), 'SyncBN': ('bn', nn.SyncBatchNorm), 'GN': ('gn', nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=''): """ Build normalization layer Args: ...
1,684
29.089286
74
py
ttfnet
ttfnet-master/mmdet/models/utils/scale.py
import torch import torch.nn as nn class Scale(nn.Module): """ A learnable scale parameter """ def __init__(self, scale=1.0): super(Scale, self).__init__() self.scale = nn.Parameter(torch.tensor(scale, dtype=torch.float)) def forward(self, x): return x * self.scale
314
18.6875
73
py
ttfnet
ttfnet-master/mmdet/models/utils/conv_ws.py
import torch.nn as nn import torch.nn.functional as F def conv_ws_2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1, eps=1e-5): c_in = weight.size(0) weight_flat = weight.view(c_in, -1...
1,335
27.425532
79
py
ttfnet
ttfnet-master/mmdet/models/utils/conv_module.py
import warnings import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from .conv_ws import ConvWS2d from .norm import build_norm_layer conv_cfg = { 'Conv': nn.Conv2d, 'ConvWS': ConvWS2d, # TODO: octave conv } def build_conv_layer(cfg, *args, **kwargs): """ Build convolution layer ...
5,745
33.824242
78
py
ttfnet
ttfnet-master/mmdet/models/losses/ghm_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES def _expand_binary_labels(labels, label_weights, label_channels): bin_labels = labels.new_full((labels.size(0), label_channels), 0) inds = torch.nonzero(labels >= 1).squeeze() if inds.numel() > 0: bin...
6,304
35.656977
79
py
ttfnet
ttfnet-master/mmdet/models/losses/mse_loss.py
import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES from .utils import weighted_loss mse_loss = weighted_loss(F.mse_loss) @LOSSES.register_module class MSELoss(nn.Module): def __init__(self, reduction='mean', loss_weight=1.0): super().__init__() self.reduction = ...
632
23.346154
66
py
ttfnet
ttfnet-master/mmdet/models/losses/balanced_l1_loss.py
import numpy as np import torch import torch.nn as nn from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def balanced_l1_loss(pred, target, beta=1.0, alpha=0.5, gamma=1.5, reduction='me...
1,884
25.928571
73
py
ttfnet
ttfnet-master/mmdet/models/losses/iou_loss.py
import torch import torch.nn as nn from mmdet.core import bbox_overlaps from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def iou_loss(pred, target, eps=1e-6): """IoU loss. Computing the IoU loss between a set of predicted bboxes and target bboxes. The loss is calculated as n...
5,635
32.547619
82
py
ttfnet
ttfnet-master/mmdet/models/losses/smooth_l1_loss.py
import torch import torch.nn as nn from ..registry import LOSSES from .utils import weighted_loss @weighted_loss def smooth_l1_loss(pred, target, beta=1.0): assert beta > 0 assert pred.size() == target.size() and target.numel() > 0 diff = torch.abs(pred - target) loss = torch.where(diff < beta, 0.5 *...
1,288
27.021739
73
py
ttfnet
ttfnet-master/mmdet/models/losses/utils.py
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
3,003
29.343434
79
py
ttfnet
ttfnet-master/mmdet/models/losses/accuracy.py
import torch.nn as nn def accuracy(pred, target, topk=1): assert isinstance(topk, (int, tuple)) if isinstance(topk, int): topk = (topk, ) return_single = True else: return_single = False maxk = max(topk) _, pred_label = pred.topk(maxk, dim=1) pred_label = pred_label.t(...
801
24.0625
69
py
ttfnet
ttfnet-master/mmdet/models/losses/focal_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from mmdet.ops import sigmoid_focal_loss as _sigmoid_focal_loss from ..registry import LOSSES from .utils import weight_reduce_loss # This method is only for debugging def py_sigmoid_focal_loss(pred, target, ...
3,636
31.473214
100
py
ttfnet
ttfnet-master/mmdet/models/losses/cross_entropy_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..registry import LOSSES from .utils import weight_reduce_loss def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None): # element-wise losses loss = F.cross_entropy(pred, label, reduction='none') # apply weigh...
3,386
31.567308
79
py
ttfnet
ttfnet-master/mmdet/models/backbones/dla.py
import os import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from mmdet.models.registry import BACKBONES import math import logging import numpy as np from os.path import join import torch from torch import nn import torch.nn.functional as F import torch.u...
16,847
34.770701
94
py
ttfnet
ttfnet-master/mmdet/models/backbones/hrnet.py
import logging import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ..registry import BACKBONES from ..utils import build_conv_layer, build_norm_layer from .resnet import BasicBlock, Bottleneck class HRM...
19,868
36.773764
79
py
ttfnet
ttfnet-master/mmdet/models/backbones/resnet.py
import logging import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from mmdet.models.plugins import GeneralizedAttention from mmdet.ops import ContextBlock, DeformConv, Modu...
18,098
32.331492
79
py
ttfnet
ttfnet-master/mmdet/models/backbones/ssd_vgg.py
import logging import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import VGG, constant_init, kaiming_init, normal_init, xavier_init from mmcv.runner import load_checkpoint from ..registry import BACKBONES @BACKBONES.register_module class SSDVGG(VGG): """VGG Backbone network for sin...
5,335
33.425806
79
py
ttfnet
ttfnet-master/mmdet/models/backbones/resnext.py
import math import torch.nn as nn from mmdet.ops import DeformConv, ModulatedDeformConv from ..registry import BACKBONES from ..utils import build_conv_layer, build_norm_layer from .resnet import Bottleneck as _Bottleneck from .resnet import ResNet class Bottleneck(_Bottleneck): def __init__(self, inplanes, pl...
8,336
33.882845
79
py
ttfnet
ttfnet-master/mmdet/models/backbones/darknet.py
import os import torch.nn as nn from mmcv.cnn import constant_init, kaiming_init from collections import OrderedDict from mmdet.models.utils import build_norm_layer from mmdet.models.registry import BACKBONES def common_conv2d(inplanes, planes, kernel, padding, ...
4,949
34.611511
93
py
ttfnet
ttfnet-master/mmdet/models/mask_heads/grid_head.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import kaiming_init, normal_init from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule @HEADS.register_module class GridHead(nn.Module): def __init__(self, ...
15,429
41.624309
79
py
ttfnet
ttfnet-master/mmdet/models/mask_heads/maskiou_head.py
import numpy as np import torch import torch.nn as nn from mmcv.cnn import kaiming_init, normal_init from torch.nn.modules.utils import _pair from mmdet.core import force_fp32 from ..builder import build_loss from ..registry import HEADS @HEADS.register_module class MaskIoUHead(nn.Module): """Mask IoU Head. ...
7,418
37.842932
79
py
ttfnet
ttfnet-master/mmdet/models/mask_heads/fcn_mask_head.py
import mmcv import numpy as np import pycocotools.mask as mask_util import torch import torch.nn as nn from torch.nn.modules.utils import _pair from mmdet.core import auto_fp16, force_fp32, mask_target from ..builder import build_loss from ..registry import HEADS from ..utils import ConvModule @HEADS.register_module...
7,043
37.703297
79
py
ttfnet
ttfnet-master/mmdet/models/mask_heads/fused_semantic_head.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import kaiming_init from mmdet.core import auto_fp16, force_fp32 from ..registry import HEADS from ..utils import ConvModule @HEADS.register_module class FusedSemanticHead(nn.Module): r"""Multi-level fused semantic segmentation head. in_1 -...
3,554
32.224299
79
py
ttfnet
ttfnet-master/mmdet/datasets/custom.py
import os.path as osp import mmcv import numpy as np from torch.utils.data import Dataset from .pipelines import Compose from .registry import DATASETS @DATASETS.register_module class CustomDataset(Dataset): """Custom dataset for detection. Annotation format: [ { 'filename': 'a.jpg'...
5,047
32.653333
75
py
ttfnet
ttfnet-master/mmdet/datasets/dataset_wrappers.py
import numpy as np from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .registry import DATASETS @DATASETS.register_module class ConcatDataset(_ConcatDataset): """A wrapper of concatenated dataset. Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but concat the group flag for...
1,639
28.285714
78
py
ttfnet
ttfnet-master/mmdet/datasets/loader/sampler.py
from __future__ import division import math import numpy as np import torch from mmcv.runner.utils import get_dist_info from torch.utils.data import DistributedSampler as _DistributedSampler from torch.utils.data import Sampler class DistributedSampler(_DistributedSampler): def __init__(self, dataset, num_repli...
5,866
34.557576
78
py
ttfnet
ttfnet-master/mmdet/datasets/loader/build_loader.py
import platform from functools import partial from mmcv.parallel import collate from mmcv.runner import get_dist_info from torch.utils.data import DataLoader from .sampler import DistributedGroupSampler, DistributedSampler, GroupSampler if platform.system() != 'Windows': # https://github.com/pytorch/pytorch/issu...
1,559
30.836735
78
py
ttfnet
ttfnet-master/mmdet/datasets/pipelines/formating.py
from collections.abc import Sequence import mmcv import numpy as np import torch from mmcv.parallel import DataContainer as DC from ..registry import PIPELINES def to_tensor(data): """Convert objects of various python types to :obj:`torch.Tensor`. Supported types are: :class:`numpy.ndarray`, :class:`torch....
5,994
31.058824
79
py
ttfnet
ttfnet-master/mmdet/utils/flops_counter.py
# Modified from flops-counter.pytorch by Vladislav Sovrasov # original repo: https://github.com/sovrasov/flops-counter.pytorch # MIT License # Copyright (c) 2018 Vladislav Sovrasov # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (th...
14,351
32.069124
79
py
ttfnet
ttfnet-master/mmdet/ops/context_block.py
import torch from mmcv.cnn import constant_init, kaiming_init from torch import nn def last_zero_init(m): if isinstance(m, nn.Sequential): constant_init(m[-1], val=0) else: constant_init(m, val=0) class ContextBlock(nn.Module): def __init__(self, inplanes, ...
3,766
34.87619
76
py
ttfnet
ttfnet-master/mmdet/ops/dcn/deform_pool.py
import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from . import deform_pool_cuda class DeformRoIPoolingFunction(Function): @staticmethod def forward(ctx, data, ...
10,212
39.367589
79
py
ttfnet
ttfnet-master/mmdet/ops/dcn/deform_conv.py
import math import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from . import deform_conv_cuda class DeformConvFunction(Function): @staticmethod def forward(ctx, input, ...
12,468
35.890533
79
py
ttfnet
ttfnet-master/mmdet/ops/masked_conv/masked_conv.py
import math import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from . import masked_conv2d_cuda class MaskedConv2dFunction(Function): @staticmethod def forward(ctx, features, mask, weight, b...
3,375
36.511111
79
py
ttfnet
ttfnet-master/mmdet/ops/sigmoid_focal_loss/sigmoid_focal_loss.py
import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from . import sigmoid_focal_loss_cuda class SigmoidFocalLossFunction(Function): @staticmethod def forward(ctx, input, target, gamma=2.0, alpha=0.25): ctx.save_for_backward(input, target)...
1,637
28.781818
77
py
ttfnet
ttfnet-master/mmdet/ops/roi_align/roi_align.py
import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from . import roi_align_cuda class RoIAlignFunction(Function): @staticmethod def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0): ...
3,068
33.875
79
py
ttfnet
ttfnet-master/mmdet/ops/roi_align/gradcheck.py
import os.path as osp import sys import numpy as np import torch from torch.autograd import gradcheck sys.path.append(osp.abspath(osp.join(__file__, '../../'))) from roi_align import RoIAlign # noqa: E402, isort:skip feat_size = 15 spatial_scale = 1.0 / 8 img_size = feat_size / spatial_scale num_imgs = 2 num_rois =...
879
27.387097
76
py
ttfnet
ttfnet-master/mmdet/ops/roi_pool/roi_pool.py
import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from . import roi_pool_cuda class RoIPoolFunction(Function): @staticmethod def forward(ctx, features, rois, out_size, spatial_scale): ...
2,544
32.486842
78
py
ttfnet
ttfnet-master/mmdet/ops/roi_pool/gradcheck.py
import os.path as osp import sys import torch from torch.autograd import gradcheck sys.path.append(osp.abspath(osp.join(__file__, '../../'))) from roi_pool import RoIPool # noqa: E402, isort:skip feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda() rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55]...
513
29.235294
66
py
ttfnet
ttfnet-master/mmdet/ops/nms/nms_wrapper.py
import numpy as np import torch import torch.nn as nn from . import nms_cpu, nms_cuda from .soft_nms_cpu import soft_nms_cpu def nms(dets, iou_thr, device_id=None): """Dispatch to either CPU or GPU NMS implementations. The input can be either a torch tensor or numpy array. GPU NMS will be used if the in...
3,959
34.675676
82
py
transitional-cGAN
transitional-cGAN-main/legacy.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
16,502
50.411215
154
py
transitional-cGAN
transitional-cGAN-main/style_mixing.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
4,891
40.109244
132
py
transitional-cGAN
transitional-cGAN-main/projector.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
8,990
41.211268
136
py
transitional-cGAN
transitional-cGAN-main/generate.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
5,338
40.069231
132
py
transitional-cGAN
transitional-cGAN-main/train.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
25,202
43.371479
192
py
transitional-cGAN
transitional-cGAN-main/calc_metrics.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
8,336
42.649215
142
py
transitional-cGAN
transitional-cGAN-main/training/loss.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
9,760
49.314433
160
py
transitional-cGAN
transitional-cGAN-main/training/augment.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
26,373
60.050926
366
py
transitional-cGAN
transitional-cGAN-main/training/dataset.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
8,551
35.084388
158
py
transitional-cGAN
transitional-cGAN-main/training/networks.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
38,364
50.56586
166
py
transitional-cGAN
transitional-cGAN-main/training/training_loop.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
23,347
50.314286
174
py
transitional-cGAN
transitional-cGAN-main/torch_utils/custom_ops.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
5,644
43.448819
146
py
transitional-cGAN
transitional-cGAN-main/torch_utils/training_stats.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
10,707
38.806691
118
py
transitional-cGAN
transitional-cGAN-main/torch_utils/persistence.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
9,708
37.527778
144
py
transitional-cGAN
transitional-cGAN-main/torch_utils/misc.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
10,995
40.338346
133
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/bias_act.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
10,047
46.173709
185
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/grid_sample_gradfix.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
3,299
38.285714
138
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/conv2d_gradfix.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
7,677
43.900585
197
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/upfirdn2d.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
16,287
41.306494
157
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/conv2d_resample.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
7,591
47.356688
130
py
transitional-cGAN
transitional-cGAN-main/torch_utils/ops/fma.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
2,034
32.360656
105
py
transitional-cGAN
transitional-cGAN-main/metrics/metric_utils.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
12,034
42.136201
167
py
transitional-cGAN
transitional-cGAN-main/metrics/kernel_inception_distance.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
2,302
48
118
py
transitional-cGAN
transitional-cGAN-main/metrics/frechet_inception_distance.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
2,312
50.4
118
py
transitional-cGAN
transitional-cGAN-main/metrics/perceptual_path_length.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
5,538
40.962121
131
py
transitional-cGAN
transitional-cGAN-main/metrics/inception_score.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
1,874
47.076923
126
py
transitional-cGAN
transitional-cGAN-main/metrics/metric_main.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
5,714
36.598684
147
py
transitional-cGAN
transitional-cGAN-main/metrics/precision_recall.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
3,617
56.428571
159
py
ANTsPy
ANTsPy-master/docs/source/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # ANTsPy documentation build configuration file, created by # sphinx-quickstart on Fri Dec 23 13:31:47 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # aut...
7,708
31.944444
84
py
T2NER
T2NER-master/t2ner/base.py
# -*- coding: utf-8 -*- import os import random import logging import numpy as np import torch import dataclasses import json from dataclasses import dataclass from transformers.file_utils import cached_property logger = logging.getLogger(__name__) class TrainInferenceUtils: @cached_property def _set...
5,967
28.98995
88
py
T2NER
T2NER-master/t2ner/evaluate.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import numpy as np import os import logging from seqeval.metrics import ( f1_score, precision_score, recall_score, classification_report ) from tqdm import tqdm from .base import TrainInferenceUtils from .data import utils, IGNORE_INDEX log...
9,698
36.886719
87
py
T2NER
T2NER-master/t2ner/train.py
# -*- coding: utf-8 -*- import logging import os import sys import random import json import time from abc import ABC, abstractmethod from tqdm import tqdm, trange from dataclasses import dataclass, field from collections import OrderedDict import torch import torch.nn as nn import numpy as np from .base import Tra...
25,359
35.647399
97
py
T2NER
T2NER-master/t2ner/modules/pooling.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn class Pooling(nn.Module): def __init__(self, mode="mean", hidden_dim=None): super().__init__() self.mode = mode if mode == "attn": self.linear = nn.Linear(hidden_dim, 1, bias=False) def forward(self, x, m...
1,972
34.872727
75
py
T2NER
T2NER-master/t2ner/modules/tagger.py
# -*- coding: utf-8 -*- import torch.nn as nn from .crf import ChainCRF from ..losses import MaskedSeqCrossEntropyLoss, MaskedSeqFocalLoss, MaskedSeqLDAMLoss from ..data import IGNORE_INDEX class Tagger(nn.Module): def __init__( self, input_dim, num_labels, use_crf=False, ...
2,550
31.291139
86
py
T2NER
T2NER-master/t2ner/modules/lstm.py
# -*- coding: utf-8 -*- """ Modified from https://github.com/thespectrewithin/joint_align/blob/master/feature_ner.py """ import torch import torch.nn as nn import numpy as np from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence class LSTM(nn.Module): def __init__( self, ...
1,426
27.54
151
py
T2NER
T2NER-master/t2ner/modules/multicell_lstm.py
# -*- coding: utf-8 -*- """ Taken from https://github.com/jiachenwestlake/Multi-Cell_LSTM/blob/master/UDA/model/MultiCell_LSTM_compos_UDA.py """ import copy import math import torch from torch import nn from torch.nn import functional, init import torch.nn.functional as F import numpy as np class Compute_Gate(nn.Mo...
10,493
40.976
123
py
T2NER
T2NER-master/t2ner/modules/mmd.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn from torch.nn import functional as F class MaximumMeanDiscrepancy(nn.Module): def __init__(self, kernel_type="rbf", normalize=False): super(MaximumMeanDiscrepancy, self).__init__() self.kernel_type = kernel_type self.normali...
2,900
33.129412
75
py
T2NER
T2NER-master/t2ner/modules/language_modeling.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn from ..losses import CausalLanguageModelingLoss class TransformersCLM(nn.Module): def __init__(self, config): super().__init__() self.net = nn.Sequential( nn.Dropout(config.hidden_dropout_prob), nn.Linear(con...
2,413
36.138462
88
py
T2NER
T2NER-master/t2ner/modules/classifier.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn from .tagger import Tagger from .grl import GradientReverseLayer, WarmStartGradientReverseLayer class SoftmaxClassifier(nn.Module): def __init__(self, input_dim, num_labels): super().__init__() self.linear = nn.Linear(input_dim, num...
4,553
29.15894
80
py
T2NER
T2NER-master/t2ner/modules/transformer.py
# -*- coding: utf-8 -*- import torch.nn as nn class Transformer(nn.Module): def __init__( self, input_dim, hidden_dim=768, num_layers=1, num_heads=8, dropout=0.1, activation="relu" ): super().__init__() transformer_encoder_layer = n...
847
24.69697
87
py
T2NER
T2NER-master/t2ner/modules/grl.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import numpy as np from torch.autograd import Function class GradientReverseFunction(Function): @staticmethod def forward(ctx, input, coeff=1.): ctx.coeff = coeff output = input * 1.0 return output @staticmethod...
1,406
21.693548
100
py
T2NER
T2NER-master/t2ner/modules/crf.py
# -*- coding: utf-8 -*- """ Taken from https://github.com/shijie-wu/crosslingual-nlp/blob/master/src/crf.py Based on https://github.com/thespectrewithin/joint_align/blob/master/crf.py with better support of masking, allowing masking in the middle of a sentence. """ import torch import torch.nn as nn from torch.nn.p...
7,716
35.923445
88
py
T2NER
T2NER-master/t2ner/modules/hyper_multi_head_attention.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import torch.nn.functional as F class MHAParameterGenetrator(nn.Module): def __init__(self, input_dim, hidden_dim): super().__init__() self.hidden_dim = hidden_dim self.in_hparam_w = nn.Parameter(torch.empty(input_di...
3,129
31.947368
91
py
T2NER
T2NER-master/t2ner/modules/optimal_transport.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn from torch.nn import functional as F class OptimalTransport(nn.Module): @staticmethod def distance(batch1, batch2, dist_metric="cosine"): if dist_metric == "cosine": batch1 = F.normalize(batch1, p=2, dim=1) batch2...
3,342
32.767677
85
py
T2NER
T2NER-master/t2ner/modules/masked_softmax.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn class MaskedSoftmax(nn.Module): def __init__(self): super().__init__() def forward(self, logits, mask=None, dim=-1, epsilon=1e-5): # cf. https://discuss.pytorch.org/t/apply-mask-softmax/14212/15 exps = torch.exp(logi...
566
26
71
py
T2NER
T2NER-master/t2ner/nets/nets.py
# -*- coding: utf-8 -*- import torch.nn as nn from ..modules import LSTM, Transformer class XNetBase(nn.Module): def __init__(self, config): super().__init__() def forward(self, encoded, mask=None): raise NotImplementedError class LSTMNet(XNetBase): def __init__(self, co...
1,504
26.87037
90
py
T2NER
T2NER-master/t2ner/models/base.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import dataclasses from dataclasses import dataclass, field from .. import modules from .. import nets from ..base import ArgumentsBase class TransformersUtils(nn.Module): def __init__(self): super().__init__() @classmethod d...
8,942
34.070588
100
py
T2NER
T2NER-master/t2ner/models/multi_token_classification.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import os from . import base from .. import modules from . import HF_MODELS, bert, xlm, xlmr from transformers import AutoConfig, PretrainedConfig from collections import OrderedDict class MultiTokenClassificationUtils(base.TransformersUtils): def...
16,162
35.567873
103
py
T2NER
T2NER-master/t2ner/models/token_classification.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import os from . import base from .. import modules from . import HF_MODELS, bert, xlm, xlmr from transformers import AutoConfig, PretrainedConfig from collections import OrderedDict class TokenClassificationUtils(base.TransformersUtils): def __in...
7,196
35.907692
103
py
T2NER
T2NER-master/t2ner/optim/lr_scheduler.py
""" Modified from https://github.com/KaiyangZhou/deep-person-reid """ import torch from transformers import optimization as optim AVAI_SCHEDS = ["constant", "linear", "cosine", "cosinehr"] def build_lr_scheduler(optimizer, lr_scheduler="linear", **kwargs): """A function wrapper for building a learning rate sche...
2,280
34.092308
88
py
T2NER
T2NER-master/t2ner/optim/radam.py
""" Imported from: https://github.com/LiyuanLucasLiu/RAdam 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}, jou...
11,564
34.045455
129
py
T2NER
T2NER-master/t2ner/optim/optimizer.py
""" Modified from https://github.com/KaiyangZhou/deep-person-reid """ import warnings import torch import torch.nn as nn from .radam import RAdam from transformers.optimization import AdamW AVAI_OPTIMS = ["adam", "adamw", "amsgrad", "sgd", "rmsprop", "radam"] def build_optimizer(model, optim="adamw", **kwargs): ...
4,631
28.503185
87
py
T2NER
T2NER-master/t2ner/data/ner.py
# -*- coding: utf-8 -*- import os import logging import torch import random import collections import functools from torch.utils.data import Dataset, DataLoader from torch.utils.data import RandomSampler, SequentialSampler from transformers import XLMTokenizer from . import utils logging.basicConfig(level=logging.I...
25,485
35.82948
110
py