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 |
|---|---|---|---|---|---|---|
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/apis/matting_inference.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import torch
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint
from mmedit.datasets.pipelines import Compose
from mmedit.models import build_model
def init_model(config, checkpoint=None, device='cuda:0'):
"""Initialize a... | 2,659 | 33.545455 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/apis/video_interpolation_inference.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import os
import os.path as osp
import cv2
import mmcv
import numpy as np
import torch
from mmcv.fileio import FileClient
from mmcv.parallel import collate
from mmedit.datasets.pipelines import Compose
VIDEO_EXTENSIONS = ('.mp4', '.mov', '.avi')
FILE_CLIENT... | 6,978 | 33.043902 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/apis/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import random
import warnings
import mmcv
import numpy as np
import torch
import torch.distributed as dist
from mmcv.parallel import MMDataParallel
from mmcv.runner import HOOKS, IterBasedRunner, get_dist_info
from mmcv.utils import build_... | 12,897 | 34.629834 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/apis/restoration_video_inference.py | # Copyright (c) OpenMMLab. All rights reserved.
import glob
import os.path as osp
import re
from functools import reduce
import mmcv
import numpy as np
import torch
from mmedit.datasets.pipelines import Compose
VIDEO_EXTENSIONS = ('.mp4', '.mov')
def pad_sequence(data, window_size):
padding = window_size // 2
... | 4,669 | 34.923077 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/distributed_wrapper.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.parallel import MODULE_WRAPPERS, MMDistributedDataParallel
from mmcv.parallel.scatter_gather import scatter_kwargs
from torch.cuda._utils import _get_device_index
@MODULE_WRAPPERS.register_module()
class DistributedDataParall... | 5,720 | 39.864286 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/misc.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import numpy as np
import torch
from torchvision.utils import make_grid
def tensor2img(tensor, out_type=np.uint8, min_max=(0, 1)):
"""Convert torch Tensors into image numpy arrays.
After clamping to (min, max), image values will be normalized to [0... | 2,898 | 37.653333 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/evaluation/eval_hooks.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from mmcv.runner import Hook
from torch.utils.data import DataLoader
class EvalIterHook(Hook):
"""Non-Distributed evaluation hook for iteration-based runner.
This hook will regularly perform evaluation in a given interval when
perform... | 3,766 | 33.87963 | 75 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/export/wrappers.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
import numpy as np
import onnxruntime as ort
import torch
from torch import nn
from mmedit.models import BaseMattor, BasicRestorer, build_model
def inference_with_session(sess, io_binding, output_names, input_tensor):
device_t... | 4,767 | 34.318519 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/hooks/visualization.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import torch
from mmcv.runner import HOOKS, Hook
from mmcv.runner.dist_utils import master_only
from torchvision.utils import save_image
@HOOKS.register_module()
class VisualizationHook(Hook):
"""Visualization hook.
In this ho... | 3,050 | 34.894118 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/hooks/ema.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
from copy import deepcopy
from functools import partial
import mmcv
import torch
from mmcv.parallel import is_module_wrapper
from mmcv.runner import HOOKS, Hook
@HOOKS.register_module()
class ExponentialMovingAverageHook(Hook):
"""Exponential Moving... | 4,719 | 40.403509 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/utils/dist_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.distributed as dist
from mmcv.runner import get_dist_info
def sync_random_seed(seed=None, device='cuda'):
"""Make sure different ranks share the same seed.
All workers must call this function, otherwise it will deadlo... | 1,108 | 29.805556 | 73 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/core/optimizer/builder.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.runner import build_optimizer
def build_optimizers(model, cfgs):
"""Build multiple optimizers from configs.
If `cfgs` contains several dicts for optimizers, then a dict for each
constructed optimizers will be returned.
If `cfgs` only contains ... | 1,679 | 27.474576 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/base.py | # Copyright (c) OpenMMLab. All rights reserved.
from abc import ABCMeta, abstractmethod
from collections import OrderedDict
import torch
import torch.nn as nn
class BaseModel(nn.Module, metaclass=ABCMeta):
"""Base model.
All models should subclass it.
All subclass should overwrite:
``init_weigh... | 2,948 | 26.820755 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv import build_from_cfg
from .registry import BACKBONES, COMPONENTS, LOSSES, MODELS
def build(cfg, registry, default_args=None):
"""Build module function.
Args:
cfg (dict): Configuration for building modules.
regis... | 1,482 | 23.311475 | 75 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/restorers/basicvsr.py | # Copyright (c) OpenMMLab. All rights reserved.
import numbers
import os.path as osp
import mmcv
import numpy as np
import torch
from mmedit.core import tensor2img
from ..registry import MODELS
from .basic_restorer import BasicRestorer
@MODELS.register_module()
class BasicVSR(BasicRestorer):
"""BasicVSR model f... | 8,430 | 36.471111 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/flow_warp.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
def flow_warp(x,
flow,
interpolation='bilinear',
padding_mode='zeros',
align_corners=True):
"""Warp an image or a feature map with optical flow.
Args:
x... | 1,781 | 36.125 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/aspp.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn import ConvModule
from torch import nn
from torch.nn import functional as F
from .separable_conv_module import DepthwiseSeparableConvModule
class ASPPPooling(nn.Sequential):
def __init__(self, in_channels, out_channels, conv_cfg, norm_cf... | 3,861 | 29.650794 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/sr_backbone_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.utils.parrots_wrapper import _BatchNorm
def default_init_weights(module, scale=1):
"""Initialize network weights.
Args:
modules (nn.Module): Modules to be initialized.
... | 2,919 | 28.795918 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/model_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
def set_requires_grad(nets, requires_grad=False):
"""Set requires_grad for all the networks.
Args:
nets (nn.Module | list[nn.Module]): A list of networks or a single
network.
requires_grad (bool): Whet... | 4,502 | 31.868613 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/separable_conv_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import ConvModule
class DepthwiseSeparableConvModule(nn.Module):
"""Depthwise separable convolution module.
See https://arxiv.org/pdf/1704.04861.pdf for details.
This module can replace a ConvModule with the conv block r... | 3,907 | 38.877551 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/linear_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv.cnn import build_activation_layer, kaiming_init
class LinearModule(nn.Module):
"""A linear block that contains linear/norm/activation layers.
For low level vision, we add spectral norm and padding layer.
Args:
in_fea... | 3,204 | 34.611111 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/contextual_attention.py | # Copyright (c) OpenMMLab. All rights reserved.
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
class ContextualAttentionModule(nn.Module):
"""Contexture attention module.
The details of this module can be found in:
Generative Image Inpainting with Contex... | 15,214 | 39.039474 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/gated_conv_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, build_activation_layer
class SimpleGatedConvModule(nn.Module):
"""Simple Gated Convolutional Module.
This module is a simple gated convolutional module. The detailed formula
is... | 2,423 | 32.205479 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/conv.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.cnn import CONV_LAYERS
from torch import nn
CONV_LAYERS.register_module('Deconv', module=nn.ConvTranspose2d)
# TODO: octave conv
| 188 | 26 | 64 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/gca_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, constant_init, xavier_init
from torch.nn import functional as F
class GCAModule(nn.Module):
"""Guided Contextual Attention Module.
From https://arxiv.org/pdf/2001.04069.pdf.
Based on https:... | 14,808 | 40.250696 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/generation_model_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, kaiming_init, normal_init, xavier_init
from torch.nn import init
def generation_init_weights(module, init_type='normal', init_gain=0.02):
"""Default initialization of network weig... | 10,699 | 34.430464 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/ensemble.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
class SpatialTemporalEnsemble(nn.Module):
""" Apply spatial and temporal ensemble and compute outputs
Args:
is_temporal_ensemble (bool, optional): Whether to apply ensemble
temporally. If True, the sequence... | 3,541 | 32.415094 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/upsample.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.nn.functional as F
from .sr_backbone_utils import default_init_weights
class PixelShufflePack(nn.Module):
""" Pixel Shuffle upsample layer.
Args:
in_channels (int): Number of input channels.
out_channels (int)... | 1,517 | 28.192308 | 76 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/img_normalize.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
class ImgNormalize(nn.Conv2d):
"""Normalize images with the given mean and std value.
Based on Conv2d layer, can work in GPU.
Args:
pixel_range (float): Pixel range of feature.
img_mean (Tuple[float]): Ima... | 1,063 | 31.242424 | 68 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/mask_conv_module.py | # Copyright (c) OpenMMLab. All rights reserved.
from mmcv.cnn import ConvModule
class MaskConvModule(ConvModule):
"""Mask convolution module.
This is a simple wrapper for mask convolution like: 'partial conv'.
Convolutions in this module always need a mask as extra input.
Args:
in_channels (... | 3,649 | 40.011236 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/common/partial_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import CONV_LAYERS
@CONV_LAYERS.register_module(name='PConv')
class PartialConv2d(nn.Conv2d):
"""Implementation for partial convolution.
Image Inpainting for Irr... | 3,605 | 34.009709 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/losses/pixelwise_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..registry import LOSSES
from .utils import masked_loss
_reduction_modes = ['none', 'mean', 'sum']
@masked_loss
def l1_loss(pred, target):
"""L1 loss.
Args:
pred (Tensor): Predict... | 7,356 | 32.13964 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/losses/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
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".
Returns:
Tensor: R... | 3,743 | 31.275862 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/losses/gan_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.functional import conv2d
from ..registry import LOSSES
@LOSSES.register_module()
class GANLoss(nn.Module):
"""Define GAN loss.
Args:
gan_... | 11,506 | 32.353623 | 86 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/losses/perceptual_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torchvision.models.vgg as vgg
from mmcv.runner import load_checkpoint
from torch.nn import functional as F
from mmedit.utils import get_root_logger
from ..registry import LOSSES
class PerceptualVGG(nn.Module):
"""VGG networ... | 10,350 | 34.940972 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/backbones/sr_backbones/basicvsr_pp.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init
from mmcv.ops import ModulatedDeformConv2d, modulated_deform_conv2d
from mmcv.runner import load_checkpoint
from mmedit.models.backbones.sr_backbones.basicvsr_net import... | 16,773 | 37.56092 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/models/backbones/sr_backbones/basicvsr_net.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmcv.runner import load_checkpoint
from mmedit.models.common import (PixelShufflePack, ResidualBlockNoBN,
flow_warp, make_layer)
from... | 14,148 | 32.608076 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/base_dataset.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
from abc import ABCMeta, abstractmethod
from torch.utils.data import Dataset
from .pipelines import Compose
class BaseDataset(Dataset, metaclass=ABCMeta):
"""Base class for datasets.
All datasets should subclass it.
All subclasses should overw... | 2,006 | 24.405063 | 73 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import platform
import random
from functools import partial
import numpy as np
import torch
from mmcv.parallel import collate
from mmcv.runner import get_dist_info
from mmcv.utils import build_from_cfg
from packaging import version
from torch.utils.data impor... | 6,177 | 32.945055 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/samplers/distributed_sampler.py | # Copyright (c) OpenMMLab. All rights reserved.
from __future__ import division
import math
import torch
from torch.utils.data import DistributedSampler as _DistributedSampler
from mmedit.core.utils import sync_random_seed
class DistributedSampler(_DistributedSampler):
"""DistributedSampler inheriting from `tor... | 2,892 | 39.180556 | 80 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/crop.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import random
import mmcv
import numpy as np
from torch.nn.modules.utils import _pair
from ..registry import PIPELINES
from .utils import random_choose_unknown
@PIPELINES.register_module()
class Crop:
"""Crop data to specific size for training.
Ar... | 28,291 | 36.722667 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/augmentation.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import math
import numbers
import os
import os.path as osp
import random
import cv2
import mmcv
import numpy as np
import torchvision.transforms as transforms
from PIL import Image
from ..registry import PIPELINES
@PIPELINES.register_module()
class Resize:... | 46,436 | 35.081585 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import numpy as np
import torch
from mmcv.utils import print_log
_integer_types = (
np.byte,
np.ubyte, # 8 bits
np.short,
np.ushort, # 16 bits
np.intc,
np.uintc, # 16 or 32 or 64 bits
np.int_,
np.uint, # 32 or 64 bits
... | 4,623 | 28.832258 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/random_down_sampling.py | # Copyright (c) OpenMMLab. All rights reserved.
import math
import numpy as np
import torch
from mmcv import imresize
from ..registry import PIPELINES
@PIPELINES.register_module()
class RandomDownSampling:
"""Generate LQ image from GT (and crop), which will randomly pick a scale.
Args:
scale_min (f... | 4,735 | 36.587302 | 79 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/formating.py | # Copyright (c) OpenMMLab. All rights reserved.
from collections.abc import Sequence
import mmcv
import numpy as np
import torch
from mmcv.parallel import DataContainer as DC
from torch.nn import functional as F
from ..registry import PIPELINES
def to_tensor(data):
"""Convert objects of various python types to ... | 8,262 | 30.299242 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/datasets/pipelines/generate_assistant.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from ..registry import PIPELINES
from .utils import make_coord
@PIPELINES.register_module()
class GenerateHeatmap:
"""Generate heatmap from keypoint.
Args:
keypoint (str): Key of keypoint in dict.
ori_size (int |... | 6,056 | 34.629412 | 78 | py |
BasicVSR_PlusPlus | BasicVSR_PlusPlus-master/mmedit/utils/setup_env.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import platform
import warnings
import cv2
import torch.multiprocessing as mp
def setup_multi_processes(cfg):
"""Setup multi-processing environment variables."""
# set multi-process start method as `fork` to speed up the training
if platform.syste... | 2,219 | 45.25 | 112 | py |
SLOPpy | SLOPpy-main/docs/conf.py | # -*- coding: utf-8 -*-
#
# PyORBIT documentation build configuration file, created by
# sphinx-quickstart on Sat Dec 16 17:20:15 2017.
#
# 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
# autogenerated file.
#
# A... | 4,554 | 29.57047 | 80 | py |
EPSANet | EPSANet-master/main.py | import argparse
import os
import random
import shutil
import time
import warnings
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transform... | 15,032 | 34.707838 | 114 | py |
EPSANet | EPSANet-master/loss.py | import torch
import numpy as np
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class CrossEntropyLabelSmooth(nn.Module):
"""Cross entropy loss with label smoothing regularizer.
Reference:
Szegedy et al. Rethinking the Inception Architecture for Computer Vision. CVP... | 1,320 | 36.742857 | 91 | py |
EPSANet | EPSANet-master/models/SE_weight_module.py |
import torch.nn as nn
class SEWeightModule(nn.Module):
def __init__(self, channels, reduction=16):
super(SEWeightModule, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc1 = nn.Conv2d(channels, channels//reduction, kernel_size=1, padding=0)
self.relu = nn.ReLU(inpla... | 651 | 30.047619 | 85 | py |
EPSANet | EPSANet-master/models/epsanet.py | import torch
import torch.nn as nn
import math
from .SE_weight_module import SEWeightModule
def conv(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1, groups=1):
"""standard convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride,
... | 6,122 | 35.664671 | 113 | py |
trieste-develop | trieste-develop/trieste/models/__init__.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 1,220 | 34.911765 | 98 | py |
trieste-develop | trieste-develop/trieste/models/optimizer.py | # Copyright 2020 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 9,230 | 37.949367 | 100 | py |
trieste-develop | trieste-develop/trieste/models/gpflux/models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 18,255 | 44.526185 | 100 | py |
trieste-develop | trieste-develop/trieste/models/gpflux/interface.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 3,501 | 37.483516 | 98 | py |
trieste-develop | trieste-develop/trieste/models/keras/architectures.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 14,523 | 40.497143 | 100 | py |
trieste-develop | trieste-develop/trieste/models/keras/builders.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 3,471 | 40.831325 | 99 | py |
trieste-develop | trieste-develop/trieste/models/keras/models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 25,439 | 47.923077 | 100 | py |
trieste-develop | trieste-develop/trieste/models/keras/__init__.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 1,334 | 45.034483 | 94 | py |
trieste-develop | trieste-develop/trieste/models/keras/interface.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 4,335 | 36.37931 | 100 | py |
trieste-develop | trieste-develop/tests/unit/models/gpflux/test_interface.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 5,238 | 34.639456 | 96 | py |
trieste-develop | trieste-develop/tests/unit/models/gpflux/test_models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 20,131 | 35.67031 | 98 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_architectures.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 9,121 | 34.084615 | 100 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_interface.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 2,045 | 30.96875 | 81 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_builders.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 2,334 | 37.278689 | 100 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 28,485 | 37.390836 | 100 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_sampler.py | # Copyright 2020 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 17,015 | 35.515021 | 100 | py |
trieste-develop | trieste-develop/tests/unit/models/keras/test_utils.py | # Copyright 2021 The Bellman Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 4,687 | 34.78626 | 90 | py |
trieste-develop | trieste-develop/tests/util/models/gpflux/models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 5,115 | 30.195122 | 91 | py |
trieste-develop | trieste-develop/tests/util/models/keras/models.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 2,717 | 29.539326 | 99 | py |
trieste-develop | trieste-develop/tests/integration/test_bayesian_optimization.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 26,051 | 36.058321 | 100 | py |
trieste-develop | trieste-develop/tests/integration/models/multifidelity/test_multifidelity_models.py | import gpflow
import numpy as np
import numpy.testing as npt
import tensorflow as tf
from tensorflow.keras.metrics import mean_squared_error
import trieste
from trieste.data import (
Dataset,
add_fidelity_column,
check_and_extract_fidelity_query_points,
split_dataset_by_fidelity,
)
from trieste.models.... | 21,553 | 37.148673 | 99 | py |
trieste-develop | trieste-develop/tests/integration/models/keras/test_predictions.py | # Copyright 2021 The Trieste Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 1,688 | 32.117647 | 94 | py |
trieste-develop | trieste-develop/docs/notebooks/deep_ensembles.pct.py | # %% [markdown]
# # Bayesian optimization with deep ensembles
#
# Gaussian processes as a surrogate models are hard to beat on smaller datasets and optimization budgets. However, they scale poorly with amount of data, cannot easily capture non-stationarities and they are rather slow at prediction time. Here we show how... | 19,205 | 52.798319 | 984 | py |
tensiometer | tensiometer-master/tensiometer/mcmc_tension/flow.py | """
"""
###############################################################################
# initial imports and set-up:
import os
import time
import gc
from numba import jit
import numpy as np
import getdist.chains as gchains
gchains.print_load_details = False
from getdist import MCSamples, WeightedSamples
import scip... | 26,170 | 49.040153 | 648 | py |
white_box_rarl | white_box_rarl-main/wbrarl.py | import sys
import os
import time
import random
import argparse
import multiprocessing
import pickle
import copy
from multiprocessing import freeze_support
import numpy as np
import torch
import gym
from stable_baselines3.ppo import PPO
from stable_baselines3.sac import SAC
from stable_baselines3.common.vec_env import S... | 24,786 | 43.341682 | 148 | py |
neurotron_experiments | neurotron_experiments-main/neurotron_torch.py | # %% [markdown]
# # Settings
# %%
import torch
import matplotlib.pyplot as plt
import numpy as np
import torch.nn as nn
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from torch.utils.data import DataLoader... | 8,128 | 25.478827 | 122 | py |
CTAB-GAN-Plus | CTAB-GAN-Plus-main/model/synthesizer/ctabgan_synthesizer.py | import numpy as np
import pandas as pd
import torch
import torch.utils.data
import torch.optim as optim
from torch.optim import Adam
from torch.nn import functional as F
from torch.nn import (Dropout, LeakyReLU, Linear, Module, ReLU, Sequential,
Conv2d, ConvTranspose2d, Sigmoid, init, BCELoss, CrossEntropyLoss,SmoothL1... | 21,711 | 35.186667 | 173 | py |
CTAB-GAN-Plus | CTAB-GAN-Plus-main/model/synthesizer/transformer.py | import numpy as np
import pandas as pd
import torch
from sklearn.mixture import BayesianGaussianMixture
class DataTransformer():
def __init__(self, train_data=pd.DataFrame, categorical_list=[], mixed_dict={}, general_list=[], non_categorical_list=[], n_clusters=10, eps=0.005):
self.meta = None
... | 17,809 | 40.418605 | 152 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/simulate.py | import io
import os
import time
import pickle
import random
import logging
import datetime
import argparse
import coloredlogs
import numpy as np
import pandas as pd
from torch.utils.data import WeightedRandomSampler
from policy import FmEGreedy, Random, Greedy, FmGreedy, LinUCB, FmThompson, TS
logger = logging.getLo... | 9,990 | 37.724806 | 122 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/utils.py | from collections import defaultdict
import torch
from torch.optim.optimizer import Optimizer
class FTRL(Optimizer):
""" Implements FTRL online learning algorithm.
Arguments:
params (iterable): iterable of parameters to optimize or dicts defining
parameter groups
alpha (float, opti... | 4,886 | 33.907143 | 99 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/model.py | import torch
import torch.nn as nn
import torch.distributions.normal as normal
import torch.nn.functional as F
import math
import time
import numpy as np
import random
from torch.autograd import Variable
PRIMITIVES = ['concat', 'multiply', 'max', 'min', 'plus']
# PRIMITIVES = ['zero', 'max', 'min', 'multiply', 'plus', ... | 27,434 | 44.123355 | 197 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/policy.py | import time
import torch
import pickle
import numpy as np
import pandas as pd
from torch.utils.data import WeightedRandomSampler
from train import Core
from train_arch import Train_Arch
from model import Linucb
def get_creative(params):
"return global creative list, and item-creatives dict"
with open(params... | 14,589 | 39.082418 | 239 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/utils_gen.py | from train import Core
from train_arch import Train_Arch
import argparse
import pickle
import numpy as np
import torch
dataset_name = "data_nas"
def gen_simulation_ctr():
c_list = None
with open("raw_data/"+dataset_name+"/creative_list.pkl", 'rb') as f:
c_list = pickle.load(f)
c_list = np.array(c_... | 3,692 | 30.29661 | 88 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/ctr.py | import numpy as np
import pandas as pd
import torch.utils.data
import itertools
import tqdm
import time
def get_index(dataset, dense_list=None):
emb_index = []
cnt = 0
dim = 0
for i in range(len(dataset)):
emb_index.append(dict())
if i in dense_list:
dim += 1
co... | 3,515 | 29.310345 | 101 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/train_arch.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import argparse
from model import NAS, NAS_TS, SNAS, DSNAS, SNAS_TS, DSNAS_TS
from ctr import TfsDataset, DirectDataset, DenseDataset
from torch.utils.data import DataLoader
import time
from utils import DataPrefetcher
from sklearn.me... | 15,572 | 42.744382 | 143 | py |
AutoCO | AutoCO-main/exp_simulate/fm_nas/train.py | import os
import time
import torch
import pickle
import numpy as np
import torch.nn.functional as F
from sklearn.metrics import roc_auc_score, log_loss
from torch.utils.data import DataLoader
from ctr import TfsDataset, DirectDataset, DenseDataset
from model import OFM, OFM_TS
from utils import cal_group_auc, FTRL
o... | 11,347 | 39.820144 | 121 | py |
AutoCO | AutoCO-main/exp_public/mushroom/simulate/main.py | import os
import sys
import glob
import numpy as np
import torch
import logging
import argparse
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torch.utils
import torch.nn.functional as F
from torch.autograd import Variable
import time
import utils
from train import train
from vartional_model import D... | 13,976 | 50.386029 | 137 | py |
AutoCO | AutoCO-main/exp_public/mushroom/simulate/utils.py | import numpy as np
import pandas as pd
import os
import os.path
import sys
import shutil
import torch
import torch.nn as nn
import torch.utils
from sklearn.preprocessing import StandardScaler
from sklearn.feature_extraction import DictVectorizer
from sklearn.utils import shuffle
from torch.utils.data import Dataset, Da... | 6,504 | 43.554795 | 98 | py |
AutoCO | AutoCO-main/exp_public/mushroom/simulate/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
import time
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS = [0, 2, 4, 8, 16]
SPACE_NAS = pow(len(PRIMITIVES_NAS), 5)
OPS = {
'plus': lambda p, q: ... | 29,059 | 42.897281 | 165 | py |
AutoCO | AutoCO-main/exp_public/mushroom/simulate/baseline.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
from collections import Counter
from torch.distributions.multivariate_normal import MultivariateNormal
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS =... | 37,783 | 46.112219 | 141 | py |
AutoCO | AutoCO-main/exp_public/mushroom/simulate/vartional_model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS = [0, 2, 4, 8, 16]
SPACE_NAS = pow(len(PRIMITIVES_NAS), 5)
OPS = {
'plus': lambda p, q: p + q,
'... | 50,650 | 49.905528 | 176 | py |
AutoCO | AutoCO-main/exp_public/adult/simulate/utils.py | import numpy as np
import pandas as pd
import os
import os.path
import sys
import shutil
import torch
import torch.nn as nn
import torch.utils
from sklearn.preprocessing import StandardScaler
from sklearn.feature_extraction import DictVectorizer
from sklearn.utils import shuffle
from torch.utils.data import Dataset, Da... | 4,315 | 36.206897 | 126 | py |
AutoCO | AutoCO-main/exp_public/adult/simulate/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
import time
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS = [0, 2, 4, 8, 16]
SPACE_NAS = pow(len(PRIMITIVES_NAS), 5)
OPS = {
'plus': lambda p, q: ... | 29,058 | 42.962179 | 165 | py |
AutoCO | AutoCO-main/exp_public/adult/simulate/baseline.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
from collections import Counter
from torch.distributions.multivariate_normal import MultivariateNormal
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS =... | 37,292 | 45.909434 | 141 | py |
AutoCO | AutoCO-main/exp_public/adult/simulate/vartional_model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import utils
import ipdb
PRIMITIVES_BINARY = ['plus', 'multiply', 'max', 'min', 'concat']
PRIMITIVES_NAS = [0, 2, 4, 8, 16]
SPACE_NAS = pow(len(PRIMITIVES_NAS), 5)
OPS = {
'plus': lambda p, q: ... | 55,609 | 50.730233 | 176 | py |
malfoy | malfoy-master/v2x/config/config.py | # -*- coding: utf-8 -*-
import os
import sys
import torch
torch.set_num_threads(1)
ROOT_DIR = os.path.normpath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../..'))
LOGS_DIR = os.path.join(ROOT_DIR, 'logs')
RESOURCES_DIR = os.path.join(ROOT_DIR, 'resources')
MODEL... | 13,031 | 50.920319 | 80 | py |
malfoy | malfoy-master/v2x/solutions/price_model_curious.py | # -*- coding: utf-8 -*-
import os
import numpy as np
import torch
from torch import tensor,nn
from torch.autograd import Variable
torch.autograd.set_detect_anomaly(True)
from torch.nn import functional as F
from torch.distributions.multivariate_normal import MultivariateNormal
from ..config.config import (PRICE_MODEL_P... | 58,987 | 42.373529 | 106 | py |
malfoy | malfoy-master/v2x/solutions/attention.py | # -*- coding: utf-8 -*-
import torch
from torch import nn,optim,tensor
from torch.nn import functional as F
from ..config.config import (PRICE_MODEL_PARAMS as pmp,DEVICE)
class EncoderRNN(nn.Module):
max_length = pmp.batch_size
def __init__(self, input_size, hidden_size=128):
super().__init__()
... | 5,674 | 39.827338 | 83 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.