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 |
|---|---|---|---|---|---|---|
mae | mae-main/main_linprobe.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# DeiT: https://github.com/facebookresearch/deit
#... | 13,142 | 40.460568 | 129 | py |
mae | mae-main/main_finetune.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# DeiT: https://github.com/facebookresearch/deit
#... | 15,633 | 42.792717 | 129 | py |
mae | mae-main/util/crop.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
from torchvision import transforms
from torchvision.transforms import functional as F
class R... | 1,361 | 31.428571 | 88 | py |
mae | mae-main/util/pos_embed.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# Position embedding utils
# -----------------------------------... | 4,047 | 40.731959 | 107 | py |
mae | mae-main/util/misc.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# DeiT: https://github.com/facebookresearch/deit
#... | 11,440 | 32.65 | 128 | py |
mae | mae-main/util/datasets.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# DeiT: https://github.com/facebookresearch/deit
#... | 1,902 | 27.833333 | 109 | py |
mae | mae-main/util/lars.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# LARS optimizer, implementation from MoCo v3:
# https://github.... | 1,851 | 38.404255 | 113 | py |
bigbird | bigbird-master/bigbird/classifier/run_classifier.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 15,676 | 33.454945 | 82 | py |
bigbird | bigbird-master/bigbird/core/modeling.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 17,704 | 36.750533 | 80 | py |
bigbird | bigbird-master/bigbird/core/utils.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 25,119 | 31.53886 | 81 | py |
bigbird | bigbird-master/bigbird/core/encoder.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 19,224 | 40.975983 | 80 | py |
bigbird | bigbird-master/bigbird/core/recompute_grad.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 19,719 | 36.277883 | 102 | py |
bigbird | bigbird-master/bigbird/core/decoder.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 23,876 | 39.67632 | 80 | py |
bigbird | bigbird-master/bigbird/core/attention.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 44,413 | 43.637186 | 80 | py |
bigbird | bigbird-master/bigbird/pretrain/run_pretraining.py | # Copyright 2021 The BigBird Authors.
#
# 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 to in ... | 24,861 | 36.107463 | 82 | py |
Formal-Conceptual-Views-in-Neural-Networks | Formal-Conceptual-Views-in-Neural-Networks-master/src/tangled/ablation.py | import pandas as pd
import numpy as np
import os
from sklearn.metrics import confusion_matrix, classification_report
import tensorflow as tf
from tensorflow.keras.optimizers import Adadelta
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.callbacks import ReduceLROnPlateau, Mo... | 15,279 | 45.30303 | 172 | py |
Formal-Conceptual-Views-in-Neural-Networks | Formal-Conceptual-Views-in-Neural-Networks-master/src/tangled/fruit_conceptual_views.py | import os
import pandas as pd
import numpy as np
from tensorflow.keras.models import Model
if not os.path.exists("scales/fruit_class"):
os.makedirs("scales/fruit_class")
if not os.path.exists("scales/fruit_obj"):
os.makedirs("scales/fruit_obj")
import numpy as np
import pandas as pd
def make_scale(w,delta=np... | 12,058 | 46.664032 | 172 | py |
Formal-Conceptual-Views-in-Neural-Networks | Formal-Conceptual-Views-in-Neural-Networks-master/src/tangled/imagenet_conceptual_views.py | import os
import pandas as pd
import numpy as np
import numpy as np
import pandas as pd
def make_scale(w,delta=np.zeros(4096,)):
"""The many-valued scale w and a delta array that specifies the
scaling thresholds. Our experiments show good results for delta=0
for all attributes. Note that w.shape[1]>del... | 10,612 | 44.74569 | 174 | py |
Formal-Conceptual-Views-in-Neural-Networks | Formal-Conceptual-Views-in-Neural-Networks-master/src/tangled/train_fruits.py | import pandas as pd
import numpy as np
import os
from sklearn.metrics import confusion_matrix, classification_report
import tensorflow as tf
from tensorflow.keras.optimizers import Adadelta
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.callbacks import ReduceLROnPlateau, Mo... | 10,589 | 51.167488 | 172 | py |
Layer-Folding | Layer-Folding-main/ResNet_Cifar10_prefold.py | '''
This code is modified the official PyTorch implementation:
https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
We also used this code:
https://github.com/chenyaofo/pytorch-cifar-models/blob/master/pytorch_cifar_models/resnet.py
There are only 1 main change in the architecture:
The forword pro... | 9,384 | 35.375969 | 112 | py |
Layer-Folding | Layer-Folding-main/VGG_Cifar10_postfold.py | import torch
import torch.utils.data
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
from typing import Union, List, Dict, Any, cast
import argparse
import numpy as np
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
parser = argparse.... | 10,900 | 37.793594 | 113 | py |
Layer-Folding | Layer-Folding-main/VGG_Cifar10_prefold.py | import torch
import torch.utils.data
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
from typing import Union, List, Dict, Any, cast
import argparse
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
parser = argparse.ArgumentParser(desc... | 9,290 | 35.57874 | 113 | py |
Layer-Folding | Layer-Folding-main/ResNet_Cifar10_postfold.py | '''
This code is modified the official PyTorch implementation:
https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
We also used this code:
https://github.com/chenyaofo/pytorch-cifar-models/blob/master/pytorch_cifar_models/resnet.py
There are only 1 main change in the architecture:
The forword pro... | 11,765 | 37.201299 | 112 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/utils_for_scripts.py | # This file includes methods that are called from the wrapper scripts or that
# require imports from the repo itself or that are only needed by one of those
# methods.
import torch
import torch.backends.cudnn as cudnn
import numpy as np
import sklearn.metrics
import configparser
import glob
import re
import shutil
imp... | 22,221 | 45.103734 | 203 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/modules.py | import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import numpy as np
from sklearn import discriminant_analysis
from scipy.special import logit, expit
from scipy.sparse import coo_matrix, dia_matrix
from scipy import linalg
from dca_plda import utils
from dca_plda import data as ddata
from d... | 60,095 | 47.347546 | 236 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/htplda.py | # The code in this file was written by Niko Brummer.
# Luciana Ferrer added the functionality to (approximately) score with stats.
import torch
from torch.autograd import Function
from torch import as_tensor as ten
import scipy
import numpy as np
torch.backends.cudnn.enabled = False
class ScoreMatrix(Function):
... | 13,536 | 29.14922 | 90 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/utils.py | # This file contains utilities that do not need imports from the repository
import torch
import torch.backends.cudnn as cudnn
import numpy as np
import sklearn.metrics
import configparser
import glob
import re
import shutil
import torch.optim as optim
import os
from numpy.linalg import cholesky as chol
from scipy.lina... | 13,902 | 32.340528 | 136 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/data.py | import random
import torch
from torch.utils.data import Dataset
import numpy as np
import h5py
from dca_plda import utils
from numpy.lib import recfunctions as rfn
class LabelledDataset(Dataset):
"""Face Landmarks dataset."""
def __init__(self, emb_file, meta_file=None, meta_is_dur_only=False, device=None, cl... | 20,504 | 54.418919 | 227 | py |
DCA-PLDA | DCA-PLDA-master/dca_plda/generative.py | # The code for training heavy-tail PLDA in this file was written by Niko Brummer
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import numpy as np
from sklearn import discriminant_analysis
from scipy.special import logit
from scipy.sparse import coo_matrix, dia_matrix
from scipy import lin... | 12,838 | 31.920513 | 136 | py |
DCA-PLDA | DCA-PLDA-master/scripts/compare_models.py | import argparse
import torch
import numpy as np
from IPython import embed
parser = argparse.ArgumentParser(description="Print the L2 distance for each parameter between two models.")
parser.add_argument('model1', help='Model 1 to compare.')
parser.add_argument('model2', help='Model 2 to compare.')
opt = parser.pars... | 619 | 25.956522 | 108 | py |
DCA-PLDA | DCA-PLDA-master/scripts/enroll.py | import argparse
import os
import random
import torch
import torch.backends.cudnn as cudnn
import torch.optim as optim
from dca_plda.data import LabelledDataset
from dca_plda.utils_for_scripts import np_to_torch, load_model, setup_torch_and_cuda_vars
from dca_plda.utils import save_checkpoint, load_configs, get_class_... | 2,268 | 38.807018 | 131 | py |
DCA-PLDA | DCA-PLDA-master/scripts/dump_sideinfo.py | import argparse
import os
import random
import torch
import torch.backends.cudnn as cudnn
import torch.optim as optim
from dca_plda.data import LabelledDataset
from dca_plda.utils_for_scripts import np_to_torch, load_model, compute_sideinfo
parser = argparse.ArgumentParser()
parser.add_argument('--cuda', help='En... | 1,305 | 27.391304 | 91 | py |
DCA-PLDA | DCA-PLDA-master/scripts/eval.py | import argparse
import os
import random
import torch
import torch.backends.cudnn as cudnn
import torch.optim as optim
from dca_plda.data import LabelledDataset
from dca_plda.utils_for_scripts import np_to_torch, evaluate, load_model, mkdirp, setup_torch_and_cuda_vars
from dca_plda.scores import IdMap, compute_performa... | 3,768 | 58.825397 | 237 | py |
DCA-PLDA | DCA-PLDA-master/scripts/train.py | import argparse
import os
import random
import torch
import re
from dca_plda.utils import load_configs, get_class_to_cluster_map_from_config
from dca_plda.utils_for_scripts import setup_torch_and_cuda_vars, print_graph, train, mkdirp
from dca_plda.data import LabelledDataset
from dca_plda.modules import DCA_PLDA_Backe... | 3,664 | 45.987179 | 222 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/eval.py | # !/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Lice... | 4,870 | 40.279661 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/predict.py | #!/usr/bin/env python
# coding: utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Li... | 5,155 | 43.834783 | 172 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/train.py | #!/usr/bin/env python
#coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 11,225 | 41.847328 | 108 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/dataset/dataset.py | #!/usr/bin/env python
#coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 15,346 | 39.708223 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/dataset/collator.py | #!/usr/bin/env python
#coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 10,146 | 40.416327 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/embedding.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 10,392 | 40.907258 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/transformer_encoder.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 4,149 | 37.425926 | 98 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/loss.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 7,035 | 41.385542 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/layers.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 6,673 | 38.02924 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/model_util.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 6,243 | 37.073171 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/rnn.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 4,174 | 37.302752 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/attention.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 3,768 | 34.224299 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/optimizer.py | #!/usr/bin/env python
#coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 9,705 | 42.918552 | 101 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/drnn.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 5,600 | 45.289256 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/textcnn.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 3,196 | 42.202703 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/textrnn.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 4,380 | 42.376238 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/textvdcnn.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 6,138 | 42.85 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/hmcn.py | #!/usr/bin/env python
# coding: utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Li... | 5,343 | 45.877193 | 113 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/classifier.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 6,661 | 49.854962 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/dpcnn.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 3,414 | 41.6875 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/fasttext.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 6,777 | 49.962406 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/transformer.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 5,571 | 42.874016 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/textrcnn.py | #!/usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licen... | 3,879 | 41.173913 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/attentive_convolution.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 8,324 | 44.244565 | 97 | py |
NeuralNLP-NeuralClassifier | NeuralNLP-NeuralClassifier-master/model/classification/region_embedding.py | #!usr/bin/env python
# coding:utf-8
"""
Tencent is pleased to support the open source community by making NeuralClassifier available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance
with the Licens... | 2,260 | 43.333333 | 97 | py |
WSAD | WSAD-main/experiments/myutils.py | import os
import pandas as pd
import numpy as np
import random
import torch
import tensorflow as tf
# metric
from sklearn.metrics import roc_auc_score, average_precision_score
# plot
import matplotlib.pyplot as plt
# statistical analysis
from scipy.stats import wilcoxon
class Utils():
def __init__(self):
... | 11,119 | 35.821192 | 117 | py |
WSAD | WSAD-main/experiments/run.py | import os
import logging; logging.basicConfig(level=logging.WARNING)
import numpy as np
import pandas as pd
from itertools import product
from tqdm import tqdm
import time
import gc
from keras import backend as K
from data_generator import DataGenerator
from myutils import Utils
class RunPipeline():
def __init__(... | 8,325 | 40.014778 | 195 | py |
WSAD | WSAD-main/experiments/baseline/PyOD.py | from myutils import Utils
import numpy as np
#add the baselines from the pyod package
from pyod.models.iforest import IForest
from pyod.models.ocsvm import OCSVM
from pyod.models.abod import ABOD
from pyod.models.cblof import CBLOF
from pyod.models.cof import COF
from pyod.models.combination import aom
from pyod.model... | 12,939 | 42.864407 | 124 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baseline_kde.py | import click
import torch
import logging
import random
import numpy as np
from utils.config import Config
from utils.visualization.plot_images_grid import plot_images_grid
from baselines.kde import KDE
from datasets.main import load_dataset
############################################################################... | 9,298 | 50.375691 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baseline_isoforest.py | import click
import torch
import logging
import random
import numpy as np
from utils.config import Config
from utils.visualization.plot_images_grid import plot_images_grid
from baselines.isoforest import IsoForest
from datasets.main import load_dataset
################################################################... | 9,754 | 52.016304 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baseline_SemiDGM.py | import click
import torch
import logging
import random
import numpy as np
from utils.config import Config
from utils.visualization.plot_images_grid import plot_images_grid
from baselines.SemiDGM import SemiDeepGenerativeModel
from datasets.main import load_dataset
####################################################... | 13,325 | 54.294606 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baseline_ssad.py | import click
import torch
import logging
import random
import numpy as np
import cvxopt as co
from utils.config import Config
from utils.visualization.plot_images_grid import plot_images_grid
from baselines.ssad import SSAD
from datasets.main import load_dataset
######################################################... | 8,981 | 49.745763 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/run.py | import torch
import logging
import random
import numpy as np
import pandas as pd
import os
from .utils.config import Config
from .utils.visualization.plot_images_grid import plot_images_grid
from .deepsad import deepsad
from .datasets.main import load_dataset
from myutils import Utils
class DeepSAD():
def __init__... | 4,834 | 40.681034 | 115 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baseline_ocsvm.py | import click
import torch
import logging
import random
import numpy as np
from utils.config import Config
from utils.visualization.plot_images_grid import plot_images_grid
from baselines.ocsvm import OCSVM
from datasets.main import load_dataset
########################################################################... | 8,888 | 49.794286 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/deepsad.py | import json
import torch
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.networks.main import build_network, build_autoencoder
from baseline.DeepSAD.src.optim.DeepSAD_trainer import DeepSADTrainer
from baseline.DeepSAD.src.optim.ae_trainer import AETrainer
class deepsad(obj... | 6,884 | 39.982143 | 128 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/fmnist_LeNet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from base.base_net import BaseNet
class FashionMNIST_LeNet(BaseNet):
def __init__(self, rep_dim=64):
super().__init__()
self.rep_dim = rep_dim
self.pool = nn.MaxPool2d(2, 2)
self.conv1 = nn.Conv2d(1, 16, 5, bias... | 2,508 | 31.584416 | 75 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/mlp.py | import torch.nn as nn
import torch.nn.functional as F
from baseline.DeepSAD.src.base.base_net import BaseNet
class MLP(BaseNet):
def __init__(self, x_dim, h_dims=[128, 64], rep_dim=32, bias=False):
super().__init__()
self.rep_dim = rep_dim
neurons = [x_dim, *h_dims]
layers = [L... | 2,252 | 28.25974 | 109 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/vae.py | import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from .layers.stochastic import GaussianSample
from .inference.distributions import log_standard_gaussian, log_gaussian
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
class Encoder(nn.Module):
"""
Encoder, ... | 4,673 | 31.013699 | 117 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/dgm.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from .vae import VariationalAutoencoder, Encoder, Decoder
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
class Classifier(nn.Module):
"""
Classifier network, i.e. q(y|x), for two classes (0: n... | 4,282 | 33.540323 | 116 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/mnist_LeNet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from base.base_net import BaseNet
class MNIST_LeNet(BaseNet):
def __init__(self, rep_dim=32):
super().__init__()
self.rep_dim = rep_dim
self.pool = nn.MaxPool2d(2, 2)
self.conv1 = nn.Conv2d(1, 8, 5, bias=False, ... | 2,151 | 28.888889 | 73 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/cifar10_LeNet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from base.base_net import BaseNet
class CIFAR10_LeNet(BaseNet):
def __init__(self, rep_dim=128):
super().__init__()
self.rep_dim = rep_dim
self.pool = nn.MaxPool2d(2, 2)
self.conv1 = nn.Conv2d(3, 32, 5, bias=Fal... | 3,003 | 35.192771 | 101 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/layers/stochastic.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
class Stochastic(nn.Module):
"""
Base stochastic layer that uses the reparametrization trick (Kingma and Welling, 2013) to draw a sampl... | 1,458 | 26.018519 | 114 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/layers/standard.py | import torch
from torch.nn import Module
from torch.nn import init
from torch.nn.parameter import Parameter
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
class Standardize(Module):
"""
Applies (element-wise) standardization with trainable translation parameter μ and scale parameter σ... | 1,646 | 30.075472 | 118 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/networks/inference/distributions.py | import math
import torch
import torch.nn.functional as F
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
def log_standard_gaussian(x):
"""
Evaluates the log pdf of a standard normal distribution at x.
:param x: point to evaluate
:return: log N(x|0,I)
"""
return torch.su... | 1,213 | 27.904762 | 120 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baselines/kde.py | import json
import logging
import time
import torch
import numpy as np
from torch.utils.data import DataLoader
from sklearn.neighbors import KernelDensity
from sklearn.metrics import roc_auc_score
from sklearn.metrics.pairwise import pairwise_distances
from sklearn.model_selection import GridSearchCV
from base.base_da... | 6,538 | 38.630303 | 118 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baselines/isoforest.py | import json
import logging
import time
import torch
import numpy as np
from torch.utils.data import DataLoader
from sklearn.ensemble import IsolationForest
from sklearn.metrics import roc_auc_score
from base.base_dataset import BaseADDataset
from networks.main import build_autoencoder
class IsoForest(object):
""... | 5,732 | 37.736486 | 118 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baselines/SemiDGM.py | import json
import torch
from base.base_dataset import BaseADDataset
from networks.main import build_network, build_autoencoder
from optim import SemiDeepGenerativeTrainer, VAETrainer
class SemiDeepGenerativeModel(object):
"""A class for the Semi-Supervised Deep Generative model (M1+M2 model).
Paper: Kingma... | 5,482 | 41.503876 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baselines/ocsvm.py | import json
import logging
import time
import torch
import numpy as np
from torch.utils.data import DataLoader
from sklearn.svm import OneClassSVM
from sklearn.metrics import roc_auc_score
from base.base_dataset import BaseADDataset
from networks.main import build_autoencoder
class OCSVM(object):
"""A class for ... | 8,812 | 38.698198 | 118 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/baselines/ssad.py | import json
import logging
import time
import torch
import numpy as np
from torch.utils.data import DataLoader
from .shallow_ssad.ssad_convex import ConvexSSAD
from sklearn.metrics import roc_auc_score
from sklearn.metrics.pairwise import pairwise_kernels
from base.base_dataset import BaseADDataset
from networks.main ... | 9,957 | 39.644898 | 118 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/optim/DeepSAD_trainer.py | from baseline.DeepSAD.src.base.base_trainer import BaseTrainer
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.base.base_net import BaseNet
from torch.utils.data.dataloader import DataLoader
from sklearn.metrics import roc_auc_score, average_precision_score
import logging
imp... | 6,937 | 37.544444 | 117 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/optim/SemiDGM_trainer.py | from baseline.DeepSAD.src.base.base_trainer import BaseTrainer
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.base.base_net import BaseNet
from baseline.DeepSAD.src.optim.variational import SVI, ImportanceWeightedSampler
from baseline.DeepSAD.src.utils.misc import binary_cros... | 7,366 | 37.978836 | 116 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/optim/variational.py | import torch
import torch.nn.functional as F
from torch import nn
from itertools import repeat
from baseline.DeepSAD.src.utils import enumerate_discrete, log_sum_exp
from baseline.DeepSAD.src.networks import log_standard_categorical
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
class Importa... | 2,723 | 27.978723 | 103 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/optim/vae_trainer.py | from baseline.DeepSAD.src.base.base_trainer import BaseTrainer
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.base.base_net import BaseNet
from baseline.DeepSAD.src.utils.misc import binary_cross_entropy
from sklearn.metrics import roc_auc_score
import logging
import time
im... | 5,108 | 35.492857 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/optim/ae_trainer.py | from baseline.DeepSAD.src.base.base_trainer import BaseTrainer
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.base.base_net import BaseNet
from sklearn.metrics import roc_auc_score, average_precision_score
import logging
import time
import torch
import torch.nn as nn
import ... | 5,242 | 36.992754 | 119 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/datasets/preprocessing.py | import torch
import numpy as np
def create_semisupervised_setting(labels, normal_classes, outlier_classes, known_outlier_classes,
ratio_known_normal, ratio_known_outlier, ratio_pollution):
"""
Create a semi-supervised data setting.
:param labels: np.array with labels of ... | 3,563 | 52.19403 | 113 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/datasets/odds.py | from torch.utils.data import DataLoader, Subset
from baseline.DeepSAD.src.base.base_dataset import BaseADDataset
from baseline.DeepSAD.src.base.odds_dataset import ODDSDataset
from .preprocessing import create_semisupervised_setting
import torch
class ODDSADDataset(BaseADDataset):
def __init__(self, data, train... | 1,430 | 35.692308 | 107 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/datasets/fmnist.py | from torch.utils.data import Subset
from PIL import Image
from torchvision.datasets import FashionMNIST
from base.torchvision_dataset import TorchvisionDataset
from .preprocessing import create_semisupervised_setting
import torch
import torchvision.transforms as transforms
import random
class FashionMNIST_Dataset(To... | 3,578 | 40.616279 | 120 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/datasets/cifar10.py | from torch.utils.data import Subset
from PIL import Image
from torchvision.datasets import CIFAR10
from base.torchvision_dataset import TorchvisionDataset
from .preprocessing import create_semisupervised_setting
import torch
import torchvision.transforms as transforms
import random
import numpy as np
class CIFAR10_D... | 3,523 | 39.505747 | 120 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/datasets/mnist.py | from torch.utils.data import Subset
from PIL import Image
from torchvision.datasets import MNIST
from baseline.DeepSAD.src.base.torchvision_dataset import TorchvisionDataset
from .preprocessing import create_semisupervised_setting
import torch
import torchvision.transforms as transforms
import random
class MNIST_Dat... | 3,513 | 39.860465 | 120 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/base/base_net.py | import logging
import torch.nn as nn
import numpy as np
class BaseNet(nn.Module):
"""Base class for all neural networks."""
def __init__(self):
super().__init__()
self.logger = logging.getLogger(self.__class__.__name__)
self.rep_dim = None # representation dimensionality, i.e. dim of... | 797 | 28.555556 | 102 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/base/odds_dataset.py | from pathlib import Path
from torch.utils.data import Dataset
from scipy.io import loadmat
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, MinMaxScaler
from torchvision.datasets.utils import download_url
import os
import torch
import pandas as pd
import numpy as n... | 1,632 | 31.019608 | 112 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/base/torchvision_dataset.py | from .base_dataset import BaseADDataset
from torch.utils.data import DataLoader
class TorchvisionDataset(BaseADDataset):
"""TorchvisionDataset class for datasets_cc already implemented in torchvision.datasets_cc."""
def __init__(self, root: str):
super().__init__(root)
def loaders(self, batch_si... | 829 | 45.111111 | 105 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/base/base_dataset.py | from abc import ABC, abstractmethod
from torch.utils.data import DataLoader
class BaseADDataset(ABC):
"""Anomaly detection dataset base class."""
def __init__(self, root: str):
super().__init__()
self.root = root # root path to data
self.n_classes = 2 # 0: normal, 1: outlier
... | 1,006 | 36.296296 | 105 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/base/__init__.py | from .base_dataset import *
from .torchvision_dataset import *
from .odds_dataset import *
from .base_net import *
from .base_trainer import *
| 143 | 23 | 34 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/utils/misc.py | import torch
from torch.autograd import Variable
# Acknowledgements: https://github.com/wohlert/semi-supervised-pytorch
def enumerate_discrete(x, y_dim):
"""
Generates a 'torch.Tensor' of size batch_size x n_labels of the given label.
:param x: tensor with batch size to mimic
:param y_dim: number of... | 1,422 | 29.276596 | 89 | py |
WSAD | WSAD-main/experiments/baseline/DeepSAD/src/utils/visualization/plot_images_grid.py | import torch
import matplotlib
matplotlib.use('Agg') # or 'PS', 'PDF', 'SVG'
import matplotlib.pyplot as plt
import numpy as np
from torchvision.utils import make_grid
def plot_images_grid(x: torch.tensor, export_img, title: str = '', nrow=8, padding=2, normalize=False, pad_value=0):
"""Plot 4D Tensor of images... | 777 | 27.814815 | 116 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.