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
linpde-gp
linpde-gp-main/experiments/experiment_utils/_setup.py
import pathlib import jax import matplotlib.pyplot as plt from matplotlib_inline.backend_inline import set_matplotlib_formats # Use custom matplotlib style file plt.style.use(pathlib.Path(__file__).parent / "linpde-gp.mplstyle") # Set output formats for matplotlib inline backend set_matplotlib_formats("svg") # Jax ...
376
24.133333
67
py
cac-openset
cac-openset-master/train_cacOpenset.py
""" Train an open set classifier with CAC Loss on the datasets. The overall setup of this training script has been adapted from https://github.com/kuangliu/pytorch-cifar Dimity Miller, 2020 """ import torch import torch.nn as nn import torch.optim as optim import json import torchvision import torchvision.transfo...
7,391
31.279476
141
py
cac-openset
cac-openset-master/eval_closedSet.py
""" Evaluate average performance for a standard closed set classifier on a given dataset. Dimity Miller, 2020 """ import argparse import json import torchvision import torchvision.transforms as tf import torch import torch.nn as nn from networks import closedSetClassifier import datasets.utils as dataHelper fro...
3,022
30.821053
136
py
cac-openset
cac-openset-master/utils.py
""" Helper functions for training and evaluation. progress_bar and format_time function was taken from https://github.com/kuangliu/pytorch-cifar which mimics xlua.progress Dimity Miller, 2020 """ import os import sys import time import math import numpy as np import torch import datasets.utils as dataHel...
6,578
28.904545
147
py
cac-openset
cac-openset-master/train_closedSet.py
""" Train a closed-set classifier on the datasets. This training script has been adapted from https://github.com/kuangliu/pytorch-cifar Dimity Miller, 2020 """ import torch import torch.nn as nn import torch.optim as optim import json import torchvision import torchvision.transforms as tf import argparse impo...
4,757
28.7375
137
py
cac-openset
cac-openset-master/eval_cacOpenset.py
""" Evaluate average performance for our proposed CAC open-set classifier on a given dataset. Dimity Miller, 2020 """ import argparse import json import torchvision import torchvision.transforms as tf import torch import torch.nn as nn from networks import openSetClassifier import datasets.utils as dataHelper fr...
3,148
38.3625
140
py
cac-openset
cac-openset-master/networks/closedSetClassifier.py
""" Network definition for standard closed set classifier. Dimity Miller, 2020 """ import torch import torchvision import torch.nn as nn class closedSetClassifier(nn.Module): def __init__(self, num_classes = 20, num_channels = 3, im_size = 64, init_weights = False, dropout = 0.3, **kwargs): sup...
5,115
32.657895
120
py
cac-openset
cac-openset-master/networks/openSetClassifier.py
""" Network definition for our proposed CAC open set classifier. Dimity Miller, 2020 """ import torch import torchvision import torch.nn as nn class openSetClassifier(nn.Module): def __init__(self, num_classes = 20, num_channels = 3, im_size = 64, init_weights = False, dropout = 0.3, **kwargs): super(openSetC...
5,072
26.873626
117
py
cac-openset
cac-openset-master/datasets/utils.py
""" Functions useful for creating experiment datasets and dataloaders. Dimity Miller, 2020 """ import torch import torchvision import torchvision.transforms as tf import json from torch.autograd import Variable import numpy as np import random random.seed(1000) def get_train_loaders(datasetName, trial_num, cfg): ...
11,899
34.628743
133
py
cac-openset
cac-openset-master/datasets/generate_trainval_splits.py
""" Randomly select train and validation subsets from training datasets. 80/20 split ratio used for all datasets except TinyImageNet, which will use 90/10. Dimity Miller, 2020 """ import json import random import torchvision import numpy as np random.seed(1000) def save_trainval_split(dataset, train_idxs, val_id...
2,075
31.4375
91
py
cac-openset
cac-openset-master/datasets/generate_class_splits.py
""" Randomly selects 5 trials of known and unknown classes for each dataset and saves for reference. 1. MNIST, SVHN, CIFAR10 - 6 known, 4 unknown 2. CIFAR+M - 4 known from non-animal subset of CIFAR10, M unknown from animal subset of CIFAR100 3. TinyImageNet - 20 known, 180 unknown Dimity Miller, 2020 """ import...
2,349
36.301587
107
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/speed_tests/timeitcwt_1d.py
import torch import ptwt import pywt import time import numpy as np import matplotlib.pyplot as plt import tikzplotlib from ptwt.continuous_transform import _ShannonWavelet def _to_jit_cwt(sig): widths = torch.arange(1, 31) wavelet = _ShannonWavelet("shan0.1-0.4") sampling_period = (4 / 800) * np.pi ...
2,991
30.166667
96
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/speed_tests/timeitconv_1d.py
import pywt import ptwt import torch import numpy as np import time from typing import NamedTuple import matplotlib.pyplot as plt # import tikzplotlib class WaveletTuple(NamedTuple): """Replaces namedtuple("Wavelet", ("dec_lo", "dec_hi", "rec_lo", "rec_hi")).""" dec_lo: torch.Tensor dec_hi: torch.Tensor ...
3,752
32.212389
99
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/speed_tests/timeitconv_3d.py
from typing import NamedTuple import pywt import ptwt import torch import numpy as np import time import matplotlib.pyplot as plt # import tikzplotlib class WaveletTuple(NamedTuple): """Replaces namedtuple("Wavelet", ("dec_lo", "dec_hi", "rec_lo", "rec_hi")).""" dec_lo: torch.Tensor dec_hi: torch.Tenso...
3,770
31.791304
87
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/speed_tests/timeitconv_2d.py
from typing import NamedTuple import pywt import ptwt import torch import numpy as np import time from pytorch_wavelets import DWTForward import matplotlib.pyplot as plt # import tikzplotlib class WaveletTuple(NamedTuple): """Replaces namedtuple("Wavelet", ("dec_lo", "dec_hi", "rec_lo", "rec_hi")).""" dec_...
4,683
33.441176
103
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/continuous_signal_analysis/cwt_chirp_analysis.py
import torch import numpy as np import ptwt import matplotlib.pyplot as plt import scipy.signal as signal if __name__ == "__main__": t = np.linspace(-2, 2, 800, endpoint=False) sig = signal.chirp(t, f0=1, f1=12, t1=2, method="linear") widths = np.arange(1, 31) cwtmatr_pt, freqs = ptwt.cwt( torc...
808
26.896552
80
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/wavelet_packet_chirp_analysis/chirp_analysis.py
import torch import pywt import numpy as np import scipy.signal import matplotlib.pyplot as plt # use from src.ptwt.packets if you cloned the repo instead of using pip. from ptwt import WaveletPacket fs = 1000 t = np.linspace(0, 2, int(2//(1/fs))) w = np.sin(256*np.pi*t**2) wavelet = pywt.Wavelet("sym8") wp = Wavele...
1,171
23.93617
81
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/network_compression/wavelet_linear.py
# Originally created by moritz (wolter@cs.uni-bonn.de) # at https://github.com/v0lta/Wavelet-network-compression/blob/master/wavelet_learning/wavelet_linear.py import torch import numpy as np from torch.nn.parameter import Parameter import pywt from ptwt.conv_transform import wavedec, waverec class WaveletLayer(torch...
4,444
34.56
104
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/network_compression/mnist_compression.py
# Originally created by moritz (wolter@cs.uni-bonn.de) on 17/12/2019 # at https://github.com/v0lta/Wavelet-network-compression/blob/master/mnist_compression.py # based on https://github.com/pytorch/examples/blob/master/mnist/main.py import argparse import numpy as np import torch import torch.nn as nn import torch.nn....
10,195
30.962382
91
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/examples/deepfake_analysis/packet_plot.py
import os from itertools import product from tqdm import tqdm from PIL import Image import numpy as np import torch import ptwt import pywt import matplotlib.pyplot as plt def get_freq_order(level: int): """Get the frequency order for a given packet decomposition level. Adapted from: https://github.com/...
5,330
32.31875
87
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/conv_transform_2.py
"""This module implements two-dimensional padded wavelet transforms. The implementation relies on torch.nn.functional.conv2d and torch.nn.functional.conv_transpose2d under the hood. """ from typing import List, Optional, Tuple, Union import pywt import torch from ._util import Wavelet, _as_wavelet, _get_len, _is_d...
9,062
32.817164
87
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/matmul_transform_3.py
"""Implement 3D separable boundary transforms.""" import sys from functools import partial from typing import Dict, List, NamedTuple, Optional, Tuple, Union import numpy as np import torch from ._util import ( Wavelet, _as_wavelet, _is_boundary_mode_supported, _is_dtype_supported, ) from .matmul_trans...
16,716
37.254005
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/matmul_transform.py
"""Implement matrix based fwt and ifwt. This module uses boundary filters instead of padding. The implementation is based on the description in Strang Nguyen (p. 32), as well as the description of boundary filters in "Ripples in Mathematics" section 10.3 . """ # Created by moritz (wolter@cs.uni-bonn.de) at 14.04.20 i...
22,734
35.728595
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/_util.py
"""Utility methods to compute wavelet decompositions from a dataset.""" from typing import Optional, Protocol, Sequence, Tuple, Union import pywt import torch class Wavelet(Protocol): """Wavelet object interface, based on the pywt wavelet object.""" name: str dec_lo: Sequence[float] dec_hi: Sequence...
1,989
28.701493
85
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/separable_conv_transform.py
"""Implement separable convolution based transforms. Under the hood code in this module transforms all dimensions individually using torch.nn.functional.conv1d and it's transpose. """ from typing import Dict, List, Optional, Union import numpy as np import pywt import torch from ._util import _as_wavelet from .conv_...
13,612
33.638677
85
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/continuous_transform.py
"""PyTorch compatible cwt code. This module is based on pywt's cwt implementation. """ from typing import Any, Tuple, Union import numpy as np import torch from pywt import ContinuousWavelet, DiscreteContinuousWavelet, Wavelet from pywt._functions import scale2frequency from torch.fft import fft, ifft def _next_fas...
11,257
34.968051
107
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/matmul_transform_2.py
"""Two dimensional matrix based fast wavelet transform implementations. This module uses boundary filters to minimize padding. """ # Written by moritz ( @ wolter.tech ) in 2021 import sys from typing import List, Optional, Tuple, Union, cast import numpy as np import torch from ._util import ( Wavelet, _as_w...
32,359
39
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/sparse_math.py
"""Efficiently construct fwt operations using sparse matrices.""" # Written by moritz ( @ wolter.tech ) 17.09.21 from itertools import product from typing import List import torch def _dense_kron( sparse_tensor_a: torch.Tensor, sparse_tensor_b: torch.Tensor ) -> torch.Tensor: """Faster than sparse_kron. ...
20,237
32.39604
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/packets.py
"""Compute analysis wavelet packet representations.""" # Created on Fri Apr 6 2021 by moritz (wolter@cs.uni-bonn.de) import collections from functools import partial from itertools import product from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union, cast import numpy as np import pywt import...
21,343
37.807273
89
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/conv_transform_3.py
"""Code for three dimensional padded transforms. The functions here are based on torch.nn.functional.conv3d and it's transpose. """ from typing import Dict, List, Optional, Sequence, Union, cast import pywt import torch from ._util import Wavelet, _as_wavelet, _get_len, _is_dtype_supported, _outer from .conv_transf...
9,342
33.603704
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/wavelets_learnable.py
"""Experimental code for adaptive wavelet learning. See https://arxiv.org/pdf/2004.09569.pdf for more information. """ # Created by moritz wolter@cs.uni-bonn.de, 14.05.20 # Inspired by Ripples in Mathematics, Jensen and La Cour-Harbo, Chapter 7.7 # import pywt from abc import ABC, abstractmethod from typing import Tup...
10,275
33.02649
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/src/ptwt/conv_transform.py
"""Fast wavelet transformations based on torch.nn.functional.conv1d and its transpose. This module treats boundaries with edge-padding. """ # Created by moritz wolter, 14.04.20 from typing import List, Optional, Sequence, Tuple, Union import pywt import torch from ._util import Wavelet, _as_wavelet, _get_len, _is_dt...
11,634
32.921283
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/_mackey_glass.py
"""Generate artificial time-series data for debugging purposes.""" from typing import Optional, Union import torch def generate_mackey( batch_size: int = 100, tmax: float = 200, delta_t: float = 1.0, rnd: bool = True, device: Union[torch.device, str] = "cuda", ) -> torch.Tensor: """Generate s...
3,296
31.643564
85
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_sparse_math.py
"""Test the sparse math code from ptwt.sparse_math.""" # Written by moritz ( @ wolter.tech ) in 2021 import numpy as np import pytest import scipy.signal import torch from scipy import datasets from src.ptwt.sparse_math import ( batch_mm, construct_conv2d_matrix, construct_conv_matrix, construct_stride...
10,862
32.018237
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_matrix_fwt_2.py
"""Test code for the boundary wavelets.""" # Created by moritz ( wolter@cs.uni-bonn.de ), 08.09.21 import numpy as np import pytest import pywt import scipy.signal import torch from src.ptwt.conv_transform import _flatten_2d_coeff_lst from src.ptwt.matmul_transform import MatrixWavedec, MatrixWaverec from src.ptwt.mat...
8,091
37.717703
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_separable_conv_fwt.py
"""Separable transform test code.""" import numpy as np import pytest import pywt import torch from src.ptwt.conv_transform import wavedec from src.ptwt.matmul_transform_2 import MatrixWavedec2 from src.ptwt.matmul_transform_3 import MatrixWavedec3 from src.ptwt.separable_conv_transform import ( _fswavedec, _...
5,702
36.032468
87
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_matrix_fwt.py
"""Test the fwt and ifwt matrices.""" # Written by moritz ( @ wolter.tech ) in 2021 import numpy as np import pytest import pywt import torch from src.ptwt.matmul_transform import ( MatrixWavedec, MatrixWaverec, _construct_a, _construct_s, construct_boundary_a, construct_boundary_s, ) from test...
7,206
38.598901
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_convolution_fwt.py
"""Test the conv-fwt code.""" # Written by moritz ( @ wolter.tech ) in 2021 import numpy as np import pytest import pywt import torch from scipy import datasets from src.ptwt._util import _outer from src.ptwt.conv_transform import ( _flatten_2d_coeff_lst, _translate_boundary_strings, wavedec, waverec, ...
8,187
37.990476
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_matrix_fwt_3.py
"""Test the 3d matrix-fwt code.""" import numpy as np import pytest import pywt import torch from src.ptwt.matmul_transform import construct_boundary_a from src.ptwt.matmul_transform_3 import MatrixWavedec3, MatrixWaverec3 from src.ptwt.sparse_math import _batch_dim_mm @pytest.mark.parametrize("axis", [1, 2, 3]) @p...
3,090
35.364706
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_jit.py
"""Ensure pytorch's torch.jit.trace feature works properly.""" from typing import NamedTuple import numpy as np import pytest import pywt import torch from scipy import signal import src.ptwt as ptwt from ptwt.continuous_transform import _ShannonWavelet from tests._mackey_glass import MackeyGenerator class WaveletT...
6,477
33.457447
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_packets.py
"""Test the wavelet packet code.""" # Created on Fri Apr 6 2021 by moritz (wolter@cs.uni-bonn.de) from itertools import product import numpy as np import pytest import pywt import torch from scipy import datasets from src.ptwt.packets import WaveletPacket, WaveletPacket2D, get_freq_order def _compare_trees1( wa...
11,918
32.574648
88
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_wavelet.py
"""Test the adaptive wavelet cost functions.""" import pytest import pywt import torch from src.ptwt.wavelets_learnable import SoftOrthogonalWavelet @pytest.mark.parametrize( "lst, is_orth", [ (pywt.wavelist(family="db"), True), (pywt.wavelist(family="sym"), True), (pywt.wavelist(fami...
1,316
29.627907
65
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_cwt.py
"""Test the continuous transformation code.""" from typing import Union import numpy as np import pytest import pywt import torch from scipy import signal from src.ptwt.continuous_transform import _ShannonWavelet, cwt continuous_wavelets = [ "cgau1", "cgau2", "cgau3", "cgau4", "cgau5", "cgau6...
3,961
33.452174
81
py
PyTorch-Wavelet-Toolbox
PyTorch-Wavelet-Toolbox-main/tests/test_convolution_fwt_3.py
"""Test our 3d for loop-convolution based fwt code.""" from typing import List import numpy as np import pytest import pywt import torch import src.ptwt as ptwt def _expand_dims(batch_list: List) -> List: for pos, bel in enumerate(batch_list): if type(bel) is np.ndarray: batch_list[pos] = n...
2,637
30.404762
85
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/train.py
""" train PINNs """ import os, sys, time import copy import numpy as np import argparse import random import torch import torchvision import torch.nn as nn import torch.optim as optim from torch.autograd import Variable import wandb import matplotlib.pyplot as plt from datetime import datetime import logging from...
25,848
43.261986
296
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/models/ffn.py
import torch import torch.nn as nn import numpy as np from utils.misc_utils import set_activation class FeedForward(nn.Module): ''' An n-layer-feed-forward-layer module ''' def __init__(self, in_dim=2, out_dim=1, depth=5, hidden_dim=50, activation='tanh'): super().__init__() self.depth = depth ...
1,588
36.833333
102
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/domains.py
''' domain classes ''' import torch import random import numpy as np from utils.pde_sols import compute_sol from utils.misc_utils import normalize, softmax, show import matplotlib.pyplot as plt def fake_mask(nt, nx, n=100): mask = np.zeros((nt,nx)) offset = 20 mask[nt//4-offset:3*nt//4-offset, nx//4:3*nx...
17,941
46.845333
164
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/logging_utils.py
import os import logging _format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' def config_logger(log_level=logging.INFO): logging.basicConfig(format=_format, level=log_level) def log_to_file(logger_name=None, log_level=logging.INFO, log_filename='tensorflow.log'): if not os.path.exists(os.path.dirnam...
1,042
30.606061
97
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/misc_utils.py
""" misc utils """ import numpy as np import scipy as sc import scipy.ndimage as nd import torch import torch.nn as nn import matplotlib import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib.colors import Normalize from matplotlib import cm def get_velocity(vel_type...
9,928
33.595819
138
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/loss_utils.py
""" loss functions """ import torch import torch.nn as nn import logging import numpy as np from torch.autograd import Variable import time from utils.misc_utils import gaussian, poisson_source, get_diff_tensor, diffusion_coef, show, get_velocity import matplotlib.pyplot as plt #from functorch import vmap class Loss...
12,316
43.305755
165
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/optimizer_utils.py
import os, sys import logging import torch import torch.optim as optim from torch.optim import lr_scheduler from torch.optim.lr_scheduler import _LRScheduler from torch.optim.lr_scheduler import ReduceLROnPlateau from utils.mod_lbfgs import ModLBFGS class EarlyStopping: """ https://github.com/Bjarten/early-stoppin...
2,787
38.267606
136
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/data_utils.py
""" data loaders """ import re import time import os, sys import logging import glob import torch import random import numpy as np from torch.utils.data import DataLoader, Dataset, TensorDataset from torch.utils.data.distributed import DistributedSampler import torchvision.transforms as transforms from utils.pde_sols...
6,612
48.350746
140
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/mod_lbfgs.py
import torch from functools import reduce from utils.optimizer_base import Optimizer def _cubic_interpolate(x1, f1, g1, x2, f2, g2, bounds=None): # ported from https://github.com/torch/optim/blob/master/polyinterp.lua # Compute bounds of interpolation area if bounds is not None: xmin_bound, xmax_bo...
18,218
36.257669
124
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/optimizer_base.py
from collections import defaultdict, abc as container_abcs import torch from copy import deepcopy from itertools import chain import warnings import functools class _RequiredParameter(object): """Singleton class representing a required parameter for an Optimizer.""" def __repr__(self): return "<requi...
11,818
42.774074
115
py
adaptive-selfsupervision-pinns
adaptive-selfsupervision-pinns-main/utils/pde_sols.py
""" solutions to different PDE systems """ import time import os import numpy as np import scipy as sc import torch import torch.fft import logging import matplotlib.pyplot as plt from scipy.sparse.linalg import LinearOperator from utils.misc_utils import gaussian, poisson_source, diffusion_coef, show, get_diff_tens...
7,599
32.480176
147
py
FewShotDetection
FewShotDetection-master/test.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import _init_paths import os import sys import numpy as np import argparse import time import cv2 import pickle import torch from torch.autograd import Variable from roi_data_layer.roidb import combined_roidb ...
17,250
44.278215
129
py
FewShotDetection
FewShotDetection-master/train.py
import _init_paths import os import sys import numpy as np import argparse import pprint import pdb import time import collections import torch import torch.nn as nn import torch.optim as optim import random from tensorboardX import SummaryWriter import torchvision.transforms as transforms from torch.utils.data.sample...
25,214
42.700173
129
py
FewShotDetection
FewShotDetection-master/lib/roi_data_layer/roibatchLoader.py
"""The data layer used during training to train a Fast R-CNN network. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import torch.utils.data as data from PIL import Image import torch from model.utils.config import cfg from roi_data_layer.minibatch i...
9,043
39.556054
109
py
FewShotDetection
FewShotDetection-master/lib/roi_data_layer/minibatch.py
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Xinlei Chen # -------------------------------------------------------- """Compute minibatch blobs for training a Fast R-CNN ne...
3,033
31.978261
113
py
FewShotDetection
FewShotDetection-master/lib/datasets/metadata.py
# -------------------------------------------------------- # Pytorch Meta R-CNN # Written by Anny Xu, Xiaopeng Yan, based on the code from Jianwei Yang # -------------------------------------------------------- import os import os.path import sys import torch.utils.data as data import cv2 import torch import random imp...
5,159
38.090909
104
py
FewShotDetection
FewShotDetection-master/lib/datasets/metadata_TFA.py
import torch.utils.data as data import cv2 import torch import collections import time import os import numpy as np import json import os.path as osp from model.utils.config import cfg from pycocotools.coco import COCO class MetaDatasetTFA(data.Dataset): def __init__(self, root, image_set, year, img_size, shots=...
6,141
38.625806
112
py
FewShotDetection
FewShotDetection-master/lib/datasets/metadata_3d.py
from __future__ import print_function # -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- import datasets import datasets.o...
6,916
33.758794
106
py
FewShotDetection
FewShotDetection-master/lib/datasets/pascal_voc_rbg.py
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Xinlei Chen # -------------------------------------------------------- from __future__ import absolute_import from __future__ i...
13,812
34.692506
85
py
FewShotDetection
FewShotDetection-master/lib/datasets/custom_metadata.py
import os, sys import numpy as np import pandas as pd import cv2 import collections import random import time import torch import torch.utils.data as data from model.utils.config import cfg import datasets from datasets.imdb import imdb import datasets.custom class MetaDatasetCustom(data.Dataset): def __init__(...
6,426
33.740541
108
py
FewShotDetection
FewShotDetection-master/lib/datasets/metadata_coco.py
# -------------------------------------------------------- # Fast/er R-CNN # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Xinlei Chen # -------------------------------------------------------- from __future__ import absolute_import from __future__ import division from __future...
9,807
36.292776
110
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/build.py
from __future__ import print_function import os import torch from torch.utils.ffi import create_extension #this_file = os.path.dirname(__file__) sources = ['src/roi_crop.c'] headers = ['src/roi_crop.h'] defines = [] with_cuda = False if torch.cuda.is_available(): print('Including CUDA code.') sources += ['sr...
881
22.837838
75
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/functions/gridgen.py
# functions/add.py import torch from torch.autograd import Function import numpy as np class AffineGridGenFunction(Function): def __init__(self, height, width,lr=1): super(AffineGridGenFunction, self).__init__() self.lr = lr self.height, self.width = height, width self.grid = np.ze...
2,233
46.531915
171
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/functions/crop_resize.py
# functions/add.py import torch from torch.autograd import Function from .._ext import roi_crop from cffi import FFI ffi = FFI() class RoICropFunction(Function): def forward(self, input1, input2): self.input1 = input1 self.input2 = input2 self.device_c = ffi.new("int *") output = to...
1,545
39.684211
126
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/functions/roi_crop.py
# functions/add.py import torch from torch.autograd import Function from .._ext import roi_crop import pdb class RoICropFunction(Function): def forward(self, input1, input2): self.input1 = input1.clone() self.input2 = input2.clone() output = input2.new(input2.size()[0], input1.size()[1], in...
1,002
44.590909
122
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/modules/gridgen.py
from torch.nn.modules.module import Module import torch from torch.autograd import Variable import numpy as np from ..functions.gridgen import AffineGridGenFunction import pyximport pyximport.install(setup_args={"include_dirs":np.get_include()}, reload_support=True) class _AffineGridGen(Module): ...
16,532
38.838554
170
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/modules/roi_crop.py
from torch.nn.modules.module import Module from ..functions.roi_crop import RoICropFunction class _RoICrop(Module): def __init__(self, layout = 'BHWD'): super(_RoICrop, self).__init__() def forward(self, input1, input2): return RoICropFunction()(input1, input2)
287
31
48
py
FewShotDetection
FewShotDetection-master/lib/model/roi_crop/_ext/roi_crop/__init__.py
from torch.utils.ffi import _wrap_function from ._roi_crop import lib as _lib, ffi as _ffi __all__ = [] def _import_symbols(locals): for symbol in dir(_lib): fn = getattr(_lib, symbol) if callable(fn): locals[symbol] = _wrap_function(fn, _ffi) else: locals[symbol] =...
382
22.9375
53
py
FewShotDetection
FewShotDetection-master/lib/model/faster_rcnn/faster_rcnn.py
# -------------------------------------------------------- # Pytorch Meta R-CNN # Written by Anny Xu, Xiaopeng Yan, based on the code from Jianwei Yang # -------------------------------------------------------- import random import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import V...
13,518
45.778547
129
py
FewShotDetection
FewShotDetection-master/lib/model/faster_rcnn/resnet.py
# -------------------------------------------------------- # Pytorch Meta R-CNN # Written by Anny Xu, Xiaopeng Yan, based on code from Jianwei Yang # -------------------------------------------------------- from __future__ import absolute_import from __future__ import division from __future__ import print_function fro...
11,588
32.787172
109
py
FewShotDetection
FewShotDetection-master/lib/model/faster_rcnn/vgg16.py
# -------------------------------------------------------- # Tensorflow Faster R-CNN # Licensed under The MIT License [see LICENSE for details] # Written by Xinlei Chen # -------------------------------------------------------- from __future__ import absolute_import from __future__ import division from __future__ impor...
2,018
31.047619
89
py
FewShotDetection
FewShotDetection-master/lib/model/faster_rcnn/trail.py
# -------------------------------------------------------- # Pytorch multi-GPU Faster R-CNN # Licensed under The MIT License [see LICENSE for details] # Written by Jiasen Lu, Jianwei Yang, based on code from Ross Girshick # -------------------------------------------------------- import _init_paths import os import sys...
15,360
37.116625
117
py
FewShotDetection
FewShotDetection-master/lib/model/roi_align/build.py
from __future__ import print_function import os import torch from torch.utils.ffi import create_extension # sources = ['src/roi_align.c'] # headers = ['src/roi_align.h'] sources = [] headers = [] defines = [] with_cuda = False if torch.cuda.is_available(): print('Including CUDA code.') sources += ['src/roi_al...
872
22.594595
75
py
FewShotDetection
FewShotDetection-master/lib/model/roi_align/functions/roi_align.py
import torch from torch.autograd import Function from .._ext import roi_align # TODO use save_for_backward instead class RoIAlignFunction(Function): def __init__(self, aligned_height, aligned_width, spatial_scale): self.aligned_width = int(aligned_width) self.aligned_height = int(aligned_height) ...
1,760
35.6875
102
py
FewShotDetection
FewShotDetection-master/lib/model/roi_align/modules/roi_align.py
from torch.nn.modules.module import Module from torch.nn.functional import avg_pool2d, max_pool2d from ..functions.roi_align import RoIAlignFunction class RoIAlign(Module): def __init__(self, aligned_height, aligned_width, spatial_scale): super(RoIAlign, self).__init__() self.aligned_width = int(...
1,672
37.906977
74
py
FewShotDetection
FewShotDetection-master/lib/model/roi_align/_ext/roi_align/__init__.py
from torch.utils.ffi import _wrap_function from ._roi_align import lib as _lib, ffi as _ffi __all__ = [] def _import_symbols(locals): for symbol in dir(_lib): fn = getattr(_lib, symbol) if callable(fn): locals[symbol] = _wrap_function(fn, _ffi) else: locals[symbol] ...
383
23
53
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/proposal_layer.py
from __future__ import absolute_import # -------------------------------------------------------- # Faster R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Sean Bell # -------------------------------------------------------- # ---------------...
7,001
38.559322
105
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/rpn_region.py
from __future__ import absolute_import import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from model.utils.config import cfg from .proposal_layer_region import _ProposalLayer from .anchor_target_layer import _AnchorTargetLayer from model.utils.net_utils import _smoot...
4,338
37.39823
109
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/proposal_layer_region.py
from __future__ import absolute_import # -------------------------------------------------------- # Faster R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Sean Bell # -------------------------------------------------------- # ---------------...
7,199
39
105
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/bbox_transform.py
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- # -------------------------------------------------------- # Reorganized...
9,288
35.003876
100
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/rpn.py
from __future__ import absolute_import import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from model.utils.config import cfg from .proposal_layer import _ProposalLayer from .anchor_target_layer import _AnchorTargetLayer from model.utils.net_utils import _smooth_l1_lo...
8,248
39.043689
109
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/anchor_target_layer.py
from __future__ import absolute_import # -------------------------------------------------------- # Faster R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Sean Bell # -------------------------------------------------------- # ---------------...
8,917
39.721461
128
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/proposal_target_layer_cascade_region.py
from __future__ import absolute_import # -------------------------------------------------------- # Faster R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Sean Bell # -------------------------------------------------------- # ---------------...
9,977
44.561644
114
py
FewShotDetection
FewShotDetection-master/lib/model/rpn/proposal_target_layer_cascade.py
from __future__ import absolute_import # -------------------------------------------------------- # Faster R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick and Sean Bell # -------------------------------------------------------- # ---------------...
9,308
43.971014
108
py
FewShotDetection
FewShotDetection-master/lib/model/utils/config.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import os.path as osp import numpy as np # `pip install easydict` if you don't have it from easydict import EasyDict as edict __C = edict() # Consumers can get config by: # from fast_rcnn_config im...
14,255
30.964126
91
py
FewShotDetection
FewShotDetection-master/lib/model/utils/net_utils.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import numpy as np import torchvision.models as models from model.utils.config import cfg from model.roi_crop.functions.roi_crop import RoICropFunction import cv2 import pdb import random def save_net(fname, net): ...
8,904
34.763052
110
py
FewShotDetection
FewShotDetection-master/lib/model/roi_pooling/build.py
from __future__ import print_function import os import torch from torch.utils.ffi import create_extension sources = ['src/roi_pooling.c'] headers = ['src/roi_pooling.h'] defines = [] with_cuda = False if torch.cuda.is_available(): print('Including CUDA code.') sources += ['src/roi_pooling_cuda.c'] header...
848
22.583333
75
py
FewShotDetection
FewShotDetection-master/lib/model/roi_pooling/functions/roi_pool.py
import torch from torch.autograd import Function from .._ext import roi_pooling import pdb class RoIPoolFunction(Function): def __init__(ctx, pooled_height, pooled_width, spatial_scale): ctx.pooled_width = pooled_width ctx.pooled_height = pooled_height ctx.spatial_scale = spatial_scale ...
1,773
44.487179
108
py
FewShotDetection
FewShotDetection-master/lib/model/roi_pooling/modules/roi_pool.py
from torch.nn.modules.module import Module from ..functions.roi_pool import RoIPoolFunction class _RoIPooling(Module): def __init__(self, pooled_height, pooled_width, spatial_scale): super(_RoIPooling, self).__init__() self.pooled_width = int(pooled_width) self.pooled_height = int(pooled_...
524
34
105
py
FewShotDetection
FewShotDetection-master/lib/model/roi_pooling/_ext/roi_pooling/__init__.py
from torch.utils.ffi import _wrap_function from ._roi_pooling import lib as _lib, ffi as _ffi __all__ = [] def _import_symbols(locals): for symbol in dir(_lib): fn = getattr(_lib, symbol) if callable(fn): locals[symbol] = _wrap_function(fn, _ffi) else: locals[symbol...
385
23.125
53
py
FewShotDetection
FewShotDetection-master/lib/model/nms/nms_wrapper.py
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- import torch from model.utils.config import cfg if torch.cuda.is_availab...
757
33.454545
81
py
FewShotDetection
FewShotDetection-master/lib/model/nms/nms_gpu.py
from __future__ import absolute_import import torch import numpy as np from ._ext import nms import pdb def nms_gpu(dets, thresh): keep = dets.new(dets.size(0), 1).zero_().int() num_out = dets.new(1).zero_().int() nms.nms_cuda(keep, dets, num_out, thresh) keep = keep[:num_out[0]] return keep
299
22.076923
47
py
FewShotDetection
FewShotDetection-master/lib/model/nms/nms_cpu.py
from __future__ import absolute_import import numpy as np import torch def nms_cpu(dets, thresh): dets = dets.cpu().numpy() x1 = dets[:, 0] y1 = dets[:, 1] x2 = dets[:, 2] y2 = dets[:, 3] scores = dets[:, 4] areas = (x2 - x1 + 1) * (y2 - y1 + 1) order = scores.argsort()[::-1] kee...
5,777
27.185366
93
py
FewShotDetection
FewShotDetection-master/lib/model/nms/build.py
from __future__ import print_function import os import torch from torch.utils.ffi import create_extension #this_file = os.path.dirname(__file__) sources = [] headers = [] defines = [] with_cuda = False if torch.cuda.is_available(): print('Including CUDA code.') sources += ['src/nms_cuda.c'] headers += ['...
850
21.394737
75
py
FewShotDetection
FewShotDetection-master/lib/model/nms/_ext/nms/__init__.py
from torch.utils.ffi import _wrap_function from ._nms import lib as _lib, ffi as _ffi __all__ = [] def _import_symbols(locals): for symbol in dir(_lib): fn = getattr(_lib, symbol) if callable(fn): locals[symbol] = _wrap_function(fn, _ffi) else: locals[symbol] = fn ...
377
22.625
53
py
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/run_re.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. 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 cop...
28,742
42.748858
150
py