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
wenet
wenet-main/wenet/efficient_conformer/encoder.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # 2022 58.com(Wuba) Inc AI Lab. # # 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 c...
25,877
44.4
88
py
wenet
wenet-main/wenet/efficient_conformer/convolution.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # 2022 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
5,749
36.096774
78
py
wenet
wenet-main/wenet/efficient_conformer/attention.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # 2022 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the ...
10,873
42.670683
88
py
wenet
wenet-main/wenet/squeezeformer/conv2d.py
# Copyright (c) 2022 Ximalaya Inc. (authors: Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
2,570
37.373134
84
py
wenet
wenet-main/wenet/squeezeformer/encoder_layer.py
# Copyright (c) 2022 Ximalaya Inc. (authors: Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
4,712
37.631148
80
py
wenet
wenet-main/wenet/squeezeformer/positionwise_feed_forward.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # 2022 Ximalaya Inc (Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http:...
2,988
36.3625
74
py
wenet
wenet-main/wenet/squeezeformer/subsampling.py
# Copyright (c) 2022 Ximalaya Inc. (authors: Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
10,976
35.959596
82
py
wenet
wenet-main/wenet/squeezeformer/encoder.py
# Copyright (c) 2022 Ximalaya Inc. (authors: Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
21,841
45.080169
85
py
wenet
wenet-main/wenet/squeezeformer/convolution.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # 2022 Ximalaya Inc. (authors: Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.a...
6,541
36.815029
83
py
wenet
wenet-main/wenet/squeezeformer/attention.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # 2022 Ximalaya Inc. (Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with ...
10,291
45.152466
80
py
wenet
wenet-main/wenet/cif/predictor.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
10,356
42.154167
80
py
wenet
wenet-main/wenet/ssl/bestrq/bestqr_model.py
import math from typing import Optional, Tuple import torch from wenet.ssl.bestrq.mask import compute_mask_indices_v2 from wenet.utils.mask import make_pad_mask from wenet.transformer.attention import RelPositionMultiHeadedAttention from wenet.transformer.encoder_layer import ConformerEncoderLayer def quantize_vecto...
10,662
36.946619
79
py
wenet
wenet-main/wenet/ssl/bestrq/mask.py
import torch import numpy as np def _sampler(pdf: torch.Tensor, num_samples: int, device=torch.device('cpu')) -> torch.Tensor: size = pdf.size() z = -torch.log(torch.rand(size, device=device)) _, indices = torch.topk(pdf + z, num_samples) return indices def compute_mask_indices( ...
5,780
35.13125
79
py
wenet
wenet-main/wenet/utils/checkpoint.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
3,737
33.934579
78
py
wenet
wenet-main/wenet/utils/ctc_util.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
3,177
36.833333
85
py
wenet
wenet-main/wenet/utils/executor.py
# Copyright (c) 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed...
10,151
48.521951
150
py
wenet
wenet-main/wenet/utils/scheduler.py
# Copyright (c) 2020 Mobvoi Inc (Binbin Zhang) # 2022 Ximalaya Inc (Yuguang Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
23,578
34.297904
80
py
wenet
wenet-main/wenet/utils/common.py
# Copyright (c) 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed...
7,880
29.546512
79
py
wenet
wenet-main/wenet/utils/init_model.py
# Copyright (c) 2022 Binbin Zhang (binbzha@qq.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
6,002
45.898438
79
py
wenet
wenet-main/wenet/utils/mask.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
10,542
34.26087
78
py
wenet
wenet-main/wenet/transformer/embedding.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
6,177
36.90184
79
py
wenet
wenet-main/wenet/transformer/encoder_layer.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
9,594
39.146444
79
py
wenet
wenet-main/wenet/transformer/label_smoothing_loss.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
3,459
34.670103
77
py
wenet
wenet-main/wenet/transformer/positionwise_feed_forward.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
1,887
33.962963
74
py
wenet
wenet-main/wenet/transformer/ctc.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
3,002
35.180723
77
py
wenet
wenet-main/wenet/transformer/subsampling.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
8,265
33.298755
74
py
wenet
wenet-main/wenet/transformer/encoder.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
20,080
43.525499
82
py
wenet
wenet-main/wenet/transformer/convolution.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
5,185
34.765517
78
py
wenet
wenet-main/wenet/transformer/cmvn.py
# Copyright (c) 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed...
1,487
30.659574
74
py
wenet
wenet-main/wenet/transformer/decoder.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
12,583
41.37037
83
py
wenet
wenet-main/wenet/transformer/swish.py
# Copyright (c) 2020 Johns Hopkins University (Shinji Watanabe) # 2020 Northwestern Polytechnical University (Pengcheng Guo) # 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License....
1,003
36.185185
74
py
wenet
wenet-main/wenet/transformer/attention.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the Licens...
14,071
43.958466
80
py
wenet
wenet-main/wenet/transformer/decoder_layer.py
# Copyright (c) 2019 Shigeki Karita # 2020 Mobvoi Inc (Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
4,807
35.150376
79
py
wenet
wenet-main/wenet/transformer/asr_model.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
41,398
42.079084
87
py
wenet
wenet-main/wenet/branchformer/encoder_layer.py
# Copyright (c) 2022 Yifan Peng (Carnegie Mellon University) # 2023 Voicecomm Inc (Kai Li) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/L...
9,799
40.176471
86
py
wenet
wenet-main/wenet/branchformer/encoder.py
# Copyright (c) 2022 Yifan Peng (Carnegie Mellon University) # 2023 Voicecomm Inc (Kai Li) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/L...
16,358
41.162371
83
py
wenet
wenet-main/wenet/branchformer/cgmlp.py
# Copyright (c) 2022 Yifan Peng (Carnegie Mellon University) # 2023 Voicecomm Inc (Kai Li) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/L...
6,397
31.810256
82
py
simple-dftd3
simple-dftd3-main/doc/conf.py
import os import sys sys.path.insert(0, os.path.join(os.path.abspath(".."), "python")) import dftd3 project = "s-dftd3" author = "Sebastian Ehlert" copyright = f"2019-2022, {author}" version = dftd3.__version__ release = version extensions = [ "sphinx_design", "sphinx_copybutton", "sphinx.ext.autosumma...
1,091
21.75
80
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/clients.py
from __future__ import print_function from copy import deepcopy from collections import deque import torch import torch.nn.functional as F import logging from utils import utils class Client(): def __init__(self, cid, model, dataLoader, optimizer, criterion=F.nll_loss, device='cpu', inner_epochs=1): sel...
4,847
37.47619
110
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/_main.py
from __future__ import print_function import torch import torch.nn.functional as F import torch.optim as optim from tensorboardX import SummaryWriter import os import logging from datetime import datetime from clients_attackers import * from server import Server def main(args): log_dir = f'logfiles/{args.AR}/{...
10,913
42.309524
156
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/dataloader.py
from __future__ import print_function import numpy as np import torch from collections import defaultdict class Partition(torch.utils.data.Dataset): """ Dataset-like object, but only access a subset of it. """ def __init__(self, data, index): self.data = data self.index = index self.c...
5,866
38.113333
161
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/server.py
from __future__ import print_function from copy import deepcopy import torch import torch.nn.functional as F import logging from datetime import datetime import numpy as np from sklearn.cluster import KMeans, AgglomerativeClustering, DBSCAN from collections import defaultdict, Counter from utils import utils from ut...
32,220
43.01776
139
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/clients_attackers.py
from __future__ import print_function import torch import torch.nn.functional as F import logging from utils import utils from utils.backdoor_semantic_utils import SemanticBackdoor_Utils from utils.backdoor_utils import Backdoor_Utils from clients import * from utils.blur_images import GaussianSmoothing class Unreli...
12,133
45.312977
185
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/utils/blur_images.py
import math import numbers import torch from torch import nn from torch.nn import functional as F # Thanks to: Adrian Sahlman #https://discuss.pytorch.org/t/is-there-anyway-to-do-gaussian-filtering-for-an-image-2d-3d-in-pytorch/12351/9 class GaussianSmoothing(nn.Module): """ Apply gaussian smoothing on a ...
2,656
34.426667
109
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/utils/backdoor_utils.py
from __future__ import print_function import torch ''' Modified upon https://github.com/howardmumu/Attack-Resistant-Federated-Learning/blob/70db1edde5b4b9dfb75633ca5dd5a5a7303c1f4c/FedAvg/Update.py#L335 Reference: Fu, Shuhao, et al. "Attack-Resistant Federated Learning with Residual-based Reweighting." arXiv prepri...
4,603
38.689655
133
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/utils/utils.py
from copy import deepcopy import torch def getTrainableParameters(model) -> list: ''' model: torch module ''' trainableParam = [] for name, param in model.named_parameters(): if param.requires_grad: trainableParam.append(name) return trainableParam def getFloatSubModules...
4,409
28.013158
137
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/utils/backdoor_semantic_utils.py
from __future__ import print_function import torch from tasks import cifar ''' Generate batches of backdoored cifar10 images the list of images for semantic backdoor is retrieved from https://github.com/ebagdasa/backdoor_federated_learning/blob/master/utils/params_runner.yaml Reference: Bagdasaryan, Eugene, et al...
3,121
41.189189
145
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/utils/allocateGPU.py
import os lim = 2 limit = str(lim) os.environ["OMP_NUM_THREADS"] = limit # export OMP_NUM_THREADS=1 os.environ["OPENBLAS_NUM_THREADS"] = limit # export OPENBLAS_NUM_THREADS=1 os.environ["MKL_NUM_THREADS"] = limit # export MKL_NUM_THREADS=1 os.environ["VECLIB_MAXIMUM_THREADS"] = limit # export VECLIB_MAXIMUM_THREAD...
2,515
34.43662
99
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/tasks/imdb_bert.py
from __future__ import print_function import pickle import torch import torch.nn as nn import torchtext from torchtext.experimental.vocab import vocab_from_file_object from transformers import MobileBertTokenizer, MobileBertModel from dataloader import * class BERTGRUSentiment(nn.Module): ''' Model retriev...
6,786
30.567442
128
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/tasks/imdb.py
from __future__ import print_function import collections import pickle import torch import torch.nn as nn import torchtext import torchtext.experimental import torchtext.experimental.vectors import torchtext.experimental.vocab from torchtext.experimental.datasets.raw.text_classification import RawTextIterableDataset ...
10,096
33.343537
112
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/tasks/fashion_mnist.py
from __future__ import print_function import os,sys,inspect current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parent_dir = os.path.dirname(current_dir) sys.path.insert(0, parent_dir) import pickle import torch import torch.nn as nn import torch.nn.functional as F from torchvision...
6,626
34.063492
112
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/tasks/cifar.py
from __future__ import print_function import os,sys,inspect current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parent_dir = os.path.dirname(current_dir) sys.path.insert(0, parent_dir) import pickle import torch import torch.nn as nn from torchvision import datasets, transforms fro...
3,417
34.237113
119
py
MUD-HoG_Federated_Learning
MUD-HoG_Federated_Learning-main/tasks/mnist.py
from __future__ import print_function import pickle import torch import torch.nn as nn import torch.nn.functional as F from torchvision import datasets, transforms from dataloader import * class Net(nn.Module): ''' LeNet retrieved from the pytorch tutorial https://pytorch.org/tutorials/beginner/bl...
4,218
31.960938
112
py
ddim
ddim-main/main.py
import argparse import traceback import shutil import logging import yaml import sys import os import torch import numpy as np import torch.utils.tensorboard as tb from runners.diffusion import Diffusion torch.set_printoptions(sci_mode=False) def parse_args_and_config(): parser = argparse.ArgumentParser(descrip...
7,498
31.184549
96
py
ddim
ddim-main/functions/losses.py
import torch def noise_estimation_loss(model, x0: torch.Tensor, t: torch.LongTensor, e: torch.Tensor, b: torch.Tensor, keepdim=False): a = (1-b).cumprod(dim=0).index_select(0, t).view(-1, 1, 1, 1) x = x0 * ...
594
27.333333
67
py
ddim
ddim-main/functions/denoising.py
import torch def compute_alpha(beta, t): beta = torch.cat([torch.zeros(1).to(beta.device), beta], dim=0) a = (1 - beta).cumprod(dim=0).index_select(0, t + 1).view(-1, 1, 1, 1) return a def generalized_steps(x, seq, model, b, **kwargs): with torch.no_grad(): n = x.size(0) seq_next = [...
2,363
33.764706
93
py
ddim
ddim-main/functions/__init__.py
import torch.optim as optim def get_optimizer(config, parameters): if config.optim.optimizer == 'Adam': return optim.Adam(parameters, lr=config.optim.lr, weight_decay=config.optim.weight_decay, betas=(config.optim.beta1, 0.999), amsgrad=config.optim.amsgrad, ...
727
44.5
100
py
ddim
ddim-main/models/diffusion.py
import math import torch import torch.nn as nn def get_timestep_embedding(timesteps, embedding_dim): """ This matches the implementation in Denoising Diffusion Probabilistic Models: From Fairseq. Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly ...
12,846
36.564327
95
py
ddim
ddim-main/models/ema.py
import torch.nn as nn class EMAHelper(object): def __init__(self, mu=0.999): self.mu = mu self.shadow = {} def register(self, module): if isinstance(module, nn.DataParallel): module = module.module for name, param in module.named_parameters(): if param....
1,723
33.48
81
py
ddim
ddim-main/datasets/utils.py
import os import os.path import hashlib import errno from torch.utils.model_zoo import tqdm def gen_bar_updater(): pbar = tqdm(total=None) def bar_update(count, block_size, total_size): if pbar.total is None and total_size: pbar.total = total_size progress_bytes = count * block_si...
5,665
29.299465
109
py
ddim
ddim-main/datasets/lsun.py
from .vision import VisionDataset from PIL import Image import os import os.path import io from collections.abc import Iterable import pickle from torchvision.datasets.utils import verify_str_arg, iterable_to_str class LSUNClass(VisionDataset): def __init__(self, root, transform=None, target_transform=None): ...
5,503
30.272727
90
py
ddim
ddim-main/datasets/__init__.py
import os import torch import numbers import torchvision.transforms as transforms import torchvision.transforms.functional as F from torchvision.datasets import CIFAR10 from datasets.celeba import CelebA from datasets.ffhq import FFHQ from datasets.lsun import LSUN from torch.utils.data import Subset import numpy as np...
6,931
31.092593
83
py
ddim
ddim-main/datasets/vision.py
import os import torch import torch.utils.data as data class VisionDataset(data.Dataset): _repr_indent = 4 def __init__(self, root, transforms=None, transform=None, target_transform=None): if isinstance(root, torch._six.string_classes): root = os.path.expanduser(root) self.root = ...
3,266
37.435294
86
py
ddim
ddim-main/datasets/celeba.py
import torch import os import PIL from .vision import VisionDataset from .utils import download_file_from_google_drive, check_integrity class CelebA(VisionDataset): """`Large-scale CelebFaces Attributes (CelebA) Dataset <http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html>`_ Dataset. Args: root (string)...
7,794
46.530488
120
py
ddim
ddim-main/datasets/ffhq.py
from io import BytesIO import lmdb from PIL import Image from torch.utils.data import Dataset class FFHQ(Dataset): def __init__(self, path, transform, resolution=8): self.env = lmdb.open( path, max_readers=32, readonly=True, lock=False, readahea...
1,055
24.756098
80
py
ddim
ddim-main/runners/diffusion.py
import os import logging import time import glob import numpy as np import tqdm import torch import torch.utils.data as data from models.diffusion import Model from models.ema import EMAHelper from functions import get_optimizer from functions.losses import loss_registry from datasets import get_dataset, data_transfo...
13,294
33.532468
98
py
cunet
cunet-main/test.py
import argparse import os import torch import math import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.backends.cudnn as cudnn from torch.utils.data import DataLoader from torch.optim import lr_scheduler import time import sys from utils import Logger, display_config, set_rand...
3,421
38.333333
124
py
cunet
cunet-main/latency_vox.py
import torch from data.face_scape_voxel_dataset import FaceScapeVoxelDataset from torchsparse.utils.collate import sparse_collate from sampling.voxelize import Voxelizer from models.cunet import CUNet from torchsparse import SparseTensor from time import time from traditional.devoxelize import DevoxelizeInterpolation ...
6,293
35.593023
121
py
cunet
cunet-main/patch.py
import numpy import torch import numpy as np from sklearn.neighbors import NearestNeighbors import torchsparse.nn.functional as F from tqdm import tqdm from sklearn.cluster import KMeans, MiniBatchKMeans from data.quantize import sparse_quantize def knn_index(source, target, k=1): nbrs = NearestNeighbors(n_neighbo...
9,305
41.3
135
py
cunet
cunet-main/latency_traditional.py
import torch from data.face_scape_voxel_dataset import FaceScapeVoxelDataset from sampling.voxelize import Voxelizer from torchsparse.utils.collate import sparse_collate from time import time from traditional.knn import KNNVoxelInterpolation from traditional.fractional import FractionalSRInterpolation import numpy as n...
2,953
35.925
97
py
cunet
cunet-main/utils.py
import numpy as np import open3d as o3d import torch import random import os import sys import errno import os.path as osp def normalize(points, scale=1.0): centroid = np.mean(points, axis=0) points_new = points - centroid m = np.max(np.sqrt(np.sum(points_new ** 2, axis=1))) points_new = scale * points...
3,238
25.120968
91
py
cunet
cunet-main/mpeg8i.py
import numpy as np import torch.cuda from utils import read_point_cloud_ply, draw_point_cloud, set_random_seed, read_mesh_ply, draw_mesh, normalize from traditional.knn import KNNVoxelInterpolation from metric.psnr import compute_psnr_numpy_rgb from data.quantize import sparse_quantize from sampling.voxelize import vox...
6,298
44.644928
130
py
cunet
cunet-main/baseline.py
import numpy as np from data.face_scape_voxel_dataset import FaceScapeVoxelDataset from utils import set_random_seed from metric.psnr import compute_psnr_numpy_rgb from sampling.voxelize import voxelize_avg_numpy, Voxelizer from tqdm import tqdm from traditional.devoxelize import devoxelize_interp from traditional.knn ...
2,299
32.823529
107
py
cunet
cunet-main/train.py
import argparse import os import torch import math import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.backends.cudnn as cudnn from torch.utils.data import DataLoader from torch.optim import lr_scheduler import time import sys from utils import Logger, display_config, set_rand...
4,966
46.304762
124
py
cunet
cunet-main/deep_interp.py
import copy import torch import numpy as np from models.cunet import CUNet from torchsparse import SparseTensor class DeepInterpolation: def __init__(self, num_channel, num_block, voxel_size, model_path, use_gpu=True): super(DeepInterpolation, self).__init__() self.model = CUNet(voxel_size, num_cha...
1,493
33.744186
85
py
cunet
cunet-main/metric/psnr.py
import numpy as np import torch def compute_psnr_numpy_rgb(pred, gt): ''' :param pred: (N, 3) :param gt: (N, 3) :return: float ''' pred = pred.astype(float) * 255. + 1e-6 # for numerical stability gt = gt.astype(float) * 255. mse = np.mean((pred - gt) ** 2) psnr = 10 * np.log10(25...
688
21.225806
70
py
cunet
cunet-main/models/cunet.py
import sys sys.path.append("..") from typing import List, Tuple, Union from torchsparse import SparseTensor from torchsparse import nn as spnn from torchsparse.utils.collate import sparse_collate_fn from torchsparse.utils.quantize import sparse_quantize import torchsparse.nn.functional as F from utils import read_point...
5,487
35.832215
112
py
cunet
cunet-main/models/knn.py
from torch import nn import torch import torch.nn.functional as F def square_distance(src, dst): """ Calculate Euclid distance between each two points. src^T * dst = xn * xm + yn * ym + zn * zm; sum(src^2, dim=-1) = xn*xn + yn*yn + zn*zn; sum(dst^2, dim=-1) = xm*xm + ym*ym + zm*zm; dist = (xn ...
2,031
33.440678
114
py
cunet
cunet-main/sampling/random_sample.py
import numpy as np import random import torch # randomly drop colors # torch class RandomColorSampler: def __init__(self, sample_rate): super(RandomColorSampler, self).__init__() self.sample_rate = sample_rate def __call__(self, points, colors): ''' :param points: (B, N, 3) ...
1,838
27.734375
74
py
cunet
cunet-main/sampling/voxelize.py
import sys sys.path.append("..") import numpy as np import torch import torchsparse.nn.functional as F from torchsparse import SparseTensor class Voxelizer: def __init__(self, voxel_size, avg_color=True): super(Voxelizer, self).__init__() self.voxel_size = voxel_size self.avg_color = avg_c...
3,788
40.184783
102
py
cunet
cunet-main/traditional/devoxelize.py
import torch import torchsparse.nn.functional as F def devoxelize_interp(points_lr, colors_lr, points_hr, idx_lr2hr): result = colors_lr[idx_lr2hr, :] return result # devoxlization without pre-computed LR-to-HR mapping class DevoxelizeInterpolation: def __init__(self, voxel_size): self.voxel_size...
935
39.695652
125
py
cunet
cunet-main/traditional/knn.py
import numpy as np from sklearn.neighbors import NearestNeighbors # from knn_cuda import KNN import torch def knn_index(source, target, k=1): nbrs = NearestNeighbors(n_neighbors=k, algorithm='auto').fit(source) distances, indices = nbrs.kneighbors(target) return indices # nearest neighbor interpolation o...
1,388
27.346939
73
py
cunet
cunet-main/runner/voxel.py
from tqdm import tqdm import torch import os from torch import optim from torch.optim import lr_scheduler import sys from metric.psnr import compute_psnr_torch_rgb from torch.cuda import amp def run_voxel(args, train_loader, valid_loader, test_loader, sampler, model): criterion = torch.nn.MSELoss() criterion ...
2,899
39.84507
121
py
cunet
cunet-main/data/face_scape_voxel_dataset.py
import sys sys.path.append("..") import json from torch.utils.data import Dataset import os from torchvision import transforms import torch import torch.nn.functional as F import numpy as np from utils import read_point_cloud_ply, normalize from data.quantize import sparse_quantize from torchsparse import SparseTensor ...
3,782
36.088235
114
py
interpretable_nn_attribution
interpretable_nn_attribution-master/run_spotify.py
""" Code for the sequential skip prediction task using the preprocessed spotify parquet files. """ import gc import time import sys import glob import numpy as np import pandas as pd sys.path.append('models') import tensorflow as tf from tensorflow.keras.callbacks import ReduceLROnPlateau, ModelCheckpoint, TensorBoar...
13,383
30.125581
122
py
interpretable_nn_attribution
interpretable_nn_attribution-master/run_movielens.py
""" Code for the movielens experiments. """ import argparse import os import time import random import numpy as np import tensorflow as tf from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense, Lambda, Concatenate, Reshape, Embedding, Flatten from tensorflow.keras.optimizers impor...
14,606
37.138381
151
py
interpretable_nn_attribution
interpretable_nn_attribution-master/models/interpretable_utils_list.py
''' Interpretable model utilities. Those functions are used to define interpretable models using lists of Layers. The other way to do it is by using mask_constraints, as done in interpretable_utils_matrix.py. ''' import tensorflow as tf from tensorflow.keras.layers import Concatenate, Lambda # -- layer wrappers de...
6,941
29.31441
110
py
interpretable_nn_attribution
interpretable_nn_attribution-master/models/multi_head_attention.py
''' Multi-head attention layer + other utils class for the transformer model. ''' import numpy as np import tensorflow as tf from tensorflow.keras.layers import Dense, Lambda, Reshape, Layer from tensorflow.keras.constraints import Constraint from tensorflow.keras import activations class LayerNormalization(Layer): ...
6,876
33.908629
96
py
interpretable_nn_attribution
interpretable_nn_attribution-master/models/multilayered_nn.py
import tensorflow as tf from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense, Lambda from tensorflow.keras.optimizers import Adam from interpretable_utils_list import * from interpretable_utils_matrix import * class Attr_Binary_FF_list(Model): """ -- Attribute-interpreta...
5,284
34.709459
81
py
interpretable_nn_attribution
interpretable_nn_attribution-master/models/spotify.py
''' Interpretable deep neural networks using boosted jointed restricted models ''' import tensorflow as tf from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense, Dropout, Lambda, Concatenate, Flatten, Activation, BatchNormalization, LeakyReLU, Add, GRU, Reshape, Bidirectional, Embe...
9,012
37.517094
175
py
TiSASRec
TiSASRec-master/modules.py
# -*- coding: utf-8 -*- #/usr/bin/python2 ''' June 2017 by kyubyong park. kbpark.linguist@gmail.com. https://www.github.com/kyubyong/transformer ''' from __future__ import print_function import tensorflow as tf import numpy as np def positional_encoding(dim, sentence_length, dtype=tf.float32): encoded_vec = np...
10,741
37.779783
163
py
fashion-compatibility
fashion-compatibility-master/main.py
from __future__ import print_function import argparse import os import sys import shutil import json import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import transforms from torch.autograd import Variable import torch.backends.cudnn as c...
13,249
41.332268
130
py
fashion-compatibility
fashion-compatibility-master/Resnet_18.py
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo __all__ = ['ResNet', 'resnet18'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', } def conv3x3(in_planes, out_planes, stride=1): "3x3 convolution with padding" return nn.Conv2d(in_planes...
3,796
29.620968
76
py
fashion-compatibility
fashion-compatibility-master/tripletnet.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable def make_fc_1d(f_in, f_out): return nn.Sequential(nn.Linear(f_in, f_out), nn.BatchNorm1d(f_out,eps=0.001,momentum=0.01), nn.ReLU(inplace=True))...
6,822
43.594771
123
py
fashion-compatibility
fashion-compatibility-master/type_specific_network.py
import torch import torch.nn as nn import numpy as np from torch.autograd import Variable class ListModule(nn.Module): def __init__(self, *args): super(ListModule, self).__init__() idx = 0 for module in args: self.add_module(str(idx), module) idx += 1 def __geti...
6,073
40.60274
104
py
fashion-compatibility
fashion-compatibility-master/polyvore_outfits.py
from PIL import Image import os import os.path import torch.utils.data import torchvision.transforms as transforms import numpy as np import json import torch import pickle import h5py from sklearn.metrics import roc_auc_score from torch.autograd import Variable def default_image_loader(path): return Image.open(pa...
13,907
37.740947
109
py
DraftRec
DraftRec-master/src/common/logger.py
import wandb import torch import os import json class LoggerService(object): def __init__(self, args): self.train_logger = WandbLogger(prefix='train') self.val_logger = WandbLogger(prefix='val') self.test_logger = WandbLogger(prefix='test') project_name = args.wandb_projec...
3,768
29.152
107
py
DraftRec
DraftRec-master/src/common/train_utils.py
import torch import torch.nn as nn import numpy as np import math def init_transformer_weights(module, init_range=0.0625): """ Initialize the weights """ if isinstance(module, (nn.Embedding, nn.Linear)): # Slightly different from the TF version which uses truncated_normal for initialization # ...
561
32.058824
95
py
DraftRec
DraftRec-master/src/common/initialization.py
import random import torch import torch.backends.cudnn as cudnn import numpy as np import torch.nn as nn def fix_random_seed(random_seed): random.seed(random_seed) torch.manual_seed(random_seed) torch.cuda.manual_seed_all(random_seed) np.random.seed(random_seed) cudnn.deterministic = True ...
829
28.642857
64
py
DraftRec
DraftRec-master/src/models/base.py
import torch.nn as nn from abc import * class BaseModel(nn.Module, metaclass=ABCMeta): def __init__(self, args): super().__init__() self.args = args @classmethod @abstractmethod def code(cls): pass
240
17.538462
46
py