repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
deephyper | deephyper-master/deephyper/nas/run/_run_horovod.py | """The :func:`deephyper.nas.run.horovod.run` function is used to evaluate a deep neural network by enabling data-parallelism with Horovod to the :func:`deephyper.nas.run.alpha.run` function. This function will automatically apply the linear scaling rule to the learning rate and batch size given the current number of ra... | 6,420 | 37.680723 | 407 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_distributed_base_trainer.py | """The :func:`deephyper.nas.run.tf_distributed.run` function is used to deploy a data-distributed training (on a single node) with ``tensorflow.distribute.MirroredStrategy``. It follows the same training pipeline as :func:`deephyper.nas.run.alpha.run`. Two hyperparameters arguments can be used to activate or deactivate... | 6,405 | 37.359281 | 410 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_debug.py | """The :func:`deephyper.nas.run.quick_random.run` function is a function used to check the good behaviour of an hyperparameter or neural architecture search algorithm. It will simply return an objective of the sum of hyperparameters combined with a random sample to check the good reproducibility of DeepHyper experiment... | 645 | 52.833333 | 376 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_debug_arch.py | """The :func:`deephyper.nas.run.quick.run` function is a function used to check the good behaviour of a neural architecture search algorithm. It will simply return the sum of the scalar values encoding a neural architecture in the ``config["arch_seq"]`` key.
"""
def run_debug_arch(config: dict) -> float:
return s... | 343 | 48.142857 | 258 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_debug_hp_arch.py | """The :func:`deephyper.nas.run.quick2.run` function is a function used to check the good behaviour of a mixed hyperparameter and neural architecture search algorithm. It will simply return an objective combining the sum of the scalar values encoding a neural architecture in the ``config["arch_seq"]`` key then divide t... | 770 | 54.071429 | 419 | py |
deephyper | deephyper-master/deephyper/nas/run/_util.py | """Utilitaries functions to ease the processing of a configuration (``dict``) generated by a neural architecture search algorithm.
"""
import logging
import copy
import json
import os
import pathlib
import uuid
from datetime import datetime
import numpy as np
import tensorflow as tf
from deephyper.core.exceptions.prob... | 12,348 | 33.785915 | 410 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_debug_slow.py | """The :func:`deephyper.nas.run.quick_random.run` function is a function used to check the good behaviour of an hyperparameter or neural architecture search algorithm. It will simply return an objective of the sum of hyperparameters combined with a random sample to check the good reproducibility of DeepHyper experiment... | 680 | 47.642857 | 376 | py |
deephyper | deephyper-master/deephyper/nas/run/_run_base_trainer.py | """The :func:`deephyper.nas.run.alpha.run` function is used to evaluate a deep neural network by loading the data, building the model, training the model and returning a scalar value corresponding to the objective defined in the used :class:`deephyper.problem.NaProblem`.
"""
import os
import traceback
import logging
i... | 4,751 | 34.2 | 271 | py |
deephyper | deephyper-master/deephyper/nas/run/__init__.py | """The :mod:`deephyper.nas.run` sub-package provides a set of functions which can evaluates configurations generated by search algorithms of DeepHyper.
"""
from ._run_base_trainer import run_base_trainer
from ._run_distributed_base_trainer import run_distributed_base_trainer
from ._run_debug_arch import run_debug_arch
... | 733 | 28.36 | 151 | py |
deephyper | deephyper-master/deephyper/nas/run/_test_horovod.py | """The :func:`deephyper.nas.run.test_horovod.run` function is used to check the good behaviour of a call made by within an Horovod context.
"""
import os
import time
import random
import horovod.tensorflow as hvd
def run(config: dict) -> float:
"""Using the stateless `run` method, a function can take in any args... | 722 | 23.1 | 139 | py |
deephyper | deephyper-master/deephyper/nas/preprocessing/_base.py | """The preprocessing module provides a few functions which returns a preprocessing pipeline following the Scikit-Learn API.
"""
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, MinMaxScaler
def stdscaler() -> Pipeline:
"""Standard normalization where the mean is of each row ... | 1,247 | 30.2 | 123 | py |
deephyper | deephyper-master/deephyper/nas/preprocessing/__init__.py | from ._base import minmaxstdscaler, stdscaler
__all__ = ["minmaxstdscaler", "stdscaler"]
| 90 | 21.75 | 45 | py |
deephyper | deephyper-master/deephyper/nas/operation/_merge.py | import deephyper as dh
import tensorflow as tf
from ._base import Operation
class Concatenate(Operation):
"""Concatenate operation.
Args:
graph:
node (Node):
stacked_nodes (list(Node)): nodes to concatenate
axis (int): axis to concatenate
"""
def __init__(self, searc... | 8,004 | 35.221719 | 164 | py |
deephyper | deephyper-master/deephyper/nas/operation/_base.py | import tensorflow as tf
class Operation:
"""Interface of an operation.
>>> import tensorflow as tf
>>> from deephyper.nas.space.op import Operation
>>> Operation(layer=tf.keras.layers.Dense(10))
Dense
Args:
layer (Layer): a ``tensorflow.keras.layers.Layer``.
"""
def __init__... | 4,141 | 25.382166 | 130 | py |
deephyper | deephyper-master/deephyper/nas/operation/__init__.py | """Operations for neural architecture search space definition."""
from ._base import Connect, Identity, Operation, Tensor, Zero, operation
from ._merge import AddByPadding, AddByProjecting, Concatenate
__all__ = [
"AddByPadding",
"AddByProjecting",
"Concatenate",
"Connect",
"Identity",
"Operati... | 370 | 22.1875 | 72 | py |
deephyper | deephyper-master/deephyper/problem/_hyperparameter.py | import copy
import json
import ConfigSpace as cs
import ConfigSpace.hyperparameters as csh
import numpy as np
from ConfigSpace.read_and_write import json as cs_json
import deephyper.core.exceptions as dh_exceptions
import deephyper.skopt
def convert_to_skopt_dim(cs_hp, surrogate_model=None):
if surrogate_model... | 12,175 | 37.653968 | 162 | py |
deephyper | deephyper-master/deephyper/problem/_neuralarchitecture.py | from collections import OrderedDict
from copy import deepcopy
from inspect import signature
import ConfigSpace.hyperparameters as csh
import tensorflow as tf
from deephyper.core.exceptions.problem import (
NaProblemError,
ProblemLoadDataIsNotCallable,
ProblemPreprocessingIsNotCallable,
SearchSpaceBuild... | 19,985 | 36.287313 | 1,442 | py |
deephyper | deephyper-master/deephyper/problem/__init__.py | """This module provides tools to define hyperparameter and neural architecture search problems. Some features of this module are based on the `ConfigSpace <https://automl.github.io/ConfigSpace/master/>`_ project.
"""
from ConfigSpace import * # noqa: F401, F403
from ._hyperparameter import HpProblem
__all__ = ["HpPr... | 636 | 26.695652 | 212 | py |
deephyper | deephyper-master/deephyper/keras/utils.py | 0 | 0 | 0 | py | |
deephyper | deephyper-master/deephyper/keras/__init__.py | 0 | 0 | 0 | py | |
deephyper | deephyper-master/deephyper/keras/callbacks/learning_rate_warmup.py | """
Adapted from Horovod implementation: https://github.com/horovod/horovod/blob/master/horovod/keras/callbacks.py
"""
import tensorflow as tf
class LearningRateScheduleCallback(tf.keras.callbacks.Callback):
def __init__(
self,
initial_lr,
multiplier,
start_epoch=0,
end_epo... | 5,317 | 35.930556 | 110 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/utils.py | from typing import Type
import deephyper
import deephyper.core.exceptions
import tensorflow as tf
def import_callback(cb_name: str) -> Type[tf.keras.callbacks.Callback]:
"""Import a callback class from its name.
Args:
cb_name (str): class name of the callback to import fron ``tensorflow.keras.callba... | 1,000 | 34.75 | 129 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/stop_if_unfeasible.py | import time
import tensorflow as tf
class StopIfUnfeasible(tf.keras.callbacks.Callback):
def __init__(self, time_limit=600, patience=20):
super().__init__()
self.time_limit = time_limit
self.timing = list()
self.stopped = False # boolean set to True if the model training has been... | 2,047 | 36.236364 | 118 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/stop_on_timeout.py | from datetime import datetime
from tensorflow.keras.callbacks import Callback
class TerminateOnTimeOut(Callback):
def __init__(self, timeout_in_min=10):
super(TerminateOnTimeOut, self).__init__()
self.run_timestamp = None
self.timeout_in_sec = timeout_in_min * 60
# self.validation... | 1,364 | 40.363636 | 102 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/csv_extended_logger.py | import collections
import io
import time
import csv
import numpy as np
import six
import tensorflow as tf
from tensorflow.python.lib.io import file_io
from tensorflow.python.util.compat import collections_abc
class CSVExtendedLogger(tf.keras.callbacks.Callback):
"""Callback that streams epoch results to a csv fi... | 3,539 | 30.891892 | 85 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/__init__.py | from deephyper.keras.callbacks.utils import import_callback
from deephyper.keras.callbacks.stop_if_unfeasible import StopIfUnfeasible
from deephyper.keras.callbacks.csv_extended_logger import CSVExtendedLogger
from deephyper.keras.callbacks.time_stopping import TimeStopping
from deephyper.keras.callbacks.learning_rate_... | 581 | 31.333333 | 75 | py |
deephyper | deephyper-master/deephyper/keras/callbacks/time_stopping.py | """Callback that stops training when a specified amount of time has passed.
source: https://github.com/tensorflow/addons/blob/master/tensorflow_addons/callbacks/time_stopping.py
"""
import datetime
import time
import tensorflow as tf
class TimeStopping(tf.keras.callbacks.Callback):
"""Stop training when a speci... | 1,499 | 30.25 | 101 | py |
deephyper | deephyper-master/deephyper/keras/layers/_mpnn.py | import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras import activations
from tensorflow.keras.layers import Dense
class SparseMPNN(tf.keras.layers.Layer):
"""Message passing cell.
Args:
state_dim (int): number of output channels.
T (int): number of message passin... | 36,142 | 35.471241 | 183 | py |
deephyper | deephyper-master/deephyper/keras/layers/__init__.py | from deephyper.keras.layers._mpnn import (
AttentionConst,
AttentionCOS,
AttentionGAT,
AttentionGCN,
AttentionGenLinear,
AttentionLinear,
AttentionSymGAT,
GlobalAttentionPool,
GlobalAttentionSumPool,
GlobalAvgPool,
GlobalMaxPool,
GlobalSumPool,
MessagePasserNNM,
M... | 960 | 20.840909 | 82 | py |
deephyper | deephyper-master/deephyper/keras/layers/_padding.py | import tensorflow as tf
class Padding(tf.keras.layers.Layer):
"""Multi-dimensions padding layer.
This operation pads a tensor according to the paddings you specify. paddings is an
integer tensor with shape [n-1, 2], where n is the rank of tensor. For each dimension
D of input, paddings[D, 0] indicat... | 1,788 | 32.12963 | 89 | py |
deephyper | deephyper-master/deephyper/search/_search.py | import abc
import copy
import functools
import os
import pathlib
import numpy as np
import pandas as pd
import yaml
from deephyper.core.exceptions import SearchTerminationError
from deephyper.core.utils._introspection import get_init_params_as_json
from deephyper.core.utils._timeout import terminate_on_timeout
from de... | 5,785 | 35.620253 | 174 | py |
deephyper | deephyper-master/deephyper/search/__init__.py | """
The ``search`` module brings a modular way to implement new search algorithms and two sub modules. One is for hyperparameter search ``deephyper.search.hps`` and one is for neural architecture search ``deephyper.search.nas``.
The ``Search`` class is abstract and has different subclasses such as: ``deephyper.search.h... | 436 | 47.555556 | 224 | py |
deephyper | deephyper-master/deephyper/search/hps/_mpi_dbo.py | import logging
import mpi4py
import numpy as np
import scipy.stats
# !To avoid initializing MPI when module is imported (MPI is optional)
mpi4py.rc.initialize = False
mpi4py.rc.finalize = True
from mpi4py import MPI # noqa: E402
from deephyper.evaluator import Evaluator # noqa: E402
from deephyper.evaluator.callba... | 14,475 | 52.025641 | 938 | py |
deephyper | deephyper-master/deephyper/search/hps/__init__.py | """Hyperparameter search algorithms.
"""
from deephyper.search.hps._cbo import CBO, AMBS
__all__ = ["CBO", "AMBS"]
try:
from deephyper.search.hps._mpi_dbo import MPIDistributedBO # noqa: F401
__all__.append("MPIDistributedBO")
except ImportError:
pass
| 268 | 19.692308 | 76 | py |
deephyper | deephyper-master/deephyper/search/hps/_cbo.py | import functools
import logging
import time
import warnings
import ConfigSpace as CS
import ConfigSpace.hyperparameters as csh
import numpy as np
import pandas as pd
import deephyper.core.exceptions
import deephyper.skopt
from deephyper.problem._hyperparameter import convert_to_skopt_space
from deephyper.search._sear... | 43,289 | 45.349036 | 938 | py |
deephyper | deephyper-master/deephyper/search/nas/_agebo.py | import collections
import deephyper.skopt
import numpy as np
from deephyper.search.nas._regevo import RegularizedEvolution
# Adapt minimization -> maximization with DeepHyper
MAP_liar_strategy = {
"cl_min": "cl_max",
"cl_max": "cl_min",
}
MAP_acq_func = {
"UCB": "LCB",
}
class AgEBO(RegularizedEvolution... | 14,057 | 41.343373 | 274 | py |
deephyper | deephyper-master/deephyper/search/nas/_ambsmixed.py | import logging
import ConfigSpace as CS
import numpy as np
import deephyper.skopt
from deephyper.problem import HpProblem
from deephyper.search.nas._base import NeuralArchitectureSearch
# Adapt minimization -> maximization with DeepHyper
MAP_liar_strategy = {
"cl_min": "cl_max",
"cl_max": "cl_min",
}
MAP_acq_... | 9,952 | 39.295547 | 284 | py |
deephyper | deephyper-master/deephyper/search/nas/_regevo.py | import collections
from deephyper.search.nas._base import NeuralArchitectureSearch
class RegularizedEvolution(NeuralArchitectureSearch):
"""`Regularized evolution <https://arxiv.org/abs/1802.01548>`_ neural architecture search. This search is only compatible with a ``NaProblem`` that has fixed hyperparameters.
... | 5,556 | 37.86014 | 224 | py |
deephyper | deephyper-master/deephyper/search/nas/_base.py | from deephyper.search._search import Search
class NeuralArchitectureSearch(Search):
def __init__(
self, problem, evaluator, random_state=None, log_dir=".", verbose=0, **kwargs
):
super().__init__(problem, evaluator, random_state, log_dir, verbose)
self._problem._space["log_dir"] = sel... | 771 | 34.090909 | 85 | py |
deephyper | deephyper-master/deephyper/search/nas/_random.py | from deephyper.search.nas._base import NeuralArchitectureSearch
class Random(NeuralArchitectureSearch):
"""Random neural architecture search. This search algorithm is compatible with a ``NaProblem`` defining fixed or variable hyperparameters.
Args:
problem (NaProblem): Neural architecture search prob... | 3,028 | 34.635294 | 142 | py |
deephyper | deephyper-master/deephyper/search/nas/__init__.py | """Neural architecture search algorithms.
"""
from deephyper.search.nas._base import NeuralArchitectureSearch
from deephyper.search.nas._regevo import RegularizedEvolution
from deephyper.search.nas._agebo import AgEBO
from deephyper.search.nas._ambsmixed import AMBSMixed
from deephyper.search.nas._random import Random
... | 544 | 29.277778 | 71 | py |
deephyper | deephyper-master/deephyper/search/nas/_regevomixed.py | import ConfigSpace as CS
from deephyper.problem import HpProblem
from deephyper.search.nas._regevo import RegularizedEvolution
class RegularizedEvolutionMixed(RegularizedEvolution):
"""Extention of the `Regularized evolution <https://arxiv.org/abs/1802.01548>`_ neural architecture search to the case of joint hype... | 6,069 | 35.347305 | 178 | py |
deephyper | deephyper-master/deephyper/sklearn/__init__.py | """Sub-package providing tools for automl.
"""
| 47 | 15 | 42 | py |
deephyper | deephyper-master/deephyper/sklearn/classifier/_autosklearn1.py | """
This module provides ``problem_autosklearn1`` and ``run_autosklearn`` for classification tasks.
"""
import warnings
from inspect import signature
import ConfigSpace as cs
from deephyper.problem import HpProblem
from sklearn.ensemble import AdaBoostClassifier, RandomForestClassifier
from sklearn.linear_model import... | 6,739 | 30.495327 | 144 | py |
deephyper | deephyper-master/deephyper/sklearn/classifier/__init__.py | from deephyper.sklearn.classifier._autosklearn1 import (
problem_autosklearn1,
run_autosklearn1,
)
__all__ = ["problem_autosklearn1", "run_autosklearn1"]
__doc__ = """
AutoML searches are executed with the ``deephyper.search.hps.CBO`` algorithm only. We provide ready to go problems, and run functions for you ... | 342 | 30.181818 | 159 | py |
deephyper | deephyper-master/deephyper/sklearn/regressor/_autosklearn1.py | """
This module provides ``problem_autosklearn1`` and ``run_autosklearn`` for regression tasks.
"""
import warnings
from inspect import signature
import ConfigSpace as cs
from deephyper.problem import HpProblem
from sklearn.ensemble import AdaBoostRegressor, RandomForestRegressor
from sklearn.linear_model import Linea... | 6,472 | 30.8867 | 141 | py |
deephyper | deephyper-master/deephyper/sklearn/regressor/__init__.py | from deephyper.sklearn.regressor._autosklearn1 import (
problem_autosklearn1,
run_autosklearn1,
)
__all__ = ["problem_autosklearn1", "run_autosklearn1"]
__doc__ = """
AutoML searches are executed with the ``deephyper.search.hps.CBO`` algorithm only. We provide ready to go problems, and run functions for you t... | 341 | 30.090909 | 159 | py |
deephyper | deephyper-master/deephyper/ensemble/_bagging_ensemble.py | import os
import traceback
import tensorflow as tf
import numpy as np
import ray
from deephyper.nas.metrics import selectMetric
from deephyper.ensemble import BaseEnsemble
from deephyper.nas.run._util import set_memory_growth_for_visible_gpus
def mse(y_true, y_pred):
return tf.square(y_true - y_pred)
@ray.rem... | 11,171 | 32.752266 | 178 | py |
deephyper | deephyper-master/deephyper/ensemble/_base_ensemble.py | import abc
import json
import os
import ray
class BaseEnsemble(abc.ABC):
"""Base class for ensembles, every new ensemble algorithms needs to extend this class.
Args:
model_dir (str): Path to directory containing saved Keras models in .h5 format.
loss (callable): a callable taking (y_true, y_... | 3,990 | 31.713115 | 178 | py |
deephyper | deephyper-master/deephyper/ensemble/__init__.py | """The ``ensemble`` module provides a way to build ensembles of checkpointed deep neural networks from ``tensorflow.keras``, with ``.h5`` format, to regularize and boost predictive performance as well as estimate better uncertainties.
"""
from deephyper.ensemble._base_ensemble import BaseEnsemble
from deephyper.ensembl... | 702 | 34.15 | 234 | py |
deephyper | deephyper-master/deephyper/ensemble/_uq_bagging_ensemble.py | import os
import traceback
import numpy as np
import ray
import tensorflow as tf
import tensorflow_probability as tfp
from deephyper.ensemble import BaseEnsemble
from deephyper.nas.metrics import selectMetric
from deephyper.nas.run._util import set_memory_growth_for_visible_gpus
from deephyper.core.exceptions import D... | 19,600 | 34.703097 | 449 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/main.py | import torch
import utility
import data
import model
import loss
from option import args
from trainer import Trainer
torch.manual_seed(args.seed)
checkpoint = utility.checkpoint(args)
def main():
global model
if args.data_test == ['video']:
from videotester import VideoTester
model = model.Mo... | 1,026 | 27.527778 | 97 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/utility.py | import os
import math
import time
import datetime
from multiprocessing import Process
from multiprocessing import Queue
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import imageio
import torch
import torch.optim as optim
import torch.optim.lr_scheduler as lrs
class time... | 7,458 | 30.340336 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/dataloader.py | import threading
import random
import torch
import torch.multiprocessing as multiprocessing
from torch.utils.data import DataLoader
from torch.utils.data import SequentialSampler
from torch.utils.data import RandomSampler
from torch.utils.data import BatchSampler
from torch.utils.data import _utils
from torch.utils.da... | 5,259 | 32.081761 | 104 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/template.py | def set_template(args):
# Set the templates here
if args.template.find('jpeg') >= 0:
args.data_train = 'DIV2K_jpeg'
args.data_test = 'DIV2K_jpeg'
args.epochs = 200
args.decay = '100'
if args.template.find('EDSR_paper') >= 0:
args.model = 'EDSR'
args.n_resbloc... | 1,312 | 23.314815 | 45 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/option.py | import argparse
import template
parser = argparse.ArgumentParser(description='EDSR and MDSR')
parser.add_argument('--debug', action='store_true',
help='Enables debug mode')
parser.add_argument('--template', default='.',
help='You can set various templates in option.py')
# Hard... | 7,464 | 45.36646 | 86 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/__init__.py | 0 | 0 | 0 | py | |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/videotester.py | import os
import math
import utility
from data import common
import torch
import cv2
from tqdm import tqdm
class VideoTester():
def __init__(self, args, my_model, ckp):
self.args = args
self.scale = args.scale
self.ckp = ckp
self.model = my_model
self.filename, _ = os.p... | 2,280 | 30.246575 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/trainer.py | import os
import math
from decimal import Decimal
import utility
import torch
import torch.nn.utils as utils
from tqdm import tqdm
class Trainer():
def __init__(self, args, loader, my_model, my_loss, ckp):
self.args = args
self.scale = args.scale
self.ckp = ckp
self.loader_train ... | 4,820 | 31.795918 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/loss/adversarial.py | import utility
from types import SimpleNamespace
from model import common
from loss import discriminator
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class Adversarial(nn.Module):
def __init__(self, args, gan_type):
super(Adversarial, self).__init__()
... | 4,393 | 37.884956 | 84 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/loss/discriminator.py | from model import common
import torch.nn as nn
class Discriminator(nn.Module):
'''
output is not normalized
'''
def __init__(self, args):
super(Discriminator, self).__init__()
in_channels = args.n_colors
out_channels = 64
depth = 7
def _block(_in_channels,... | 1,595 | 27.5 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/loss/vgg.py | from model import common
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
class VGG(nn.Module):
def __init__(self, conv_index, rgb_range=1):
super(VGG, self).__init__()
vgg_features = models.vgg19(pretrained=True).features
modules = [m ... | 1,106 | 28.918919 | 75 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/loss/__init__.py | import os
from importlib import import_module
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class Loss(nn.modules.loss._Loss):
def __init__(self, args, ckp):
super(Loss, self).__init__()
... | 4,659 | 31.361111 | 80 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/utils/tools.py | import os
import torch
import numpy as np
from PIL import Image
import torch.nn.functional as F
def normalize(x):
return x.mul_(2).add_(-1)
def same_padding(images, ksizes, strides, rates):
assert len(images.size()) == 4
batch_size, channel, rows, cols = images.size()
out_rows = (rows + strides[0] - ... | 2,777 | 32.878049 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/utils/__init__.py | 0 | 0 | 0 | py | |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/div2kjpeg.py | import os
from data import srdata
from data import div2k
class DIV2KJPEG(div2k.DIV2K):
def __init__(self, args, name='', train=True, benchmark=False):
self.q_factor = int(name.replace('DIV2K-Q', ''))
super(DIV2KJPEG, self).__init__(
args, name=name, train=train, benchmark=benchmark
... | 675 | 31.190476 | 67 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/sr291.py | from data import srdata
class SR291(srdata.SRData):
def __init__(self, args, name='SR291', train=True, benchmark=False):
super(SR291, self).__init__(args, name=name)
| 180 | 24.857143 | 72 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/benchmark.py | import os
from data import common
from data import srdata
import numpy as np
import torch
import torch.utils.data as data
class Benchmark(srdata.SRData):
def __init__(self, args, name='', train=True, benchmark=True):
super(Benchmark, self).__init__(
args, name=name, train=train, benchmark=Tr... | 703 | 26.076923 | 67 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/video.py | import os
from data import common
import cv2
import numpy as np
import imageio
import torch
import torch.utils.data as data
class Video(data.Dataset):
def __init__(self, args, name='Video', train=False, benchmark=False):
self.args = args
self.name = name
self.scale = args.scale
s... | 1,207 | 25.844444 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/srdata.py | import os
import glob
import random
import pickle
from data import common
import numpy as np
import imageio
import torch
import torch.utils.data as data
class SRData(data.Dataset):
def __init__(self, args, name='', train=True, benchmark=False):
self.args = args
self.name = name
self.train... | 5,337 | 32.78481 | 73 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/demo.py | import os
from data import common
import numpy as np
import imageio
import torch
import torch.utils.data as data
class Demo(data.Dataset):
def __init__(self, args, name='Demo', train=False, benchmark=False):
self.args = args
self.name = name
self.scale = args.scale
self.idx_scale... | 1,075 | 25.9 | 76 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/common.py | import random
import numpy as np
import skimage.color as sc
import torch
def get_patch(*args, patch_size=96, scale=1, multi=False, input_large=False):
ih, iw = args[0].shape[:2]
if not input_large:
p = 1 if multi else 1
tp = p * patch_size
ip = tp // 1
else:
tp = patch_si... | 1,770 | 23.260274 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/__init__.py | from importlib import import_module
#from dataloader import MSDataLoader
from torch.utils.data import dataloader
from torch.utils.data import ConcatDataset
# This is a simple wrapper function for ConcatDataset
class MyConcatDataset(ConcatDataset):
def __init__(self, datasets):
super(MyConcatDataset, self).... | 1,974 | 36.264151 | 83 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/data/div2k.py | import os
from data import srdata
class DIV2K(srdata.SRData):
def __init__(self, args, name='DIV2K', train=True, benchmark=False):
data_range = [r.split('-') for r in args.data_range.split('/')]
if train:
data_range = data_range[0]
else:
if args.test_only and len(dat... | 1,134 | 33.393939 | 72 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/rcan.py | ## ECCV-2018-Image Super-Resolution Using Very Deep Residual Channel Attention Networks
## https://arxiv.org/abs/1807.02758
from model import common
import torch.nn as nn
def make_model(args, parent=False):
return RCAN(args)
## Channel Attention (CA) Layer
class CALayer(nn.Module):
def __init__(self, channel... | 5,178 | 34.717241 | 116 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/ddbpn.py | # Deep Back-Projection Networks For Super-Resolution
# https://arxiv.org/abs/1803.02735
from model import common
import torch
import torch.nn as nn
def make_model(args, parent=False):
return DDBPN(args)
def projection_conv(in_channels, out_channels, scale, up=True):
kernel_size, stride, padding = {
... | 3,629 | 26.5 | 78 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/rdn.py | # Residual Dense Network for Image Super-Resolution
# https://arxiv.org/abs/1802.08797
from model import common
import torch
import torch.nn as nn
def make_model(args, parent=False):
return RDN(args)
class RDB_Conv(nn.Module):
def __init__(self, inChannels, growRate, kSize=3):
super(RDB_Conv, self)... | 3,202 | 29.216981 | 90 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/mdsr.py | from model import common
import torch.nn as nn
def make_model(args, parent=False):
return MDSR(args)
class MDSR(nn.Module):
def __init__(self, args, conv=common.default_conv):
super(MDSR, self).__init__()
n_resblocks = args.n_resblocks
n_feats = args.n_feats
kernel_size = 3
... | 1,837 | 25.637681 | 78 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/common.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
def default_conv(in_channels, out_channels, kernel_size,stride=1, bias=True):
return nn.Conv2d(
in_channels, out_channels, kernel_size,
padding=(kernel_size//2),stride=stride, bias=bias)
class MeanShift(nn.Conv2d):
... | 2,799 | 30.460674 | 80 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/__init__.py | import os
from importlib import import_module
import torch
import torch.nn as nn
from torch.autograd import Variable
class Model(nn.Module):
def __init__(self, args, ckp):
super(Model, self).__init__()
print('Making model...')
self.scale = args.scale
self.idx_scale = 0
sel... | 6,200 | 31.465969 | 90 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/panet.py | from model import common
from model import attention
import torch.nn as nn
def make_model(args, parent=False):
return PANET(args)
class PANET(nn.Module):
def __init__(self, args, conv=common.default_conv):
super(PANET, self).__init__()
n_resblocks = args.n_resblocks
n_feats = args.n_f... | 2,779 | 32.493976 | 104 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms
from torchvision import utils as vutils
from model import common
from utils.tools import extract_image_patches,\
reduce_mean, reduce_sum, same_padding
class PyramidAttention(nn.Module):
def __init__(self, leve... | 4,427 | 46.106383 | 147 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/vdsr.py | from model import common
import torch.nn as nn
import torch.nn.init as init
url = {
'r20f64': ''
}
def make_model(args, parent=False):
return VDSR(args)
class VDSR(nn.Module):
def __init__(self, args, conv=common.default_conv):
super(VDSR, self).__init__()
n_resblocks = args.n_resblocks... | 1,275 | 26.148936 | 73 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/utils/tools.py | import os
import torch
import numpy as np
from PIL import Image
import torch.nn.functional as F
def normalize(x):
return x.mul_(2).add_(-1)
def same_padding(images, ksizes, strides, rates):
assert len(images.size()) == 4
batch_size, channel, rows, cols = images.size()
out_rows = (rows + strides[0] - ... | 2,777 | 32.878049 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/Demosaic/code/model/utils/__init__.py | 0 | 0 | 0 | py | |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/main.py | import torch
import utility
import data
import model
import loss
from option import args
from trainer import Trainer
torch.manual_seed(args.seed)
checkpoint = utility.checkpoint(args)
def main():
global model
if args.data_test == ['video']:
from videotester import VideoTester
model = model.Mo... | 1,028 | 27.583333 | 98 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/utility.py | import os
import math
import time
import datetime
from multiprocessing import Process
from multiprocessing import Queue
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import imageio
import torch
import torch.optim as optim
import torch.optim.lr_scheduler as lrs
class time... | 7,480 | 30.432773 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/dataloader.py | import threading
import random
import torch
import torch.multiprocessing as multiprocessing
from torch.utils.data import DataLoader
from torch.utils.data import SequentialSampler
from torch.utils.data import RandomSampler
from torch.utils.data import BatchSampler
from torch.utils.data import _utils
from torch.utils.da... | 5,259 | 32.081761 | 104 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/template.py | def set_template(args):
# Set the templates here
if args.template.find('jpeg') >= 0:
args.data_train = 'DIV2K_jpeg'
args.data_test = 'DIV2K_jpeg'
args.epochs = 200
args.decay = '100'
if args.template.find('EDSR_paper') >= 0:
args.model = 'EDSR'
args.n_resbloc... | 1,312 | 23.314815 | 45 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/option.py | import argparse
import template
parser = argparse.ArgumentParser(description='EDSR and MDSR')
parser.add_argument('--debug', action='store_true',
help='Enables debug mode')
parser.add_argument('--template', default='.',
help='You can set various templates in option.py')
# Hard... | 7,645 | 45.621951 | 83 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/__init__.py | 0 | 0 | 0 | py | |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/videotester.py | import os
import math
import utility
from data import common
import torch
import cv2
from tqdm import tqdm
class VideoTester():
def __init__(self, args, my_model, ckp):
self.args = args
self.scale = args.scale
self.ckp = ckp
self.model = my_model
self.filename, _ = os.p... | 2,280 | 30.246575 | 77 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/trainer.py | import os
import math
from decimal import Decimal
import utility
import torch
import torch.nn.utils as utils
from tqdm import tqdm
class Trainer():
def __init__(self, args, loader, my_model, my_loss, ckp):
self.args = args
self.scale = args.scale
self.ckp = ckp
self.loader_train ... | 4,820 | 31.795918 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/loss/adversarial.py | import utility
from types import SimpleNamespace
from model import common
from loss import discriminator
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class Adversarial(nn.Module):
def __init__(self, args, gan_type):
super(Adversarial, self).__init__()
... | 4,393 | 37.884956 | 84 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/loss/discriminator.py | from model import common
import torch.nn as nn
class Discriminator(nn.Module):
'''
output is not normalized
'''
def __init__(self, args):
super(Discriminator, self).__init__()
in_channels = args.n_colors
out_channels = 64
depth = 7
def _block(_in_channels,... | 1,595 | 27.5 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/loss/vgg.py | from model import common
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
class VGG(nn.Module):
def __init__(self, conv_index, rgb_range=1):
super(VGG, self).__init__()
vgg_features = models.vgg19(pretrained=True).features
modules = [m ... | 1,106 | 28.918919 | 75 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/loss/__init__.py | import os
from importlib import import_module
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class Loss(nn.modules.loss._Loss):
def __init__(self, args, ckp):
super(Loss, self).__init__()
... | 4,628 | 31.598592 | 83 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/loss/__loss__.py | 0 | 0 | 0 | py | |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/utils/tools.py | import os
import torch
import numpy as np
from PIL import Image
import torch.nn.functional as F
def normalize(x):
return x.mul_(2).add_(-1)
def same_padding(images, ksizes, strides, rates):
assert len(images.size()) == 4
batch_size, channel, rows, cols = images.size()
out_rows = (rows + strides[0] - ... | 2,777 | 32.878049 | 79 | py |
Pyramid-Attention-Networks | Pyramid-Attention-Networks-master/SR/code/utils/__init__.py | 0 | 0 | 0 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.