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 |
|---|---|---|---|---|---|---|
ReconVAT | ReconVAT-master/train_baseline_onset_frame_VAT.py | import os
from datetime import datetime
import pickle
import numpy as np
from sacred import Experiment
from sacred.commands import print_config, save_config
from sacred.observers import FileStorageObserver
from torch.optim.lr_scheduler import StepLR
from torch.utils.data import DataLoader, ConcatDataset
from tqdm imp... | 8,271 | 45.47191 | 136 | py |
ReconVAT | ReconVAT-master/train_UNet_VAT.py | import os
from datetime import datetime
import pickle
import numpy as np
from sacred import Experiment
from sacred.commands import print_config, save_config
from sacred.observers import FileStorageObserver
from torch.optim.lr_scheduler import StepLR, CyclicLR
from torch.utils.data import DataLoader, ConcatDataset
fro... | 8,580 | 43.926702 | 213 | py |
ReconVAT | ReconVAT-master/model/self_attention_VAT.py | """
A rough translation of Magenta's Onsets and Frames implementation [1].
[1] https://github.com/tensorflow/magenta/blob/master/magenta/models/onsets_frames_transcription/model.py
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from nnAudio import Spectrogram
fr... | 56,736 | 41.788084 | 196 | py |
ReconVAT | ReconVAT-master/model/VAT.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from nnAudio import Spectrogram
from .constants import *
from model.utils import Normalization
class stepwise_VAT(nn.Module):
"""
We define a function of regularization, specifically VAT.
"""
def __init__(s... | 1,478 | 32.613636 | 88 | py |
ReconVAT | ReconVAT-master/model/Unet_prestack.py | import torch
from torch.nn.functional import conv1d, mse_loss
import torch.nn.functional as F
import torch.nn as nn
from nnAudio import Spectrogram
from .constants import *
from model.utils import Normalization
batchNorm_momentum = 0.1
num_instruments = 1
class block(nn.Module):
def __init__(self, inp, out, ksiz... | 7,503 | 41.636364 | 124 | py |
ReconVAT | ReconVAT-master/model/onset_frame_VAT.py | """
A rough translation of Magenta's Onsets and Frames implementation [1].
[1] https://github.com/tensorflow/magenta/blob/master/magenta/models/onsets_frames_transcription/model.py
"""
import torch
import torch.nn.functional as F
from torch import nn
from nnAudio import Spectrogram
from .constants import *
from mo... | 29,455 | 39.685083 | 150 | py |
ReconVAT | ReconVAT-master/model/constants.py | import torch
SAMPLE_RATE = 16000
HOP_LENGTH = SAMPLE_RATE * 32 // 1000
ONSET_LENGTH = SAMPLE_RATE * 32 // 1000
OFFSET_LENGTH = SAMPLE_RATE * 32 // 1000
HOPS_IN_ONSET = ONSET_LENGTH // HOP_LENGTH
HOPS_IN_OFFSET = OFFSET_LENGTH // HOP_LENGTH
MIN_MIDI = 21
MAX_MIDI = 108
N_BINS = 229 # Default using Mel spectrograms
ME... | 570 | 20.961538 | 64 | py |
ReconVAT | ReconVAT-master/model/Thickstun_model.py | import torch
from torch.nn.functional import conv1d, mse_loss
import torch.nn.functional as F
import torch.nn as nn
from nnAudio import Spectrogram
from .constants import *
from model.utils import Normalization
class Thickstun(torch.nn.Module):
def __init__(self):
super(Thickstun, self).__init__()
... | 3,069 | 41.054795 | 122 | py |
ReconVAT | ReconVAT-master/model/helper_functions.py | import os
from model.dataset import *
from model.evaluate_functions import evaluate_wo_velocity
import torch
from torch.utils.tensorboard import SummaryWriter
from torch.nn.utils import clip_grad_norm_
import numpy as np
# Mac users need to uncomment these two lines
import matplotlib
matplotlib.use('TkAgg')
import mat... | 31,908 | 45.44687 | 155 | py |
ReconVAT | ReconVAT-master/model/self_attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
class MutliHeadAttention1D(nn.Module):
def __init__(self, in_features, out_features, kernel_size, stride=1, groups=1, position=True, bias=False):
"""kernel_size is the 1D local attention window size"""
... | 3,357 | 39.95122 | 135 | py |
ReconVAT | ReconVAT-master/model/utils.py | import sys
from functools import reduce
import torch
from PIL import Image
from torch.nn.modules.module import _addindent
def cycle(iterable):
while True:
for item in iterable:
yield item
def summary(model, file=sys.stdout):
def repr(model):
# We treat the extra repr like the su... | 3,934 | 35.775701 | 247 | py |
ReconVAT | ReconVAT-master/model/dataset.py | import json
import os
from abc import abstractmethod
from glob import glob
import sys
import pickle
import pandas as pd
import numpy as np
import soundfile
from torch.utils.data import Dataset
from tqdm import tqdm
from .constants import *
from .midi import parse_midi
class PianoRollAudioDataset(Dataset):
def ... | 22,968 | 40.914234 | 140 | py |
ReconVAT | ReconVAT-master/model/self_attenttion_model.py | """
A rough translation of Magenta's Onsets and Frames implementation [1].
[1] https://github.com/tensorflow/magenta/blob/master/magenta/models/onsets_frames_transcription/model.py
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from nnAudio import Spectrogram
fr... | 29,286 | 40.958453 | 211 | py |
ReconVAT | ReconVAT-master/model/__init__.py | from .constants import *
from .dataset import MAPS, MAESTRO, MusicNet, Corelli, Application_Wind, Application_Dataset
from .decoding import *
from .midi import save_midi
from .utils import *
from .evaluate_functions import *
from .helper_functions import *
# from .Conv_Seq2Seq import *
from .self_attenttion_model impor... | 521 | 31.625 | 92 | py |
ReconVAT | ReconVAT-master/model/decoding.py | import numpy as np
import torch
def extract_notes_wo_velocity(onsets, frames, onset_threshold=0.5, frame_threshold=0.5, rule='rule1'):
"""
Finds the note timings based on the onsets and frames information
Parameters
----------
onsets: torch.FloatTensor, shape = [frames, bins]
frames: torch.Flo... | 4,479 | 33.198473 | 134 | py |
ReconVAT | ReconVAT-master/model/UNet_onset.py | """
A rough translation of Magenta's Onsets and Frames implementation [1].
[1] https://github.com/tensorflow/magenta/blob/master/magenta/models/onsets_frames_transcription/model.py
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from nnAudio import Spectrogram
fr... | 25,563 | 45.144404 | 196 | py |
ReconVAT | ReconVAT-master/model/Spectrogram.py | """
Module containing all the spectrogram classes
"""
# 0.2.0
import torch
import torch.nn as nn
from torch.nn.functional import conv1d, conv2d, fold
import scipy # used only in CFP
import numpy as np
from time import time
from nnAudio.librosa_functions import *
from nnAudio.utils import *
sz_float = 4 # size... | 96,009 | 41.976723 | 401 | py |
ReconVAT | ReconVAT-master/model/evaluate_functions.py | import argparse
import os
import sys
from collections import defaultdict
import numpy as np
from mir_eval.multipitch import evaluate as evaluate_frames
from mir_eval.transcription import precision_recall_f1_overlap as evaluate_notes
from mir_eval.transcription_velocity import precision_recall_f1_overlap as evaluate_no... | 6,587 | 50.069767 | 174 | py |
ReconVAT | ReconVAT-master/model/Segmentation.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
import torch.nn.init as init
import numpy as np
from nnAudio import Spectrogram
from .constants import *
from model.utils import Normalization
def _l2_normalize(d, binwise):
# input shape (batch, timesteps, bins, ?)... | 25,776 | 39.15109 | 156 | py |
ReconVAT | ReconVAT-master/model/midi.py | import multiprocessing
import sys
import mido
import numpy as np
from joblib import Parallel, delayed
from mido import Message, MidiFile, MidiTrack
from mir_eval.util import hz_to_midi
from tqdm import tqdm
def parse_midi(path):
"""open midi file and return np.array of (onset, offset, note, velocity) rows"""
... | 3,796 | 34.485981 | 122 | py |
DFMGAN | DFMGAN-main/legacy.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 16,502 | 50.411215 | 154 | py |
DFMGAN | DFMGAN-main/style_mixing.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 4,891 | 40.109244 | 132 | py |
DFMGAN | DFMGAN-main/projector.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 8,990 | 41.211268 | 136 | py |
DFMGAN | DFMGAN-main/generate.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 10,000 | 45.300926 | 150 | py |
DFMGAN | DFMGAN-main/gen_gif_dfmgan.py | """Generate GIF using pretrained network pickle."""
import os
import click
import dnnlib
import numpy as np
from PIL import Image
import torch
import legacy
#----------------------------------------------------------------------------
@click.command()
@click.option('--network', 'network_pkl', help='Network pickle ... | 5,711 | 41.947368 | 170 | py |
DFMGAN | DFMGAN-main/generate_gif.py | """Generate GIF using pretrained network pickle."""
import os
import click
import dnnlib
import numpy as np
from PIL import Image
import torch
import legacy
#----------------------------------------------------------------------------
@click.command()
@click.option('--network', 'network_pkl', help='Network pickle ... | 5,303 | 43.571429 | 196 | py |
DFMGAN | DFMGAN-main/dataset_tool.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... | 19,055 | 39.372881 | 201 | py |
DFMGAN | DFMGAN-main/train.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 29,176 | 44.095827 | 192 | py |
DFMGAN | DFMGAN-main/calc_metrics.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and rel... | 9,992 | 43.413333 | 182 | py |
DFMGAN | DFMGAN-main/training/loss.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 18,203 | 56.974522 | 266 | py |
DFMGAN | DFMGAN-main/training/augment.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 26,373 | 60.050926 | 366 | py |
DFMGAN | DFMGAN-main/training/dataset.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 8,683 | 35.334728 | 159 | py |
DFMGAN | DFMGAN-main/training/networks.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 49,430 | 50.544317 | 199 | py |
DFMGAN | DFMGAN-main/training/__init__.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... | 435 | 42.6 | 76 | py |
DFMGAN | DFMGAN-main/training/training_loop.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 31,481 | 53.27931 | 184 | py |
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/__init__.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... | 436 | 42.7 | 76 | 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/torch_utils/ops/__init__.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... | 436 | 42.7 | 76 | 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/__init__.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... | 435 | 42.6 | 76 | 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 |
DFMGAN | DFMGAN-main/dnnlib/util.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and re... | 16,625 | 33.782427 | 151 | py |
DFMGAN | DFMGAN-main/dnnlib/__init__.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... | 476 | 46.7 | 76 | 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 |
Conditionial-SWF | Conditionial-SWF-main/data/get_celebA.py | import resource
low, high = resource.getrlimit(resource.RLIMIT_NOFILE)
resource.setrlimit(resource.RLIMIT_NOFILE, (high, high))
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
def resize_small(image, resolution):
"""Shrink an image to the given resolution."""
h, w = image.shape[0],... | 3,109 | 33.555556 | 95 | 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/setup.py | import os
from setuptools import find_packages, setup
def src(pth):
return os.path.join(os.path.dirname(__file__), pth)
# Project description
descr = (
"Python library implementing linear operators to allow solving large-scale optimization "
"problems without requiring to explicitly create a dense (or ... | 1,647 | 28.963636 | 93 | 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/tutorials/lsm.py | r"""
15. Least-squares migration
===========================
Seismic migration is the process by which seismic data are manipulated to create
an image of the subsurface reflectivity.
While traditionally solved as the adjont of the demigration operator,
it is becoming more and more common to solve the underlying invers... | 6,408 | 32.380208 | 113 | py |
pylops | pylops-master/tutorials/deblending.py | r"""
18. Deblending
==============
The cocktail party problem arises when sounds from different sources mix before reaching our ears
(or any recording device), requiring the brain (or any hardware in the recording device) to estimate
individual sources from the received mixture. In seismic acquisition, an analog proble... | 8,243 | 30.227273 | 114 | py |
pylops | pylops-master/tutorials/realcomplex.py | r"""
17. Real/Complex Inversion
==========================
In this tutorial we will discuss two equivalent approaches to the solution
of inverse problems with real-valued model vector and complex-valued data vector.
In other words, we consider a modelling operator
:math:`\mathbf{A}:\mathbb{F}^m \to \mathbb{C}^n` (which... | 2,359 | 29.25641 | 81 | py |
pylops | pylops-master/tutorials/mdd.py | """
09. Multi-Dimensional Deconvolution
===================================
This example shows how to set-up and run the
:py:class:`pylops.waveeqprocessing.MDD` inversion using synthetic data.
"""
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pylops
from pylops.utils.seismicevents import ... | 7,744 | 25.892361 | 88 | py |
pylops | pylops-master/tutorials/seismicinterpolation.py | r"""
12. Seismic regularization
==========================
The problem of *seismic data regularization* (or interpolation) is a very
simple one to write, yet ill-posed and very hard to solve.
The forward modelling operator is a simple :py:class:`pylops.Restriction`
operator which is applied along the spatial direction... | 12,173 | 26.542986 | 112 | py |
pylops | pylops-master/tutorials/ilsm.py | r"""
20. Image Domain Least-squares migration
========================================
Seismic migration is the process by which seismic data are manipulated to create
an image of the subsurface reflectivity.
In one of the previous tutorials, we have seen how the process can be formulated
as an inverse problem, which ... | 8,191 | 30.875486 | 133 | py |
pylops | pylops-master/tutorials/bayesian.py | r"""
04. Bayesian Inversion
======================
This tutorial focuses on Bayesian inversion, a special type of inverse problem
that aims at incorporating prior information in terms of model and data
probabilities in the inversion process.
In this case we will be dealing with the same problem that we discussed in
:r... | 7,878 | 34.490991 | 87 | py |
pylops | pylops-master/tutorials/poststack.py | r"""
07. Post-stack inversion
========================
Estimating subsurface properties from band-limited seismic data represents an
important task for geophysical subsurface characterization.
In this tutorial, the :py:class:`pylops.avo.poststack.PoststackLinearModelling`
operator is used for modelling of both 1d and ... | 10,369 | 30.141141 | 105 | py |
pylops | pylops-master/tutorials/wavefielddecomposition.py | r"""
14. Seismic wavefield decomposition
===================================
Multi-component seismic data can be decomposed
in their up- and down-going constituents in a purely data driven fashion.
This task can be accurately achieved by linearly combining the input pressure
and particle velocity data in the frequency-... | 9,595 | 28.9875 | 125 | py |
pylops | pylops-master/tutorials/ctscan.py | r"""
16. CT Scan Imaging
===================
This tutorial considers a very well-known inverse problem from the field of
medical imaging.
We will be using the :func:`pylops.signalprocessing.Radon2D` operator
to model a *sinogram*, which is a graphic representation of the raw data
obtained from a CT scan. The sinogram ... | 3,873 | 26.671429 | 79 | py |
pylops | pylops-master/tutorials/prestack.py | r"""
08. Pre-stack (AVO) inversion
=============================
Pre-stack inversion represents one step beyond post-stack inversion in that
not only the profile of acoustic impedance can be inferred from seismic data,
rather a set of elastic parameters is estimated from pre-stack data
(i.e., angle gathers) using the i... | 17,756 | 29.562823 | 94 | py |
pylops | pylops-master/tutorials/linearoperator.py | """
01. The LinearOperator
======================
This first tutorial is aimed at easing the use of the PyLops
library for both new users and developers.
We will start by looking at how to initialize a linear operator as well as
different ways to apply the forward and adjoint operations. Finally we will
investigate va... | 9,016 | 33.680769 | 81 | py |
pylops | pylops-master/tutorials/interpolation.py | r"""
06. 2D Interpolation
====================
In the mathematical field of numerical analysis, interpolation is the problem of constructing new data
points within the range of a discrete set of known data points. In signal and image processing,
the data may be recorded at irregular locations and it is often required t... | 4,061 | 32.85 | 102 | py |
pylops | pylops-master/tutorials/deblurring.py | r"""
05. Image deblurring
====================
*Deblurring* is the process of removing blurring effects from images, caused for
example by defocus aberration or motion blur.
In forward mode, such blurring effect is typically modelled as a 2-dimensional
convolution between the so-called *point spread function* and a ta... | 5,273 | 33.470588 | 80 | py |
pylops | pylops-master/tutorials/marchenko.py | """
10. Marchenko redatuming by inversion
=====================================
This example shows how to set-up and run the
:py:class:`pylops.waveeqprocessing.Marchenko` inversion using synthetic data.
"""
# sphinx_gallery_thumbnail_number = 5
# pylint: disable=C0103
import warnings
import matplotlib.pyplot as plt
i... | 6,260 | 25.871245 | 88 | py |
pylops | pylops-master/tutorials/dottest.py | """
02. The Dot-Test
================
One of the most important aspect of writing a *Linear operator* is to be able
to verify that the code implemented in *forward mode* and the code implemented
in *adjoint mode* are effectively adjoint to each other. If this is the case,
your Linear operator will successfully pass the... | 4,980 | 33.116438 | 94 | py |
pylops | pylops-master/tutorials/classsolvers.py | r"""
03. Solvers (Advanced)
======================
This is a follow up tutorial to the :ref:`sphx_glr_tutorials_solvers.py` tutorial. The same example will be considered,
however we will showcase how to use the class-based version of our solvers (introduced in PyLops v2).
First of all, when shall you use class-based s... | 6,320 | 33.353261 | 120 | py |
pylops | pylops-master/tutorials/radonfiltering.py | r"""
11. Radon filtering
===================
In this example we will be taking advantage of the
:py:class:`pylops.signalprocessing.Radon2D` operator to perform filtering of
unwanted events from a seismic data. For those of you not familiar with seismic
data, let's imagine that we have a data composed of a certain numbe... | 5,808 | 33.993976 | 87 | py |
pylops | pylops-master/tutorials/deghosting.py | r"""
13. Deghosting
==============
Single-component seismic data can be decomposed
in their up- and down-going constituents in a model driven fashion.
This task can be achieved by defining an f-k propagator (or ghost model) and
solving an inverse problem as described in
:func:`pylops.waveeqprocessing.Deghosting`.
"""
... | 4,499 | 24.280899 | 128 | py |
pylops | pylops-master/tutorials/solvers.py | r"""
03. Solvers
===========
This tutorial will guide you through the :py:mod:`pylops.optimization`
module and show how to use various solvers that are included in the
PyLops library.
The main idea here is to provide the user of PyLops with very high-level
functionalities to quickly and easily set up and solve complex... | 14,441 | 36.317829 | 93 | py |
pylops | pylops-master/examples/plot_flip.py | r"""
Flip along an axis
==================
This example shows how to use the :py:class:`pylops.Flip`
operator to simply flip an input signal along an axis.
"""
import matplotlib.pyplot as plt
import numpy as np
import pylops
plt.close("all")
#########################################################################... | 2,455 | 27.55814 | 79 | py |
pylops | pylops-master/examples/plot_tapers.py | """
Tapers
======
This example shows how to create some basic tapers in 1d, 2d, and 3d
using the :py:mod:`pylops.utils.tapers` module.
"""
import matplotlib.pyplot as plt
import pylops
plt.close("all")
############################################
# Let's first define the time and space axes
par = {
"ox": -200,
... | 1,541 | 23.870968 | 73 | py |
pylops | pylops-master/examples/plot_symmetrize.py | r"""
Symmetrize
==========
This example shows how to use the :py:class:`pylops.Symmetrize`
operator which takes an input signal and returns a symmetric signal
by pre-pending the input signal in reversed order. Such an operation can be
inverted as we will see in this example.
Moreover the :py:class:`pylops.Symmetrize`... | 3,135 | 30.36 | 85 | py |
pylops | pylops-master/examples/plot_smoothing1d.py | r"""
1D Smoothing
============
This example shows how to use the :py:class:`pylops.Smoothing1D` operator
to smooth an input signal along a given axis.
Derivative (or roughening) operators are generally used *regularization*
in inverse problems. Smoothing has the opposite effect of roughening and
it can be employed as... | 2,681 | 30.186047 | 89 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.