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 |
|---|---|---|---|---|---|---|
DFMGAN | DFMGAN-main/torch_utils/custom_ops.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 5,644 | 43.448819 | 146 | py |
DFMGAN | DFMGAN-main/torch_utils/training_stats.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 10,707 | 38.806691 | 118 | py |
DFMGAN | DFMGAN-main/torch_utils/persistence.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 9,708 | 37.527778 | 144 | py |
DFMGAN | DFMGAN-main/torch_utils/misc.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 11,073 | 40.631579 | 133 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/bias_act.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 10,047 | 46.173709 | 185 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/grid_sample_gradfix.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 3,299 | 38.285714 | 138 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/conv2d_gradfix.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 7,677 | 43.900585 | 197 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/upfirdn2d.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 16,287 | 41.306494 | 157 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/conv2d_resample.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 7,591 | 47.356688 | 130 | py |
DFMGAN | DFMGAN-main/torch_utils/ops/fma.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 2,034 | 32.360656 | 105 | py |
DFMGAN | DFMGAN-main/metrics/metric_utils.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 12,605 | 43.076923 | 185 | py |
DFMGAN | DFMGAN-main/metrics/kernel_inception_distance.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 3,977 | 50 | 118 | py |
DFMGAN | DFMGAN-main/metrics/frechet_inception_distance.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 2,040 | 47.595238 | 118 | py |
DFMGAN | DFMGAN-main/metrics/lpips.py | import lpips, torch
import itertools
import numpy as np
import dnnlib
from tqdm import tqdm
import copy
def compute_clpips(opts, num_gen):
dataset_kwargs = opts.dataset_kwargs
device = opts.device
G = copy.deepcopy(opts.G).eval().requires_grad_(False).to(device)
with torch.no_grad():
loss_fn_a... | 3,201 | 41.131579 | 115 | py |
DFMGAN | DFMGAN-main/metrics/perceptual_path_length.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 5,538 | 40.962121 | 131 | py |
DFMGAN | DFMGAN-main/metrics/inception_score.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 1,874 | 47.076923 | 126 | py |
DFMGAN | DFMGAN-main/metrics/metric_main.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 7,212 | 36.963158 | 147 | py |
DFMGAN | DFMGAN-main/metrics/precision_recall.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 3,617 | 56.428571 | 159 | py |
Conditionial-SWF | Conditionial-SWF-main/main.py | import glob
import os
import shutil
import configargparse
import jax
import jax.numpy as jnp
import numpy as np
import dataset
import models
import plotting
import utils
parser = configargparse.ArgumentParser()
parser.add("-c", "--config", required=True, is_config_file=True, help="config file path")
utils.setup_pars... | 9,887 | 47.470588 | 287 | py |
Conditionial-SWF | Conditionial-SWF-main/plotting.py | import os
import imageio
import numpy as np
import torch
import torchvision
def save_image(args, i, data, prefix="", nrow=None):
data = (np.array(data) + 1.0) / 2.0
if args.dataset in ["mnist", "fashion"]:
data_shape = (1, 28, 28)
if args.dataset == "cifar10":
data_shape = (3, 32, 32)
if args.dataset... | 965 | 33.5 | 162 | py |
Conditionial-SWF | Conditionial-SWF-main/utils.py | import errno
import logging
import os
import random
import time
import coloredlogs
import jax
import jax.numpy as jnp
import numpy as np
param_dict = dict(
seed=0,
hdim=10000,
hdim_per_conv=10,
layer_steps=200,
step_size=1.0,
n_batched_particles=250000,
n_offline_particles=4000,
forward="sorting",
i... | 4,759 | 30.111111 | 143 | py |
Conditionial-SWF | Conditionial-SWF-main/dataset.py | import numpy as np
import torch
import torchvision
def mnist():
ds = torchvision.datasets.MNIST(root="./data", train=True, download=True)
dst = torchvision.datasets.MNIST(root="./data", train=False, download=True)
mx = ds.data.float()
mxt = dst.data.float()
my = torch.nn.functional.one_hot(ds.targets, num_c... | 2,912 | 31.730337 | 84 | py |
Conditionial-SWF | Conditionial-SWF-main/slicers.py | import jax
import jax.numpy as jnp
import numpy as np
def uniform(key, dim, hdim, **kwargs):
w = jax.random.normal(key, shape=(hdim, dim))
w_norm = jnp.linalg.norm(w, axis=1, keepdims=True)
w = w / w_norm
return w
def conv(key, input_shape, hdim, n_filters, kernel_sizes, strides=1, paddings="SAME", dilation... | 3,025 | 37.303797 | 128 | py |
Conditionial-SWF | Conditionial-SWF-main/layers.py | import functools
import jax
import jax.numpy as jnp
import jax.scipy
def sorting_forward(xs, x):
nx = xs.shape[0]
idx = jnp.searchsorted(xs, x)
im1 = jnp.clip(idx - 1, 0, nx - 1)
i = jnp.clip(idx, 0, nx - 1)
# if falls in the middle
delta_x = xs[i] - xs[im1]
offset_x = x - xs[im1]
rel_offset = jnp.cl... | 10,259 | 43.034335 | 251 | py |
Conditionial-SWF | Conditionial-SWF-main/models.py | import functools
import jax
import numpy as np
import layers
import slicers
nfs = 20
def downsample_kxk_dense_layer(layer, data_shape, k, hdim, step_size=1.0, method="lanczos3"):
down_k_size = (k, k)
dim_ratio = np.prod(down_k_size) / np.prod(data_shape[1:])
down_k_slicer = functools.partial(
slicers.dow... | 18,274 | 60.949153 | 286 | py |
blockchain-explorer | blockchain-explorer-main/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: Apache-2.0
#
# 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 --------------------... | 7,264 | 28.653061 | 96 | py |
DLFuzz | DLFuzz-master/ImageNet/utils_tmp.py | # -*- coding: utf-8 -*-
import random
from collections import defaultdict
import numpy as np
from datetime import datetime
from keras import backend as K
from keras.applications.vgg16 import preprocess_input, decode_predictions
from keras.models import Model
from keras.preprocessing import image
model_layer_weights_... | 15,272 | 40.167116 | 144 | py |
DLFuzz | DLFuzz-master/ImageNet/gen_diff.py | # -*- coding: utf-8 -*-
from __future__ import print_function
import shutil
from keras.applications.vgg16 import VGG16
from keras.applications.vgg19 import VGG19
from keras.applications.resnet50 import ResNet50
from keras.layers import Input
from scipy.misc import imsave
from utils_tmp import *
import sys
import os
... | 7,199 | 30.858407 | 127 | py |
DLFuzz | DLFuzz-master/MNIST/Model2.py | '''
LeNet-4
'''
# usage: python MNISTModel2.py - train the model
from __future__ import print_function
from keras.datasets import mnist
from keras.layers import Convolution2D, MaxPooling2D, Input, Dense, Activation, Flatten
from keras.models import Model
from keras.utils import to_categorical
def Model2(input_tens... | 2,636 | 30.023529 | 120 | py |
DLFuzz | DLFuzz-master/MNIST/Model3.py | '''
LeNet-5
'''
# usage: python MNISTModel3.py - train the model
from __future__ import print_function
from keras.datasets import mnist
from keras.layers import Convolution2D, MaxPooling2D, Input, Dense, Activation, Flatten
from keras.models import Model
from keras.utils import to_categorical
def Model3(input_tens... | 2,637 | 30.035294 | 120 | py |
DLFuzz | DLFuzz-master/MNIST/utils_tmp.py | # -*- coding: utf-8 -*-
import random
from collections import defaultdict
import numpy as np
from datetime import datetime
from keras import backend as K
from keras.applications.vgg16 import preprocess_input, decode_predictions
from keras.models import Model
from keras.preprocessing import image
model_layer_weights_... | 16,769 | 41.671756 | 144 | py |
DLFuzz | DLFuzz-master/MNIST/gen_diff.py | # -*- coding: utf-8 -*-
from __future__ import print_function
from keras.layers import Input
from scipy.misc import imsave
from utils_tmp import *
import sys
import os
import time
from Model1 import Model1
from Model2 import Model2
from Model3 import Model3
def load_data(path="../MNIST_data/mnist.npz"):
f = np.... | 7,071 | 29.614719 | 124 | py |
DLFuzz | DLFuzz-master/MNIST/Model1.py | '''
LeNet-1
'''
# usage: python MNISTModel1.py - train the model
from __future__ import print_function
from keras.datasets import mnist
from keras.layers import Convolution2D, MaxPooling2D, Input, Dense, Activation, Flatten
from keras.models import Model
from keras.utils import to_categorical
from keras import backe... | 3,009 | 29.714286 | 120 | py |
pylops | pylops-master/tutorials/torchop.py | r"""
19. Automatic Differentiation
=============================
This tutorial focuses on the use of :class:`pylops.TorchOperator` to allow performing
Automatic Differentiation (AD) on chains of operators which can be:
- native PyTorch mathematical operations (e.g., :func:`torch.log`,
:func:`torch.sin`, :func:`torch... | 5,465 | 30.964912 | 85 | py |
pylops | pylops-master/docs/source/conf.py | # -*- coding: utf-8 -*-
import sys
import os
import datetime
from sphinx_gallery.sorting import ExampleTitleSortKey
from pylops import __version__
# Sphinx needs to be able to import the package to use autodoc and get the version number
sys.path.insert(0, os.path.abspath("../../pylops"))
extensions = [
"sphinx.ex... | 4,717 | 28.304348 | 89 | py |
pylops | pylops-master/pytests/test_torchoperator.py | import numpy as np
import pytest
import torch
from numpy.testing import assert_array_equal
from pylops import MatrixMult, TorchOperator
par1 = {"ny": 11, "nx": 11, "dtype": np.float32} # square
par2 = {"ny": 21, "nx": 11, "dtype": np.float32} # overdetermined
np.random.seed(0)
@pytest.mark.parametrize("par", [(p... | 2,110 | 29.157143 | 88 | py |
pylops | pylops-master/pylops/_torchoperator.py | import logging
from pylops.utils import deps
if deps.torch_enabled:
import torch
from torch.utils.dlpack import from_dlpack, to_dlpack
if deps.cupy_enabled:
import cupy as cp
class _TorchOperator(torch.autograd.Function):
"""Wrapper class for PyLops operators into Torch functions"""
@staticmet... | 1,923 | 26.884058 | 73 | py |
pylops | pylops-master/pylops/__init__.py | """
PyLops
======
Linear operators and inverse problems are at the core of many of the most used
algorithms in signal processing, image processing, and remote sensing.
When dealing with small-scale problems, the Python numerical scientific
libraries `numpy <http://www.numpy.org>`_
and `scipy <http://www.scipy.org/scip... | 2,654 | 32.607595 | 79 | py |
pylops | pylops-master/pylops/torchoperator.py | __all__ = [
"TorchOperator",
]
from typing import Optional
import numpy as np
from pylops import LinearOperator
from pylops.utils import deps
if deps.torch_enabled:
from pylops._torchoperator import _TorchOperator
else:
torch_message = (
"Torch package not installed. In order to be able to use"
... | 3,580 | 33.76699 | 89 | py |
pylops | pylops-master/pylops/utils/typing.py | __all__ = [
"IntNDArray",
"NDArray",
"InputDimsLike",
"SamplingLike",
"ShapeLike",
"DTypeLike",
"TensorTypeLike",
]
from typing import Sequence, Tuple, Union
import numpy as np
import numpy.typing as npt
from pylops.utils.deps import torch_enabled
if torch_enabled:
import torch
IntN... | 608 | 17.454545 | 48 | py |
pylops | pylops-master/pylops/utils/deps.py | __all__ = [
"cupy_enabled",
"cusignal_enabled",
"devito_enabled",
"numba_enabled",
"pyfftw_enabled",
"pywt_enabled",
"skfmm_enabled",
"spgl1_enabled",
"sympy_enabled",
"torch_enabled",
]
import os
from importlib import util
# check package availability
cupy_enabled = (
util... | 4,378 | 26.540881 | 88 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/sotabench.py | import os
import numpy as np
import PIL
import torch
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
from torchvision.datasets import ImageNet
from efficientnet_pytorch import EfficientNet
from sotabencheval.image_classification import ImageNetEvaluator
from sotabencheval.utils imp... | 2,094 | 28.097222 | 131 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Note: To use the 'upload' functionality of this file, you must:
# $ pipenv install twine --dev
import io
import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
# Package meta-data.
NAME = 'efficientnet_pytorch'
DESCRIPTIO... | 3,543 | 27.580645 | 96 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/hubconf.py | from efficientnet_pytorch import EfficientNet as _EfficientNet
dependencies = ['torch']
def _create_model_fn(model_name):
def _model_fn(num_classes=1000, in_channels=3, pretrained='imagenet'):
"""Create Efficient Net.
Described in detail here: https://arxiv.org/abs/1905.11946
Args:
... | 1,709 | 37.863636 | 78 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/efficientnet_pytorch/utils.py | """utils.py - Helper functions for building the model and for loading model parameters.
These helper functions are built to mirror those in the official TensorFlow implementation.
"""
# Author: lukemelas (github username)
# Github repo: https://github.com/lukemelas/EfficientNet-PyTorch
# With adjustments and added ... | 24,957 | 39.450567 | 130 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/efficientnet_pytorch/model.py | """model.py - Model and module class for EfficientNet.
They are built to mirror those in the official TensorFlow implementation.
"""
# Author: lukemelas (github username)
# Github repo: https://github.com/lukemelas/EfficientNet-PyTorch
# With adjustments and added comments by workingcoder (github username).
import... | 17,388 | 40.402381 | 107 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/examples/imagenet/main.py | """
Evaluate on ImageNet. Note that at the moment, training is not implemented (I am working on it).
that being said, evaluation is working.
"""
import argparse
import os
import random
import shutil
import time
import warnings
import PIL
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backend... | 17,107 | 37.531532 | 96 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/tests/test_model.py | from collections import OrderedDict
import pytest
import torch
import torch.nn as nn
from efficientnet_pytorch import EfficientNet
# -- fixtures -------------------------------------------------------------------------------------
@pytest.fixture(scope='module', params=[x for x in range(4)])
def model(request):
... | 4,122 | 31.984 | 99 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/load_tf_weights_tf1.py | import numpy as np
import tensorflow as tf
import torch
def load_param(checkpoint_file, conversion_table, model_name):
"""
Load parameters according to conversion_table.
Args:
checkpoint_file (string): pretrained checkpoint model file in tensorflow
conversion_table (dict): { pytorch tensor... | 10,344 | 58.797688 | 126 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/load_tf_weights.py | import numpy as np
import tensorflow as tf
import torch
tf.compat.v1.disable_v2_behavior()
def load_param(checkpoint_file, conversion_table, model_name):
"""
Load parameters according to conversion_table.
Args:
checkpoint_file (string): pretrained checkpoint model file in tensorflow
conve... | 10,410 | 58.491429 | 126 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/efficientnet_model.py | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# 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 applica... | 26,027 | 35.453782 | 80 | py |
EfficientNet-PyTorch | EfficientNet-PyTorch-master/tf_to_pytorch/convert_tf_to_pt/original_tf/utils.py | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# 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 applica... | 15,742 | 37.775862 | 91 | py |
neuron-importance-zsl | neuron-importance-zsl-master/mod2alpha.py | # Code to map from any modality to alphas.
# Train using class_info and alphas from a trained network
import argparse
import numpy as np
import random
random.seed(1234)
from random import shuffle
import pickle
from pprint import pprint
from dotmap import DotMap
import pdb
import csv
import os
import json
import tensorf... | 18,735 | 41.103371 | 377 | py |
neuron-importance-zsl | neuron-importance-zsl-master/alpha2w.py | # Finetune a network in tensorflow on the CUB dataset
import argparse
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import sys
import ntpath
import json
import pdb
import random
import torchfile
import importlib
from scipy.stats import spearmanr
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as p... | 49,803 | 47.589268 | 419 | py |
RecommenderSystems | RecommenderSystems-master/socialRec/dgrec/layers.py | from __future__ import division
from __future__ import print_function
import tensorflow as tf
from .inits import zeros
# DISCLAIMER:
# This file is forked from
# https://github.com/tkipf/gcn
# which is also under the MIT license
# global unique layer ID dictionary for layer name assignment
_LAYER_UIDS = {}
def g... | 3,731 | 31.172414 | 105 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/test.py | import argparse
import os
import random
import shutil
import time
import warnings
import sys
import cv2
import numpy as np
import scipy.misc
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.multiprocessing... | 13,359 | 39.731707 | 124 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/train_sr.py | import argparse
import os
import copy
import torch
from torch import nn
import torch.optim as optim
import torch.backends.cudnn as cudnn
from torch.utils.data.dataloader import DataLoader
from tqdm import tqdm
from sr_models.model import RDN, VGGLoss
from sr_models.datasets import TrainDataset, EvalDataset
from sr_mo... | 4,950 | 41.316239 | 173 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/train.py | import argparse
import os
import random
import shutil
import time
import warnings
import sys
import cv2
import numpy as np
import scipy.misc
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.multiprocessing... | 17,834 | 40.866197 | 195 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/models/customize.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Hang Zhang
## ECE Department, Rutgers University
## Email: zhang.hang@rutgers.edu
## Copyright (c) 2017
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this sou... | 10,973 | 36.71134 | 99 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/models/resnet.py | """Dilated ResNet"""
import math
import torch
import torch.utils.model_zoo as model_zoo
import torch.nn as nn
from .customize import GlobalAvgPool2d
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'BasicBlock', 'Bottleneck', 'get_resnet']
model_urls = {
'resnet18': '... | 11,165 | 35.135922 | 162 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/models/resnet_cifar.py | """Dilated ResNet"""
import torch.nn as nn
from .customize import FrozenBatchNorm2d
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth',
}
def conv_1_3x3(input_channel):
return nn.Sequential(nn.Co... | 11,254 | 37.412969 | 140 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/sr_models/utils.py | import torch
import numpy as np
def convert_rgb_to_y(img, dim_order='hwc'):
if dim_order == 'hwc':
return 16. + (64.738 * img[..., 0] + 129.057 * img[..., 1] + 25.064 * img[..., 2]) / 256.
else:
return 16. + (64.738 * img[0] + 129.057 * img[1] + 25.064 * img[2]) / 256.
def denormalize(img):
... | 1,061 | 22.086957 | 97 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/sr_models/model.py | import torch
from torch import nn
class DenseLayer(nn.Module):
def __init__(self, in_channels, out_channels):
super(DenseLayer, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=3 // 2)
self.relu = nn.ReLU(inplace=True)
def forward(self, x):
... | 4,943 | 36.172932 | 122 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/sr_models/datasets.py | import random
import h5py
import numpy as np
from PIL import Image
from torch.utils.data import Dataset
from scipy.ndimage import gaussian_filter
from scipy.ndimage.filters import convolve
from io import BytesIO
import copy
class TrainDataset(Dataset):
def __init__(self, file_path, patch_size, scale, aug=False, c... | 10,057 | 32.415282 | 102 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/datasets/base.py | ###########################################################################
# Created by: Hang Zhang
# Email: zhang.hang@rutgers.edu
# Copyright (c) 2017
###########################################################################
import random
import numpy as np
from PIL import Image, ImageOps, ImageFilter
import to... | 835 | 22.222222 | 75 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/datasets/image_dataset.py | ###########################################################################
# Created by: Hang Zhang
# Email: zhang.hang@rutgers.edu
# Copyright (c) 2018
###########################################################################
import os
import sys
import random
import numpy as np
from tqdm import tqdm, trange
from ... | 2,300 | 31.871429 | 144 | py |
BeyondtheSpectrum | BeyondtheSpectrum-main/datasets/__init__.py | import warnings
from torchvision.datasets import *
from .base import *
from .image_dataset import BinaryImageDataset
datasets = {
'image': BinaryImageDataset,
}
def get_dataset(name, **kwargs):
return datasets[name.lower()](**kwargs)
| 246 | 16.642857 | 45 | py |
ps-lite | ps-lite-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# ps-lite documentation build configuration file, created by
# sphinx-quickstart on Sun Mar 20 20:12:23 2016.
#
# Mu: additional changes
# - add breathe into extensions
# - change html theme into sphinx_rtd_theme
# - add sphnix_util.py
# - add .md into source_suffix
# - add setup() a... | 10,101 | 30.968354 | 80 | py |
minkasi | minkasi-master/examples/tsBowl_map_maker.py | import minkasi
import numpy as np
from matplotlib import pyplot as plt
import glob
import time
import minkasi_jax.presets_by_source as pbs
import os
from astropy.coordinates import Angle
from astropy import units as u
dir = '/scratch/r/rbond/jorlo/MS0735//TS_EaCMS0f0_51_5_Oct_2021/'
tod_names=glob.glob(dir+'Sig*.fits'... | 6,463 | 28.788018 | 146 | py |
tbsm | tbsm-main/tbsm_pytorch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
### import packages ###
from __future__ import absolute_import, division, print_function, unicode_literals
# miscellaneous
import time
import... | 35,338 | 36.917382 | 148 | py |
tbsm | tbsm-main/tbsm_synthetic.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# miscellaneous
from os import path
import sys
# numpy and scikit-learn
import numpy as np
from sklearn.metrics import roc_auc_score
# pyto... | 11,465 | 36.106796 | 88 | py |
tbsm | tbsm-main/tbsm_data_pytorch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
### import packages ###
from __future__ import absolute_import, division, print_function, unicode_literals
# miscellaneous
from os import pat... | 16,772 | 36.52349 | 88 | py |
rllab | rllab-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# rllab documentation build configuration file, created by
# sphinx-quickstart on Mon Feb 15 20:07:12 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All... | 9,550 | 31.050336 | 79 | py |
wakenet | wakenet-master/Code/example_main.py | from neuralWake import *
from optimisation import *
import synth_and_train as st
def florisPw(u_stream, tis, xs, ys, yws):
# Initialise FLORIS for initial configuraiton
if curl == True:
fi.floris.farm.set_wake_model("curl")
fi.reinitialize_flow_field(wind_speed=u_stream)
fi.reinitialize_flow_f... | 4,399 | 30.884058 | 105 | py |
wakenet | wakenet-master/Code/packages.py | # Package list
import os
import time
import json
import random
import warnings
import numpy as np
import scipy.stats as stats
from matplotlib import rc
import matplotlib.pyplot as plt
from matplotlib.pyplot import gca
import torch
import torch.nn as nn
import torch.optim as optim
from torch import nn, optim
from tor... | 840 | 21.72973 | 69 | py |
wakenet | wakenet-master/Code/superposition.py | from re import S
from neuralWake import *
from torch import cpu
from CNNWake.FCC_model import *
warnings.filterwarnings("ignore")
# Synth value
if train_net == 0:
# Load model
model = wakeNet().to(device)
model.load_state_dict(torch.load(weights_path, map_location=device))
model.eval().to(device)
# Us... | 19,926 | 37.469112 | 101 | py |
wakenet | wakenet-master/Code/synth_and_train.py | from neuralWake import *
def set_seed(seed):
"""
Use this to set ALL the random seeds to a fixed value and remove randomness from cuda kernels
"""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# Uses the inbuilt cudnn auto-tuner to fin... | 15,305 | 31.916129 | 102 | py |
wakenet | wakenet-master/Code/neuralWake.py | from packages import *
from initialisations import *
class wakeNet(nn.Module):
"""
wakeNet class definition
"""
def __init__(self, inputs=3, hidden_neurons=[100, 200]):
"""
wakeNet initializations
Args:
u_stream (torch float array) Inputs of training step.
... | 12,814 | 32.372396 | 97 | py |
wakenet | wakenet-master/Code/initialisations.py | import numpy as np
from packages import json
from packages import torch
import floris.tools as wfct
from floris.tools import static_class as sc
# Initialisation of variables #
# =======================================================================... | 4,417 | 28.065789 | 100 | py |
wakenet | wakenet-master/Code/CNNWake/FCC_model.py | import torch
import torch.nn as nn
import numpy as np
import random
import floris.tools as wfct
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__c... | 24,254 | 42.467742 | 97 | py |
wakenet | wakenet-master/Code/CNNWake/visualise.py | import torch
import matplotlib.pyplot as plt
import numpy as np
import time
import floris.tools as wfct
from .superposition import super_position
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.... | 13,979 | 42.6875 | 131 | py |
wakenet | wakenet-master/Code/CNNWake/train_CNN.py | import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
from .CNN_model import Generator
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
_... | 5,251 | 38.19403 | 78 | py |
wakenet | wakenet-master/Code/CNNWake/train_FCNN.py | import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from torch.optim import lr_scheduler
from FCC_model import FCNN
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__licen... | 5,082 | 38.1 | 79 | py |
wakenet | wakenet-master/Code/CNNWake/superposition.py | import torch
from torch.backends import cudnn
import matplotlib.pyplot as plt
import numpy as np
import time
import floris.tools as wfct
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.ac.uk"
__s... | 12,291 | 43.375451 | 130 | py |
wakenet | wakenet-master/Code/CNNWake/optimisation.py | from scipy.optimize import minimize
import numpy as np
import torch
import time
import floris.tools as wfct
from .superposition import CNNWake_farm_power, FLORIS_farm_power
from .CNN_model import Generator
from .FCC_model import FCNN
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["J... | 8,797 | 42.554455 | 79 | py |
wakenet | wakenet-master/Code/CNNWake/CNN_model.py | import torch
import torch.nn as nn
import numpy as np
import random
import floris.tools as wfct
__author__ = "Jens Bauer"
__copyright__ = "Copyright 2021, CNNwake"
__credits__ = ["Jens Bauer"]
__license__ = "MIT"
__version__ = "1.0"
__email__ = "jens.bauer20@imperial.ac.uk"
__status__ = "Development"
class Generator... | 14,425 | 42.583082 | 79 | py |
Enhancement-Coded-Speech | Enhancement-Coded-Speech-master/CepsDomCNN_Train.py | #####################################################################################
# Training the CNN for cepstral domain approach III.
# Input:
# 1- Training input: Train_inputSet_g711.mat
# 2- Training target: Train_targetSet_g711.mat
# 3- Validation input: Validation_inputSet_g711.mat
# 4-... | 6,716 | 35.112903 | 151 | py |
Enhancement-Coded-Speech | Enhancement-Coded-Speech-master/CepsDomCNN_Test.py | #####################################################################################
# Use the trained CNN for cepstral domain approach III.
# Input:
# 1- CNN input: type_3_cnn_input_ceps.mat
# 2- Trained CNN weights: cnn_weights_ceps_g711_best.h5
# Output:
# 1- CNN output: type_3_cnn_output_ceps.mat... | 4,173 | 31.866142 | 151 | py |
kl_sample | kl_sample-master/kl_sample/cosmo.py | """
Module containing all the relevant functions
to compute and manipulate cosmology.
Functions:
- get_cosmo_mask(params)
- get_cosmo_ccl(params)
- get_cls_ccl(params, cosmo, pz, ell_max)
- get_xipm_ccl(cosmo, cls, theta)
"""
import numpy as np
import pyccl as ccl
import kl_sample.reshape as rsh
import kl_sampl... | 8,962 | 27.453968 | 79 | py |
ilmart | ilmart-main/experiments/nrgam/nrgam_evaluate.py | #!/usr/bin/env python
# coding: utf-8
import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_ranking as tfr
import pickle
import argparse
from tqdm import tqdm
from rankeval.metrics.ndcg import NDCG
from collections import defaultdict
import yahoo_dataset
import numpy as np
DATASET_DICT = {
... | 3,771 | 34.92381 | 118 | py |
ilmart | ilmart-main/experiments/nrgam/nrgam_train.py | import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_ranking as tfr
import argparse
import pickle
from pathlib import Path
tf.config.threading.set_inter_op_parallelism_threads(40)
tf.config.threading.set_intra_op_parallelism_threads(40)
DATSET_DICT = {
"mslr_web/30k_fold1": "web30k",
"... | 5,534 | 39.698529 | 118 | py |
pytorch-darknet19 | pytorch-darknet19-master/demo/darknet19_demo.py | import numpy as np
import torch
import torchvision.datasets as dset
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from model import darknet
def main():
imageNet_label = [line.strip() for line in open("demo/imagenet.shortnames.list", 'r')]
dataset = dset.ImageFolder(root="demo/sam... | 995 | 31.129032 | 90 | py |
pytorch-darknet19 | pytorch-darknet19-master/base/base_model.py | import logging
import torch.nn as nn
import numpy as np
class BaseModel(nn.Module):
"""
Base class for all models
"""
def __init__(self):
super(BaseModel, self).__init__()
self.logger = logging.getLogger(self.__class__.__name__)
def forward(self, *input):
"""
Forwa... | 1,076 | 26.615385 | 93 | py |
pytorch-darknet19 | pytorch-darknet19-master/model/darknet.py | from collections import OrderedDict
from torch import nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from base import BaseModel
model_paths = {
'darknet19': 'https://s3.ap-northeast-2.amazonaws.com/deepbaksuvision/darknet19-deepBakSu-e1b3ec1e.pth'
}
class GlobalAvgPool2d(nn.Module):
... | 5,509 | 46.094017 | 107 | py |
RBNN | RBNN-master/imagenet/main.py | import argparse
import os
import time
import logging
import random
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import models_cifar
import models_imagenet
import numpy as np
from torch.autograd import Variable
from utils.options import args
from utils.common import *
from modules import *
fro... | 17,019 | 40.111111 | 161 | py |
RBNN | RBNN-master/imagenet/modules/binarized_modules.py | import torch
import torch.nn as nn
import math
import numpy as np
import torch.nn.functional as F
from torch.autograd import Function, Variable
from scipy.stats import ortho_group
from utils.options import args
class BinarizeConv2d(nn.Conv2d):
def __init__(self, *kargs, **kwargs):
super(BinarizeConv2d, se... | 3,835 | 34.518519 | 101 | py |
RBNN | RBNN-master/imagenet/dataset/dataset.py | from datetime import datetime
import os
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import transforms, datasets
from torch.utils.data import DataLoader
def load_data(type='both',dataset='cifar10',data_path='/data',batch_size = 256,batch_size_test=256,num_workers=0):
# load da... | 3,858 | 37.59 | 134 | py |
RBNN | RBNN-master/imagenet/dataset/__init__.py | from .dataset import load_data, add_module_fromdict
from .imagenet import get_imagenet_iter_dali as get_imagenet
from .imagenet import get_imagenet_iter_torch as get_imagenet_torch | 180 | 59.333333 | 67 | py |
RBNN | RBNN-master/imagenet/dataset/imagenet.py | import time
import torch.utils.data
import nvidia.dali.ops as ops
import nvidia.dali.types as types
import torchvision.datasets as datasets
from nvidia.dali.pipeline import Pipeline
import torchvision.transforms as transforms
from nvidia.dali.plugin.pytorch import DALIClassificationIterator, DALIGenericIterator
class... | 6,531 | 51.677419 | 131 | py |
RBNN | RBNN-master/imagenet/models_imagenet/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch.nn.init as init
from modules import *
BN = None
__all__ = ['resnet18_1w1a', 'resnet34_1w1a']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.... | 5,965 | 31.248649 | 97 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.