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
ELLE
ELLE-main/fairseq_ELLE/fairseq/optim/lr_scheduler/tri_stage_lr_scheduler.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. from . import FairseqLRScheduler, register_lr_scheduler import math @register_lr_scheduler('tri_stage') class TriStageLRSchedule(FairseqLRSc...
4,993
30.018634
84
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/optim/lr_scheduler/reduce_lr_on_plateau.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 torch.optim.lr_scheduler from . import FairseqLRScheduler, register_lr_scheduler @register_lr_scheduler('reduce_lr_on_plateau') clas...
4,411
43.565657
109
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/optim/lr_scheduler/cosine_lr_scheduler.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 math from . import FairseqLRScheduler, register_lr_scheduler @register_lr_scheduler('cosine') class CosineSchedule(FairseqLRSchedule...
4,752
38.941176
105
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/language_pair_dataset.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 numpy as np import torch from . import data_utils, FairseqDataset def collate( samples, pad_idx, eos_idx, left_pad_source=True, ...
12,245
41.373702
107
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/token_block_dataset.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 numpy as np import torch from fairseq.data import FairseqDataset, plasma_utils class TokenBlockDataset(FairseqDataset): """Break...
6,139
34.906433
96
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/subsample_dataset.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 numpy as np from . import BaseWrapperDataset class SubsampleDataset(BaseWrapperDataset): """Subsamples a given dataset by a spec...
2,042
29.492537
101
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/prepend_dataset.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 numpy as np import torch from . import BaseWrapperDataset class PrependDataset(BaseWrapperDataset): def __init__(self, dataset, ...
953
31.896552
83
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/base_wrapper_dataset.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. from torch.utils.data.dataloader import default_collate from . import FairseqDataset class BaseWrapperDataset(FairseqDataset): def __i...
1,352
24.528302
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/raw_label_dataset.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 torch from . import FairseqDataset class RawLabelDataset(FairseqDataset): def __init__(self, labels): super().__init__(...
547
20.92
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/resampling_dataset.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 numpy as np from . import BaseWrapperDataset, plasma_utils class ResamplingDataset(BaseWrapperDataset): """Randomly samples from...
4,096
30.274809
78
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/dictionary.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. from collections import Counter from multiprocessing import Pool import os import torch from fairseq.tokenizer import tokenize_line from fai...
10,926
32.621538
109
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/append_token_dataset.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 numpy as np import torch from . import BaseWrapperDataset class AppendTokenDataset(BaseWrapperDataset): def __init__(self, data...
1,066
23.813953
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/mask_tokens_dataset.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. from functools import lru_cache import numpy as np import torch from fairseq.data import data_utils, Dictionary from . import BaseWrapperDa...
6,814
38.393064
87
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/concat_dataset.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 bisect import numpy as np from torch.utils.data.dataloader import default_collate from . import FairseqDataset class ConcatDataset(...
3,717
34.075472
86
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/nested_dictionary_dataset.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. from collections import OrderedDict import torch from torch.utils.data.dataloader import default_collate from . import FairseqDataset def ...
3,776
31.282051
86
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/lm_context_window_dataset.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 numpy as np import torch from fairseq.data.monolingual_dataset import MonolingualDataset from . import FairseqDataset class LMConte...
2,910
35.848101
90
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/colorize_dataset.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 torch from . import BaseWrapperDataset class ColorizeDataset(BaseWrapperDataset): """ Adds 'colors' property to net input that i...
844
32.8
113
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/iterators.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 itertools import math import os import numpy as np import torch from . import data_utils class CountingIterator(object): """Wra...
11,820
32.392655
91
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/backtranslation_dataset.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 torch from fairseq import utils from . import FairseqDataset def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True)...
6,235
36.566265
93
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/monolingual_dataset.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 numpy as np import torch from . import data_utils, FairseqDataset def collate(samples, pad_idx, eos_idx): if len(samples) == 0: ...
7,859
36.251185
117
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/roll_dataset.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 torch from . import BaseWrapperDataset class RollDataset(BaseWrapperDataset): def __init__(self, dataset, shifts): supe...
486
23.35
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/replace_dataset.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. from . import BaseWrapperDataset class ReplaceDataset(BaseWrapperDataset): """Replaces tokens found in the dataset by a specified replac...
1,394
36.702703
117
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/id_dataset.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 torch from . import FairseqDataset class IdDataset(FairseqDataset): def __getitem__(self, index): return index def...
424
19.238095
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/indexed_dataset.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. from functools import lru_cache import os import shutil import struct import numpy as np import torch from . import FairseqDataset def __b...
16,026
29.585878
105
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/denoising_dataset.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 numpy as np import torch import math from . import data_utils, FairseqDataset def collate( samples, pad_idx, eos_idx, ...
14,119
35.580311
118
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/prepend_token_dataset.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 numpy as np import torch from . import BaseWrapperDataset class PrependTokenDataset(BaseWrapperDataset): def __init__(self, dat...
1,431
26.018868
66
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/numel_dataset.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 numpy as np import torch from . import BaseWrapperDataset class NumelDataset(BaseWrapperDataset): def __init__(self, dataset, r...
787
22.878788
65
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/noising.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 torch import numpy as np from fairseq.data import data_utils class WordNoising(object): """Generate a noisy version of a sentenc...
12,177
37.537975
110
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/concat_sentences_dataset.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 torch from . import FairseqDataset class ConcatSentencesDataset(FairseqDataset): def __init__(self, *datasets): super()...
1,573
26.614035
75
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/fairseq_dataset.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 numpy as np import torch.utils.data class EpochListening: """Mixin for receiving updates whenever the epoch increments.""" de...
2,202
29.178082
80
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/transform_eos_dataset.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 torch from . import FairseqDataset class TransformEosDataset(FairseqDataset): """A :class:`~fairseq.data.FairseqDataset` wrapper...
4,300
35.449153
88
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/audio/raw_audio_dataset.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 os import numpy as np import sys import torch import torch.nn.functional as F from .. import FairseqDataset class RawAudioDataset(...
4,571
28.121019
84
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/encoders/utils.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 torch from fairseq.data import encoders def get_whole_word_mask(args, dictionary): bpe = encoders.build_bpe(args) if bpe is n...
907
30.310345
67
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/encoders/hf_bert_bpe.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. from fairseq.data.encoders import register_bpe @register_bpe('bert') class BertBPE(object): @staticmethod def add_args(parser): ...
1,799
33.615385
90
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/legacy/block_pair_dataset.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 math import numpy as np import torch from fairseq.data import FairseqDataset class BlockPairDataset(FairseqDataset): """Break a...
12,878
40.146965
99
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/data/legacy/masked_lm_dataset.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 math import numpy as np import torch from typing import Dict, List, Tuple from fairseq.data import FairseqDataset, data_utils from ...
12,468
37.603715
83
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/continual_lm.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 os import torch from fairseq import utils from fairseq.data import ( data_utils, Dictionary, MonolingualDataset, Toke...
14,067
37.437158
145
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/language_modeling.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 os import torch from fairseq import utils from fairseq.data import ( data_utils, Dictionary, MonolingualDataset, Toke...
9,239
37.181818
98
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/continual_KI.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 os import numpy as np import torch import fairseq.utils from fairseq.data import ( data_utils, Dictionary, IdDataset, ...
15,616
39.25
145
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/clmb_task.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 os import numpy as np from fairseq.data import ( data_utils, Dictionary, IdDataset, MaskTokensDataset, NestedDict...
8,792
38.78733
98
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/multilingual_masked_lm.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 os import numpy as np import torch from fairseq.data import ( data_utils, Dictionary, encoders, ConcatDataset, Id...
12,280
39.531353
98
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/continual_KI_no_replay.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 os import numpy as np import torch from fairseq.data import ( data_utils, Dictionary, IdDataset, MaskTokensDataset, ...
13,724
39.014577
136
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/multilingual_translation.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. from collections import OrderedDict import os import torch from fairseq import options, utils from fairseq.data import ( Dictionary, ...
16,648
43.755376
116
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/translation_lev.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 torch from fairseq.utils import new_arange from fairseq.tasks import register_task from fairseq.tasks.translation import TranslationTa...
6,412
39.847134
87
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/translation_moe.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 torch from fairseq import modules, utils from fairseq.tasks import register_task from fairseq.tasks.translation import TranslationTask...
8,872
41.252381
110
py
ELLE
ELLE-main/fairseq_ELLE/fairseq/tasks/fairseq_task.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 numpy as np import torch from fairseq import tokenizer from fairseq.data import ( data_utils, FairseqDataset, iterators, ...
11,175
37.143345
104
py
ELLE
ELLE-main/fairseq_ELLE/docs/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # fairseq documentation build configuration file, created by # sphinx-quickstart on Fri Aug 17 21:45:30 2018. # # 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 # au...
4,235
30.849624
80
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/setup.py
#!/usr/bin/env python3 # 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 os from setuptools import setup, find_packages, Extension import sys if sys.version_info < (3, 5): sys.exi...
4,357
25.736196
92
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/generate.py
#!/usr/bin/env python3 -u # 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. """ Translate pre-processed data with a trained model. """ import torch from fairseq import bleu, checkpoint_utils,...
8,179
39.098039
110
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/train_copy2.py
#!/usr/bin/env python3 -u # 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. """ Train a new model on one or across multiple GPUs. """ import collections import math import random import os imp...
31,610
41.260695
216
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/eval_lm.py
#!/usr/bin/env python3 -u # 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. """ Evaluate the perplexity of a trained language model. """ import numpy as np import torch from fairseq import c...
8,132
34.671053
118
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/interactive.py
#!/usr/bin/env python3 -u # 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. """ Translate raw text with a trained model. Batches data on-the-fly. """ from collections import namedtuple import ...
6,445
32.05641
103
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/eval.py
#!/usr/bin/env python3 -u # 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. """ Train a new model on one or across multiple GPUs. """ import collections import math import random import numpy...
14,048
37.280654
104
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/train_copy.py
#!/usr/bin/env python3 -u # 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. """ Train a new model on one or across multiple GPUs. """ import collections import math import random import os imp...
33,886
41.14801
179
py
ELLE
ELLE-main/fairseq_ELLE/fairseq_cli/train.py
#!/usr/bin/env python3 -u # 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. """ Train a new model on one or across multiple GPUs. """ import collections import math import random import os imp...
33,608
41.06383
179
py
islplot
islplot-master/islplot/plotter3d.py
from islplot.support import * # color scheme # http://colorschemedesigner.com/#01400w0w0w0w0 colors = [] # red colors.append({'base': '0xff0700', 'light': '0xff7673', 'dark': '0xA60400'}) # blue colors.append({'base': '0x3B14Af', 'light': '0x886E7D'}) # yellow colors.append({'base': '0xFFD500', 'light': '0xFFE873'...
839,440
21.081836
237
py
islplot
islplot-master/doc/conf.py
# -*- coding: utf-8 -*- # # islplot documentation build configuration file, created by # sphinx-quickstart on Sat Jan 4 18:35:53 2014. # # 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...
8,022
31.481781
169
py
timematch
timematch-main/dataset.py
from collections import defaultdict import datetime as dt import os import pickle as pkl from typing import List import numpy as np import torch from torch.utils import data from torch.utils.data import ConcatDataset, DataLoader, Subset from torchvision.transforms import transforms import zarr from transforms import ...
14,500
32.645012
118
py
timematch
timematch-main/timematch.py
from torch.utils.data.sampler import WeightedRandomSampler import sklearn.metrics from collections import Counter from copy import deepcopy import numpy as np import torch import torch.nn.functional as F from torch.utils import data from torchvision import transforms from tqdm import tqdm from dataset import PixelSet...
16,785
42.942408
202
py
timematch
timematch-main/evaluation.py
import os import numpy as np import torch import torch.backends.cudnn import torch.nn.functional as F from tqdm import tqdm import sklearn.metrics from utils.train_utils import AverageMeter, to_cuda def validation(best_f1, best_model_path, config, criterion, device, epoch, model, val_loader, writer, temporal_shift=No...
3,103
44.647059
168
py
timematch
timematch-main/train.py
import argparse from collections import defaultdict from copy import deepcopy from distutils.util import strtobool import json import os import pickle as pkl import random import numpy as np import torch import torch.backends.cudnn from torch.utils.tensorboard import SummaryWriter from torchvision.transforms import tr...
20,486
52.07513
145
py
timematch
timematch-main/transforms.py
import random import numpy as np import torch class Identity(object): def __call__(self, sample): return sample class RandomSamplePixels(object): """Randomly draw num_pixels from the available pixels in sample. If the total number of pixels is less than num_pixels, one arbitrary pixel is repeat...
4,239
32.385827
119
py
timematch
timematch-main/models/stclassifier.py
from copy import deepcopy import torch.nn as nn from models.competings import GRU, TempConv from models.decoder import get_decoder from models.ltae import LTAE from models.pse import PixelSetEncoder from models.tae import TemporalAttentionEncoder class PseLTae(nn.Module): """ Pixel-Set encoder + Lightweight...
10,050
30.117647
93
py
timematch
timematch-main/models/ltae.py
""" Lightweight Temporal Attention Encoder module We modify the original LTAE to support variable time series lengths and domain-specific batch normalization Credits: The module is heavily inspired by the works of Vaswani et al. on self-attention and their pytorch implementation of the Transformer served as code base ...
5,128
38.75969
152
py
timematch
timematch-main/models/layers.py
import math import torch import torch.nn as nn class LinearLayer(nn.Module): def __init__(self, in_dim, out_dim): super().__init__() self.linear = nn.Linear(in_dim, out_dim, bias=False) self.norm = nn.BatchNorm1d(out_dim) self.activation = nn.ReLU() def forward(self, x): ...
1,112
33.78125
90
py
timematch
timematch-main/models/pse.py
""" Pixel-Set encoder module author: Vivien Sainte Fare Garnot """ import torch import torch.nn as nn import torch.nn.functional as F import copy from models.layers import LinearLayer class PixelSetEncoder(nn.Module): def __init__( self, input_dim, mlp1=[10, 32, 64], pooling="mea...
4,294
29.899281
118
py
timematch
timematch-main/models/decoder.py
import torch.nn as nn from models.layers import LinearLayer def get_decoder(n_neurons, n_classes): """Returns an MLP with the layer widths specified in n_neurons. Every linear layer but the last one is followed by BatchNorm + ReLu args: n_neurons (list): List of int that specifies the width and l...
605
30.894737
85
py
timematch
timematch-main/models/competings.py
import torch.nn as nn from models.tae import get_positional_encoding import copy class GRU(nn.Module): """ Gated Recurrent Unit """ def __init__(self, in_channels=128, hidden_dim=128, max_position=365, max_temporal_shift=100): super(GRU, self).__init__() self.name = 'GRU_h{}'.format(...
2,650
32.556962
99
py
timematch
timematch-main/models/tae.py
""" Temporal Attention Encoder module Credits: The module is heavily inspired by the works of Vaswani et al. on self-attention and their pytorch implementation of the Transformer served as code base for the present script. paper: https://arxiv.org/abs/1706.03762 code: github.com/jadore801120/attention-is-all-you-need...
6,252
35.354651
116
py
timematch
timematch-main/competitors/mmd/kernels.py
from typing import Optional import torch import torch.nn as nn __all__ = ['GaussianKernel'] class GaussianKernel(nn.Module): r"""Gaussian Kernel Matrix Gaussian Kernel k is defined by .. math:: k(x_1, x_2) = \exp \left( - \dfrac{\| x_1 - x_2 \|^2}{2\sigma^2} \right) where :math:`x_1, x_2 ...
2,312
38.87931
139
py
timematch
timematch-main/competitors/mmd/dan.py
from typing import Optional, Sequence import torch import torch.nn as nn __all__ = ['MultipleKernelMaximumMeanDiscrepancy'] class MultipleKernelMaximumMeanDiscrepancy(nn.Module): r"""The Multiple Kernel Maximum Mean Discrepancy (MK-MMD) used in `Learning Transferable Features with Deep Adaptation Networks (...
4,968
42.587719
115
py
timematch
timematch-main/competitors/mmd/train_mmd.py
''' Re-implementation of MMD loss (DAN) from https://github.com/thuml/Transfer-Learning-Library/blob/master/examples/domain_adaptation/classification/dan.py ''' import torch import torch.nn as nn from torch.optim.lr_scheduler import LambdaLR from torch.optim.sgd import SGD from torchvision import transforms from tqdm i...
5,631
38.384615
152
py
timematch
timematch-main/competitors/jumbot/jumbot.py
""" Dependances : - python (3.8.0) - numpy (1.19.2) - torch (1.7.1) - POT (0.7.0) - Cuda command: python3 train.py """ import numpy as np import ot import torch import torch.nn as nn import torch.nn.functional as F from torch.optim.lr_scheduler import LambdaLR from torch.optim.sgd import SGD from torch.utils import...
9,207
34.145038
139
py
timematch
timematch-main/competitors/dann/dann.py
""" Re-implementation of DANN from https://github.com/thuml/Transfer-Learning-Library """ import torch import torch.nn as nn from torch.optim.lr_scheduler import LambdaLR from torch.optim.sgd import SGD from torchvision import transforms from tqdm import tqdm from dataset import PixelSetData from evaluation import val...
21,427
39.737643
171
py
timematch
timematch-main/competitors/dann/grl.py
from typing import Optional, Any, Tuple import numpy as np import torch.nn as nn from torch.autograd import Function import torch class GradientReverseFunction(Function): @staticmethod def forward(ctx: Any, input: torch.Tensor, coeff: Optional[float] = 1.) -> torch.Tensor: ctx.coeff = coeff o...
2,645
32.923077
119
py
timematch
timematch-main/competitors/alda/train_alda.py
from tqdm import tqdm import torch import torch.nn as nn import competitors.alda.loss as loss from dataset import PixelSetData from evaluation import validation from transforms import Normalize, RandomSamplePixels, RandomSampleTimeSteps, ToTensor, RandomTemporalShift, Identity from utils.metrics import accuracy from ut...
8,566
32.728346
127
py
timematch
timematch-main/competitors/alda/loss.py
import numpy as np import torch import torch.nn as nn def create_matrix(n): """ :param n: matrix size (class num) :return a matrix with torch.tensor type: for example n=3: 1 -1/2 -1/2 -1/2 1 -1/2 -1/2 -1/2 1 """ a = np.zeros((n,n), dtype=np.float32) for i in range...
3,238
42.77027
146
py
timematch
timematch-main/utils/train_utils.py
import torch import argparse FALSY_STRINGS = {"off", "false", "0"} TRUTHY_STRINGS = {"on", "true", "1"} def to_cuda(sample, device, non_blocking=True): pixels = sample['pixels'].cuda(device=device, non_blocking=non_blocking) valid_pixels = sample['valid_pixels'].cuda(device=device, non_blocking=non_blocking)...
1,979
28.117647
99
py
timematch
timematch-main/utils/focal_loss.py
''' Implementation of Focal Loss. Reference: [1] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollar, Focal loss for dense object detection. arXiv preprint arXiv:1708.02002, 2017. ''' import torch import torch.nn as nn import torch.nn.functional as F class FocalLoss(nn.Module): def __init__(self, gamma=0,...
843
28.103448
99
py
timematch
timematch-main/utils/metrics.py
import torch import numpy as np from tabulate import tabulate @torch.no_grad() def accuracy(outputs, targets): preds = outputs.argmax(dim=1) return preds.eq(targets).float().mean().item() def f1_score(confusion_matrix, reduce_mean=True): f1_scores = [] for index in range(confusion_matrix.shape[0]): ...
5,384
37.464286
169
py
timematch
timematch-main/utils/samplers.py
import torch class VariableSequenceLengthBatchSampler(torch.utils.data.Sampler): """ Outputs batches of patch indices where all patches have the same sequence length, so that they can be torch.stack'ed. """ def __init__(self, data_source, batch_size): self.data_source = data_source ...
1,365
39.176471
117
py
BPC-Divergences
BPC-Divergences-main/reparam_module.py
import torch import torch.nn as nn import warnings import types from collections import namedtuple from contextlib import contextmanager class ReparamModule(nn.Module): def _get_module_from_name(self, mn): if mn == '': return self m = self for p in mn.split('.'): m ...
6,718
41.257862
112
py
BPC-Divergences
BPC-Divergences-main/utils.py
# adapted from # https://github.com/VICO-UoE/DatasetCondensation import time import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import os import tqdm from torch.utils.data import Dataset from torchvision import datasets, transforms from scipy.ndimage.interpolation import rotate as sc...
27,247
42.666667
194
py
BPC-Divergences
BPC-Divergences-main/networks.py
import torch.nn as nn import torch.nn.functional as F import torch # Acknowledgement to # https://github.com/kuangliu/pytorch-cifar, # https://github.com/BIGBALLON/CIFAR-ZOO, # adapted from # https://github.com/VICO-UoE/DatasetCondensation ''' MLP ''' class MLP(nn.Module): def __init__(self, channel, num_classes)...
22,466
40.837989
170
py
BPC-Divergences
BPC-Divergences-main/buffer.py
import os import argparse import torch import torch.nn as nn from tqdm import tqdm from utils import get_dataset, get_network, get_daparam,\ TensorDataset, epoch, ParamDiffAug import copy import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) def main(args): args.dsa = True if...
6,272
43.176056
130
py
BPC-Divergences
BPC-Divergences-main/evaluation.py
import torch import torch.nn as nn from reparam_module import ReparamModule import numpy as np from utils import DiffAugment import torch.nn.functional as F def evaluate_bpc(method, net, images_train, labels_train, test_loader, args, logger, testaug=False): net = net.to(args.device) images_train = images...
6,685
39.035928
142
py
BPC-Divergences
BPC-Divergences-main/train.py
import os from pickletools import optimize import time import argparse import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torchvision.utils import save_image from tqdm import tqdm import copy import random from utils import get_dataset, get_network, get_eval_pool, get_time, DiffA...
20,750
46.376712
154
py
DiffDVR
DiffDVR-master/pytests/tests/vis_gui.py
import os import sys sys.path.append(os.getcwd()) import numpy as np import torch import os import time import h5py import collections import matplotlib import matplotlib.pyplot as plt from abc import ABC, abstractmethod # import PyQtChart from PyQt5.QtChart import * from PyQt5.QtGui import * from PyQt5.QtCore impor...
32,594
40.949807
138
py
DiffDVR
DiffDVR-master/pytests/tests/volume/train_volume.py
""" Large hyperparameter training session """ import sys import os sys.path.insert(0, os.getcwd()) import numpy as np import torch import torch.nn.functional as F import os import tqdm import time import h5py import argparse import json from collections import defaultdict import subprocess import contextlib @context...
32,479
49.356589
139
py
DiffDVR
DiffDVR-master/pytests/tests/volume/test_volume_optimization2.py
import numpy as np import torch import torchvision import matplotlib.pyplot as plt from diffdvr import Renderer, VolumeDensities, TfPiecewiseLinear, CameraOnASphere, \ SmoothnessPrior, toCHW import pyrenderer def optimize(): np.random.seed(42) torch.random.manual_seed(42) pyrenderer.set_cuda_sync_mode(False)...
7,526
35.897059
142
py
DiffDVR
DiffDVR-master/pytests/tests/volume/test_volume_optimization.py
import numpy as np import torch import sys import os import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec import matplotlib.animation import tqdm # load pyrenderer import diffdvr import pyrenderer if __name__=='__main__': print(pyrenderer.__doc__) print("Create Marschner Lobb") volume = pyr...
7,930
33.633188
112
py
DiffDVR
DiffDVR-master/pytests/tests/volume/compare_reconstruction.py
""" Absorption-only Reconstruction, comparison with other methods (ASTRA + Mitsuba) Command lines: Skull: python3 compare_reconstruction.py results/volume/density/skull7absorption config-files/skull7absorption.json --views 64 --diffdvrL1 --visCropSlice 73:2:64:96 --visCropRendering 62:250:192:128 --visRenderingDiffSca...
34,505
44.164921
305
py
DiffDVR
DiffDVR-master/pytests/tests/volume/normalize_dataset.py
""" Normalizes a volume from [minDensity,maxDensity] to [0,1] """ import sys import os sys.path.insert(0, os.getcwd()) import argparse import numpy as np import torch.nn.functional as F import torch from diffdvr import Renderer, CameraOnASphere, Settings, setup_default_settings, \ renderer_dtype_torch, renderer_...
3,245
36.310345
122
py
DiffDVR
DiffDVR-master/pytests/tests/volume/vis_volume.py
import os import sys sys.path.append(os.getcwd()) import h5py import tests.vis_gui import torch import numpy as np import skimage.transform import pyrenderer class UIVolume(tests.vis_gui.UI): def __init__(self, folder, preshaded_to_density): self._preshaded_to_density = preshaded_to_density if ...
9,452
45.79703
119
py
DiffDVR
DiffDVR-master/pytests/tests/volume/test_volume_optimization3.py
import numpy as np import torch import torchvision import matplotlib.pyplot as plt from diffdvr import Renderer, VolumePreshaded, TfPiecewiseLinear, CameraOnASphere, \ SmoothnessPrior, toCHW, renderer_dtype_torch import pyrenderer def optimize(): np.random.seed(42) torch.random.manual_seed(42) pyren...
8,046
38.446078
114
py
DiffDVR
DiffDVR-master/pytests/tests/volume/export_trained_volumes.py
""" Export script for the reconstructions from train_volume.py, which are normally visualized by vis_volume.py """ import os import sys sys.path.append(os.getcwd()) import h5py import tests.vis_gui import torch import numpy as np import skimage.transform import imageio from typing import List from collections import...
11,701
43.158491
134
py
DiffDVR
DiffDVR-master/pytests/tests/volume/preshaded_to_density.py
import numpy as np import torch import torch.nn.functional as F import os import sys import tqdm import time import h5py import argparse import json import subprocess from collections import defaultdict sys.path.append(os.getcwd()) from diffdvr import renderer_dtype_torch, renderer_dtype_np, \ VolumeDensities, Smo...
15,721
45.931343
119
py
DiffDVR
DiffDVR-master/pytests/tests/volume/compute_image_statistics.py
import sys import os import numpy as np import torch import torch.nn.functional as F import imageio from typing import List from losses.lossbuilder import LossBuilder def toCHW(bhwc : torch.Tensor): """ Converts a tensor in BxHxWxC to BxCxHxW """ return bhwc.movedim((0,1,2,3), (0,2,3,1)) class SSIM(): d...
1,838
26.863636
85
py
DiffDVR
DiffDVR-master/pytests/tests/volume/mitsuba/optimize_rb2.py
import os from os.path import join, dirname, realpath import pytest import time import enoki as ek import mitsuba from mitsuba.core import Bitmap, Struct, Thread, EColorMode from mitsuba.optix import OptiXRenderer from mitsuba.render.autodiff import get_differentiable_parameters, Adam, SGD import numpy as np from ren...
8,777
38.013333
98
py
DiffDVR
DiffDVR-master/pytests/tests/stepsize/train_stepsize.py
import sys import os sys.path.append(os.getcwd()) import numpy as np import torch import torch.nn.functional as F import os import tqdm import time import h5py import argparse import json from collections import defaultdict import subprocess from diffdvr import Renderer, CameraOnASphere, Settings, setup_default_sett...
13,007
47.719101
150
py