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
DDoS
DDoS-master/models/srVAE/srVAE.py
from functools import partial import numpy as np import torch import torch.nn as nn from torchvision import transforms from .backbone.densenet16x32 import * from .priors.realnvp import RealNVP # --------- Utility functions --------- def get_shape(z_dim): """ Given the dimentionality of the latent space, ...
6,789
29.3125
122
py
DDoS
DDoS-master/models/srVAE/backbone/densenet16x32.py
import torch import torch.nn as nn import torch.nn.functional as F from src.modules.nn_layers import * from src.modules.distributions import n_embenddings from src.utils.args import args class q_u(nn.Module): """ Encoder q(u|y) """ def __init__(self, output_shape, input_shape): super().__init__()...
4,289
23.94186
85
py
DDoS
DDoS-master/models/srVAE/priors/mog.py
import numpy as np import torch import torch.nn as nn from torch.autograd import Variable from .prior import Prior from src.modules.nn_layers import * from src.modules.distributions import * from src.utils import args # Modified vertion of: https://github.com/divymurli/VAEs class MixtureOfGaussians(Prior): de...
3,267
32.010101
94
py
DDoS
DDoS-master/models/srVAE/priors/prior.py
import torch import torch.nn as nn class Prior(nn.Module): def __init__(self): super().__init__() def sample(self, **kwargs): raise NotImplementedError def log_p(self, input, **kwargs): return self.forward(z) def forward(self, input, **kwargs): raise NotImplementedEr...
420
16.541667
39
py
DDoS
DDoS-master/models/srVAE/priors/standard_normal.py
import math import torch class StandardNormal: def __init__(self, z_shape): self.z_shape = z_shape def sample(self, n_samples=1, **kwargs): return torch.randn((n_samples, *self.z_shape)) def log_p(self, z, **kwargs): return self.forward(z) def forward(self, z, **kwargs): ...
681
21
67
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/distributions/mog.py
import numpy as np import torch import torch.nn as nn from torch.autograd import Variable from src.modules.nn_layers import * from src.modules.distributions import * from src.utils import args class MixtureOfGaussians(nn.Module): def __init__(self, z_shape, num_mixtures=10): super().__init__() s...
3,185
32.536842
94
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/distributions/standard_normal.py
import math import torch import torch.nn as nn class StandardNormal: """ Isotropic Standard Normal distribution. """ def __init__(self, z_shape): self.z_shape = z_shape def sample(self, n_samples=1, **kwargs): return torch.randn((n_samples, *self.z_shape)) def log_p(self, z,...
764
20.857143
67
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/util/array_util.py
import torch import torch.nn.functional as F def squeeze_2x2(x, reverse=False, alt_order=False): """For each spatial position, a sub-volume of shape `1x1x(N^2 * C)`, reshape into a sub-volume of shape `NxNxC`, where `N = block_size`. Adapted from: https://github.com/tensorflow/models/blob/master/...
4,369
40.226415
103
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/util/norm_util.py
import functools import torch import torch.nn as nn def get_norm_layer(norm_type='instance'): if norm_type == 'batch': return functools.partial(nn.BatchNorm2d, affine=True) elif norm_type == 'instance': return functools.partial(nn.InstanceNorm2d, affine=False) else: raise NotImplem...
4,052
37.971154
96
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/model/real_nvp.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from .coupling_layer import CouplingLayer, MaskType from ..util import squeeze_2x2 from ..distributions import StandardNormal # Modified vertion of: https://github.com/chrischute/real-nvp class RealNVP(nn.Module): """RealNVP Mo...
5,949
37.636364
120
py
DDoS
DDoS-master/models/srVAE/priors/realnvp/model/coupling_layer.py
import torch import torch.nn as nn from enum import IntEnum from ..util import checkerboard_mask from src.modules.nn_layers import * class MaskType(IntEnum): CHECKERBOARD = 0 CHANNEL_WISE = 1 class CouplingLayer(nn.Module): """Coupling layer in RealNVP. Args: in_channels (int): Number of...
4,031
32.04918
91
py
DDoS
DDoS-master/models/ShuffleUNet/icnr.py
import torch import torch.nn as nn def ICNR(tensor, upscale_factor=2, inizializer=nn.init.kaiming_normal_): new_shape = [int(tensor.shape[0] / (upscale_factor ** 2))] + list(tensor.shape[1:]) subkernel = torch.zeros(new_shape) subkernel = inizializer(subkernel) subkernel = subkernel.transpose(0, 1) ...
708
31.227273
87
py
DDoS
DDoS-master/models/ShuffleUNet/pixel_shuffle.py
import torch.nn as nn from . import icnr def _pixel_shuffle(input, upscale_factor): r"""Rearranges elements in a Tensor of shape :math:`(N, C, d_{1}, d_{2}, ..., d_{n})` to a tensor of shape :math:`(N, C/(r^n), d_{1}*r, d_{2}*r, ..., d_{n}*r)`. Where :math:`n` is the dimensionality of the data. See :...
2,276
35.142857
111
py
DDoS
DDoS-master/models/ShuffleUNet/net.py
import sys import torch import torch.nn as nn from . import pixel_shuffle, pixel_unshuffle # -------------------------------------------------------------------------------------------------------------------------------------------------## class _double_conv(nn.Module): """ Double Convolution Block """ ...
5,659
36.733333
151
py
DDoS
DDoS-master/models/ShuffleUNet/pixel_unshuffle.py
import torch.nn as nn from . import icnr class _double_conv_3d(nn.Module): """ Convolution Block """ def __init__(self, in_channels, out_channels, k_size, stride, bias=True): super(_double_conv_3d, self).__init__() self.conv = nn.Sequential( nn.Conv3d(in_channels=in_chann...
4,185
37.054545
111
py
DDoS
DDoS-master/visualisation/num4trilinear.py
from glob import glob import torch from tqdm import tqdm import os import nibabel as nib import numpy as np import pandas as pd import torch.nn.functional as F from utils.utilities import calc_metircs fully_root = "/mnt/MEMoRIAL/MEMoRIAL_SharedStorage_M1.2+4+7/Chompunuch/PhD/Data/3DDynTest/MickAbdomen3DDyn/DynProtoco...
1,754
38
158
py
DDoS
DDoS-master/utils/elastic_transform.py
#!/usr/bin/env python ''' Purpose : ''' from numbers import Number from typing import Optional, Tuple, Union import numpy as np import torch import torch as th import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter __author__ = "Kartik Prabhu, Mahantesh Pattadkal, and Soum...
9,147
40.022422
163
py
DDoS
DDoS-master/utils/datasets_dyn.py
# from __future__ import self.logger.debug_function, division import fnmatch import glob import os import sys from random import randint, random, seed import nibabel import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torchvision.tr...
24,444
54.938215
300
py
DDoS
DDoS-master/utils/data.py
import fnmatch import os import random from glob import glob import numpy as np import torch import torchio as tio from torchio.data.io import read_image from .motion import MotionCorrupter __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2022, Faculty of Computer Science, Otto von Guericke University Ma...
7,985
38.93
118
py
DDoS
DDoS-master/utils/interpnorm_vols.py
import os import random from glob import glob import nibabel as nib import numpy as np import torch import torch.nn.functional as F from tqdm import tqdm __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2022, Faculty of Computer Science, Otto von Guericke University Magdeburg, Germany" __credits__ = ["Sou...
1,778
35.306122
110
py
DDoS
DDoS-master/utils/utilities.py
import os from copy import deepcopy from statistics import median import random import nibabel as nib import numpy as np import torch import torch.nn.functional as F import torchcomplex.nn.functional as cF import torchio as tio import torchvision.utils as vutils from scipy import ndimage import wandb from pynufft impo...
13,876
38.991354
184
py
DDoS
DDoS-master/utils/datasets.py
# from __future__ import self.logger.debug_function, division import glob import os import sys from random import randint, random, seed import nibabel import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torchvision.transforms as tra...
19,535
53.266667
261
py
DDoS
DDoS-master/utils/motion.py
import math import multiprocessing.dummy as multiprocessing import random from collections import defaultdict from typing import List import numpy as np import SimpleITK as sitk import torch import torchio as tio from scipy.ndimage import affine_transform from torchio.transforms import Motion, RandomMotion from torchi...
8,325
44.497268
183
py
DDoS
DDoS-master/utils/padding.py
#parital source: https://github.com/c22n/unet-pytorch from typing import Tuple, Union import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function, Variable from torch.nn.modules.utils import _ntuple __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2022, Soumick ...
3,703
36.04
80
py
DDoS
DDoS-master/utils/pLoss/Resnet2D.py
#!/usr/bin/env python """ Original file Resnet2Dv2b14 of NCC1701 """ import torch import torch.nn as nn import torch.nn.functional as F #from utils.TorchAct.pelu import PELU_oneparam as PELU __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2018, Soumick Chatterjee & OvGU:ESF:MEMoRIAL" __credits__ = ["So...
3,150
31.484536
294
py
DDoS
DDoS-master/utils/pLoss/VesselSeg_UNet3d_DeepSup.py
# -*- coding: utf-8 -*- """ """ # from __future__ import print_function, division import torch import torch.nn as nn import torch.utils.data #from Utils.wta import KWinnersTakeAll __author__ = "Kartik Prabhu, Mahantesh Pattadkal, and Soumick Chatterjee" __copyright__ = "Copyright 2022, Faculty of Computer Science,...
13,151
29.09611
110
py
DDoS
DDoS-master/utils/pLoss/perceptual_loss.py
import math import torch import torch.nn as nn import torchvision # from utils.utils import * # from pytorch_msssim import SSIM from .Resnet2D import ResNet from .simpleunet import UNet from .VesselSeg_UNet3d_DeepSup import U_Net_DeepSup __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2022, Faculty of C...
8,538
42.345178
154
py
DDoS
DDoS-master/utils/pLoss/simpleunet.py
import torch import torch.nn.functional as F from torch import nn __author__ = "Soumick Chatterjee" __copyright__ = "Copyright 2022, Faculty of Computer Science, Otto von Guericke University Magdeburg, Germany" __credits__ = ["Soumick Chatterjee", "Chompunuch Sarasaen"] __license__ = "GPL" __version__ = "1.0.0" __main...
7,121
39.237288
160
py
HIBPool
HIBPool-main/GIB.py
#!/usr/bin/env python # coding: utf-8 # In[ ]: from __future__ import print_function import numpy as np import pprint as pp from copy import deepcopy import pickle from numbers import Number from collections import OrderedDict import itertools import torch import torch.nn as nn from torch.autograd import Variable fr...
208,307
46.428962
300
py
theedhum-nandrum
theedhum-nandrum-master/src/tn/multiclassrnnclassifier.py
""" @author sanjeethr, oligoglot Thanks to Susan Li for this step by step guide: https://towardsdatascience.com/multi-class-text-classification-with-lstm-1590bee1bd17 """ import pandas as pd import matplotlib.pyplot as plt import numpy as np import sys, os from keras.preprocessing.text import Tokenizer from keras.prep...
6,528
38.331325
172
py
deephyper
deephyper-master/setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Note: To use the 'upload' functionality of this file, you must: # $ pip install twine import os import platform import sys from shutil import rmtree from setuptools import Command, setup # path of the directory where this file is located here = os.path.abspath(os.pa...
5,761
25.552995
93
py
deephyper
deephyper-master/tests/deephyper/nas/test_node.py
import unittest import pytest @pytest.mark.fast @pytest.mark.nas class NodeTest(unittest.TestCase): def test_mirror_node(self): import tensorflow as tf from deephyper.nas.node import MirrorNode, VariableNode from deephyper.nas.operation import operation Dense = operation(tf.keras...
1,118
21.836735
63
py
deephyper
deephyper-master/tests/deephyper/nas/test_new_api.py
import pytest @pytest.mark.fast @pytest.mark.nas def test_basic_space(verbose=0): import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import VariableNode, ConstantNode from deephyper.nas.operation import operation, Identity Dense = operation(tf.keras.layers.Den...
1,177
24.608696
88
py
deephyper
deephyper-master/tests/deephyper/nas/test_trainer_keras_regressor.py
import unittest import pytest @pytest.mark.slow @pytest.mark.nas class TrainerKerasRegressorTest(unittest.TestCase): def test_trainer_regressor_train_valid_with_one_input(self): import sys from random import random import deephyper.core.utils import numpy as np from deeph...
4,879
33.125874
85
py
deephyper
deephyper-master/tests/deephyper/nas/test_keras_search_space.py
import unittest import pytest @pytest.mark.nas class TestKSearchSpace(unittest.TestCase): def test_create(self): import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import VariableNode from deephyper.nas.operation import operation Dense ...
2,481
28.2
66
py
deephyper
deephyper-master/tests/deephyper/keras/layers/padding_test.py
import pytest @pytest.mark.fast @pytest.mark.nas def test_padding_layer(): import tensorflow as tf import numpy as np from deephyper.keras.layers import Padding model = tf.keras.Sequential() model.add(Padding([[1, 1]])) data = np.random.random((3, 1)) shape_data = np.shape(data) asse...
450
20.47619
46
py
deephyper
deephyper-master/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
8,809
27.79085
107
py
deephyper
deephyper-master/deephyper/stopper/_lcmodel_stopper.py
import sys from functools import partial import jax import jax.numpy as jnp import numpy as np import numpyro import numpyro.distributions as dist from numpyro.infer import MCMC, NUTS from scipy.optimize import least_squares from sklearn.base import BaseEstimator, RegressorMixin from sklearn.utils import check_random_...
19,786
36.263653
401
py
deephyper
deephyper-master/deephyper/test/nas/linearRegHybrid/problem.py
from deephyper.nas.spacelib.tabular import OneLayerSpace from deephyper.problem import NaProblem from deephyper.test.nas.linearReg.load_data import load_data Problem = NaProblem() Problem.load_data(load_data) Problem.search_space(OneLayerSpace) Problem.hyperparameters( batch_size=Problem.add_hyperparameter((1, ...
817
24.5625
99
py
deephyper
deephyper-master/deephyper/test/nas/linearReg/problem.py
from deephyper.nas.spacelib.tabular import OneLayerSpace from deephyper.problem import NaProblem from deephyper.test.nas.linearReg.load_data import load_data Problem = NaProblem() Problem.load_data(load_data) Problem.search_space(OneLayerSpace) Problem.hyperparameters( batch_size=100, learning_rate=0.1, optimiz...
611
21.666667
99
py
deephyper
deephyper-master/deephyper/nas/_nx_search_space.py
import abc import traceback from collections.abc import Iterable import networkx as nx from deephyper.core.exceptions.nas.space import ( NodeAlreadyAdded, StructureHasACycle, WrongSequenceToSetOperations, ) from deephyper.nas.node import MimeNode, Node, VariableNode class NxSearchSpace(abc.ABC): """A...
7,301
30.747826
166
py
deephyper
deephyper-master/deephyper/nas/losses.py
"""This module provides different loss functions. A loss can be defined by a keyword (str) or a callable following the ``tensorflow.keras`` interface. If it is a keyword it has to be available in ``tensorflow.keras`` or in ``deephyper.losses``. The loss functions availble in ``deephyper.losses`` are: * Negative Log Lik...
1,605
34.688889
301
py
deephyper
deephyper-master/deephyper/nas/node.py
"""This module provides the available node types to build a ``KSearchSpace``. """ import tensorflow as tf import deephyper.core.exceptions from deephyper.nas.operation import Operation class Node: """Represents a node of a ``KSearchSpace``. Args: name (str): node name. """ # Number of 'Node...
8,363
29.086331
218
py
deephyper
deephyper-master/deephyper/nas/_keras_search_space.py
import copy import logging import warnings import networkx as nx import numpy as np import tensorflow as tf from deephyper.core.exceptions.nas.space import ( InputShapeOfWrongType, WrongSequenceToSetOperations, ) from deephyper.nas._nx_search_space import NxSearchSpace from deephyper.nas.node import ConstantNo...
7,837
34.789954
170
py
deephyper
deephyper-master/deephyper/nas/metrics.py
"""This module provides different metric functions. A metric can be defined by a keyword (str) or a callable. If it is a keyword it has to be available in ``tensorflow.keras`` or in ``deephyper.netrics``. The loss functions availble in ``deephyper.metrics`` are: * Sparse Perplexity: ``sparse_perplexity`` * R2: ``r2`` *...
3,474
31.175926
262
py
deephyper
deephyper-master/deephyper/nas/__init__.py
from ._nx_search_space import NxSearchSpace from ._keras_search_space import KSearchSpace __all__ = ["NxSearchSpace", "KSearchSpace"]
135
26.2
45
py
deephyper
deephyper-master/deephyper/nas/trainer/_utils.py
from collections import OrderedDict import tensorflow as tf optimizers_keras = OrderedDict() optimizers_keras["sgd"] = tf.keras.optimizers.SGD optimizers_keras["rmsprop"] = tf.keras.optimizers.RMSprop optimizers_keras["adagrad"] = tf.keras.optimizers.Adagrad optimizers_keras["adam"] = tf.keras.optimizers.Adam optimiz...
1,156
35.15625
88
py
deephyper
deephyper-master/deephyper/nas/trainer/_horovod.py
import logging import time from inspect import signature import deephyper.nas.trainer._arch as a import deephyper.nas.trainer._utils as U import horovod.tensorflow.keras as hvd import numpy as np import tensorflow as tf from deephyper.core.exceptions import DeephyperRuntimeError from deephyper.nas.losses import select...
21,070
37.733456
241
py
deephyper
deephyper-master/deephyper/nas/trainer/_base.py
import inspect import logging import time from inspect import signature import deephyper.nas.trainer._arch as a import deephyper.nas.trainer._utils as U import numpy as np import tensorflow as tf from deephyper.core.exceptions import DeephyperRuntimeError from deephyper.nas.losses import selectLoss from deephyper.nas....
21,923
37.0625
241
py
deephyper
deephyper-master/deephyper/nas/spacelib/tabular/one_layer.py
import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import ConstantNode, VariableNode from deephyper.nas.operation import operation, Concatenate Dense = operation(tf.keras.layers.Dense) Dropout = operation(tf.keras.layers.Dropout) class OneLayerSpace(KSearchSpace): def __init_...
1,655
27.551724
87
py
deephyper
deephyper-master/deephyper/nas/spacelib/tabular/supervised_reg_auto_encoder.py
import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import ConstantNode, VariableNode from deephyper.nas.operation import Identity, operation Dense = operation(tf.keras.layers.Dense) class SupervisedRegAutoEncoderSpace(KSearchSpace): def __init__( self, input_s...
2,268
28.855263
85
py
deephyper
deephyper-master/deephyper/nas/spacelib/tabular/feed_forward.py
import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import ConstantNode, VariableNode from deephyper.nas.operation import Identity, operation Dense = operation(tf.keras.layers.Dense) class FeedForwardSpace(KSearchSpace): """Simple search space for a feed-forward neural network...
2,179
32.030303
150
py
deephyper
deephyper-master/deephyper/nas/spacelib/tabular/dense_skipco.py
import collections import tensorflow as tf from deephyper.nas import KSearchSpace from deephyper.nas.node import ConstantNode, VariableNode from deephyper.nas.operation import operation, Zero, Connect, AddByProjecting, Identity Dense = operation(tf.keras.layers.Dense) Dropout = operation(tf.keras.layers.Dropout) c...
2,637
28.311111
87
py
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_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/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/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/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/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/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/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/__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/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/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/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