repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
trimmed_match | trimmed_match-master/trimmed_match/design/multi_cell/tests/geox_simulation_test.py | """Tests for geox simulation."""
import numpy as np
import pandas as pd
from trimmed_match.design import common_classes
from trimmed_match.design.multi_cell import geox_simulation
from trimmed_match.design.multi_cell import multi_cell_util
import unittest
from absl.testing import parameterized
_PRE_EXPERIMENT = com... | 8,082 | 31.857724 | 79 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/multi_cell/tests/block_design_rmse_test.py | import pandas as pd
from trimmed_match.design import common_classes
from trimmed_match.design.multi_cell import block_design_rmse
from trimmed_match.design.multi_cell import multi_cell_util
import unittest
_PRE_EXPERIMENT = common_classes.ExperimentPeriod.PRE_EXPERIMENT
_EXPERIMENT = common_classes.ExperimentPeriod.E... | 5,261 | 30.508982 | 80 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/multi_cell/tests/geo_blocking_test.py | """Tests for geo blocking generation."""
import numpy as np
import pandas as pd
from trimmed_match.design.multi_cell import geo_blocking
import unittest
class GeoBlockingTest(unittest.TestCase):
def setUp(self):
super(GeoBlockingTest, self).setUp()
self.geo_level_data = pd.DataFrame({
'geo': range... | 3,338 | 33.071429 | 79 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/multi_cell/tests/multi_cell_util_test.py | from absl.testing import parameterized
import numpy as np
import pandas as pd
from trimmed_match.design.multi_cell import multi_cell_util
import unittest
GeoXType = multi_cell_util.GeoXType
class InferBlockSizeTest(unittest.TestCase):
def testInferBlockSize(self):
test_list = [1, 2, 3, 1, 2, 3]
test_seri... | 12,549 | 35.167147 | 79 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/multi_cell/tests/multi_cell_geo_assignment_test.py | """Tests for multi cell geo assignment generation."""
import pandas as pd
from trimmed_match.design.multi_cell import geo_blocking
from trimmed_match.design.multi_cell import multi_cell_geo_assignment
import unittest
class MultiCellGeoAssignmentTest(unittest.TestCase):
def setUp(self):
super(MultiCellGeoAssig... | 2,520 | 34.507042 | 80 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/trimmed_match_design_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 49,061 | 35.833333 | 96 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/matched_pairs_rmse_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 17,113 | 37.895455 | 93 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/geo_assignment_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 9,931 | 32.106667 | 80 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/geo_level_estimators_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 4,981 | 38.539683 | 80 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/util_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 20,184 | 36.241697 | 80 | py |
trimmed_match | trimmed_match-master/trimmed_match/design/tests/common_classes_test.py | # Copyright 2020 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | 4,435 | 36.59322 | 80 | py |
MotifClass | MotifClass-master/motif_selection/retrieve_docs.py | from collections import defaultdict
import argparse
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
parser.add_argument('--num_retrieved_docs', default=0, type=int)
args = parser.pars... | 1,382 | 29.065217 | 108 | py |
MotifClass | MotifClass-master/motif_selection/candidate_generation.py | import json
from collections import defaultdict
from collections import deque
import argparse
from tqdm import tqdm
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
parser.add_argument... | 1,718 | 26.285714 | 108 | py |
MotifClass | MotifClass-master/motif_selection/motif_selection.py | import numpy as np
import argparse
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
parser.add_argument('--num_motif', default=50, type=int)
parser.add_argument('--eta', default=2.0, t... | 1,715 | 23.869565 | 108 | py |
MotifClass | MotifClass-master/motif_selection/doc_id.py | import json
import argparse
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
args = parser.parse_args()
dataset = args.dataset
paper2id = {}
with open(f'../{dataset}_data/dataset.jso... | 964 | 31.166667 | 117 | py |
MotifClass | MotifClass-master/motif_selection/embedding_postprocess.py | import os
import argparse
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
args = parser.parse_args()
dataset = args.dataset
if not os.path.exists(f'../text_classification/{dataset}/... | 945 | 25.277778 | 108 | py |
MotifClass | MotifClass-master/motif_selection/embedding_preprocess.py | import json
from collections import defaultdict
import argparse
from tqdm import tqdm
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
parser.add_argument('--window', default=5, type=i... | 1,346 | 27.659574 | 108 | py |
MotifClass | MotifClass-master/text_classification/main.py | # The code structure is adapted from the WeSTClass implementation
# https://github.com/yumeng5/WeSTClass
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import numpy as np
np.random.seed(1234)
from time import time
from model import WSTC, f1
from keras.optimizers import... | 7,853 | 36.759615 | 137 | py |
MotifClass | MotifClass-master/text_classification/dataset_preprocess.py | import json
import argparse
from tqdm import tqdm
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
args = parser.parse_args()
dataset = args.dataset
metadatas = set()
with open(f'../... | 1,021 | 29.969697 | 108 | py |
MotifClass | MotifClass-master/text_classification/model.py | import numpy as np
np.random.seed(1234)
import os
from time import time
import csv
import keras.backend as K
# K.set_session(K.tf.Session(config=K.tf.ConfigProto(intra_op_parallelism_threads=30, inter_op_parallelism_threads=30)))
from keras.engine.topology import Layer
from keras.layers import Dense, Input, Convolution... | 9,038 | 32.354244 | 124 | py |
MotifClass | MotifClass-master/text_classification/gen.py | import numpy as np
import os
np.random.seed(1234)
from spherecluster import SphericalKMeans, VonMisesFisherMixture, sample_vMF
def seed_expansion(word_sup_array, prob_sup_array, sz, write_path, vocabulary_inv, embedding_mat):
expanded_seed = []
vocab_sz = len(vocabulary_inv)
for j, word_class in enumerate(word_sup... | 6,410 | 36.057803 | 113 | py |
MotifClass | MotifClass-master/text_classification/eval.py | from sklearn.metrics import f1_score
from sklearn.metrics import confusion_matrix
import argparse
parser = argparse.ArgumentParser(description='main', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--dataset', default='mag', choices=['mag', 'amazon'])
args = parser.parse_args()
dataset =... | 668 | 26.875 | 108 | py |
MotifClass | MotifClass-master/text_classification/load_data.py | import csv
import numpy as np
import os
import re
import itertools
from collections import Counter
from os.path import join
from nltk import tokenize
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
def read_file(data_dir, with_evaluation):
data... | 10,012 | 31.615635 | 116 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/attack_csgld_pgd_torch.py | """
Implementation of the attacks used in the article
"""
import numpy as np
import pandas as pd
import torch
import argparse
import time
import os
import sys
import re
from tqdm import tqdm
import random
from random import shuffle
from utils.data import CIFAR10, CIFAR100, ImageNet, MNIST
from utils.helpers import key... | 24,661 | 61.753181 | 254 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/compute_accuracy.py | import argparse
import torch
import torch.nn.functional as F
import numpy as np
import pandas as pd
import os
import sys
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from utils.helpers import list_models, guess_and_load_model, guess_method
from utils.data import ImageNet
def nl... | 4,542 | 37.82906 | 163 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/analyse_weights_space.py | import pandas as pd
import random
import os
import argparse
from tqdm import tqdm
import numpy as np
import torch
from torchvision import models as tmodels
import torchvision.datasets as datasets
import torchvision.transforms as transforms
#from pyhessian import hessian
from utils.data import ImageNet
from utils.helper... | 13,744 | 54.873984 | 179 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/analyse_feature_space.py | """
Interpolate between adv ex from 2 surrogate in feature space
"""
import os
import sys
import torch
import math
import random
import argparse
import numpy as np
import pandas as pd
from math import sqrt
from tqdm import tqdm
from utils.n_sphere import convert_spherical, convert_rectangular
from utils.data import CIF... | 14,705 | 54.91635 | 215 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/generate_parametric_path.py | import os
import argparse
from tqdm import tqdm
import numpy as np
import torch
from torchvision import models as tmodels
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from utils.data import ImageNet
from utils.helpers import guess_and_load_model, guess_model
from utils.pca_weights... | 4,285 | 46.622222 | 167 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/train_swag_imagenet.py | import argparse
import os
import random
import sys
import time
import tabulate
from collections import OrderedDict
import torch
import torch.nn.functional as F
import torchvision.models
import timm
from utils.swag import data
from utils.subspace_inference import utils, losses
#from utils.swag.posteriors import SWAG
... | 12,515 | 29.378641 | 128 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/generate_noisy_models.py | import pandas as pd
import os
from pathlib import Path
import argparse
import random
from tqdm import tqdm
import numpy as np
import torch
from torchvision import models as tmodels
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from utils.data import ImageNet
from utils.helpers impo... | 7,194 | 56.103175 | 201 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/hessian/compute_hessian.py | #*
# @file Different utility functions
# Copyright (c) Zhewei Yao, Amir Gholami
# All rights reserved.
# This file is part of PyHessian library.
#
# PyHessian is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, ei... | 4,571 | 30.531034 | 78 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/lgv/imagenet/hessian/utils_hessian.py | #*
# @file Different utility functions
# Copyright (c) Zhewei Yao, Amir Gholami
# All rights reserved.
# This file is part of PyHessian library.
#
# PyHessian is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, ei... | 5,701 | 39.728571 | 75 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/modelsghostpreresnet.py | """
PreResNet model definition
ported from https://github.com/bearpaw/pytorch-classification/blob/master/models/cifar/preresnet.py
-----
Adapted to add skip connection erosion
Do not use to train a model. Only for inference. Train on regular PreResNet
"""
import torch
import torch.nn as nn
import t... | 6,999 | 32.653846 | 141 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/n_sphere.py | # N-sphere Convert to Spherical or Rectangular Coordination
# improve n-sphere package with numerical stability and basic vectorization: https://pypi.org/project/n-sphere/
import numpy as np
import math
import torch
SUPPORTED_TYPES = ['Tensor', 'ndarray', 'list']
def convert_spherical(input, digits=6, tol=1e-8):
... | 3,609 | 37.817204 | 111 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/pca_weights.py | import torch
from sklearn.decomposition import PCA
from utils.subspace_inference.utils import flatten, bn_update
def model2vector(model):
"""
Transform a pytorch model into its weight Tensor
:param model: pytorch model
:return: tensor of size (n_weights,)
"""
w = flatten([param.detach().cpu() ... | 4,046 | 34.191304 | 120 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/optimizers.py | """
File adapted from https://github.com/JavierAntoran/Bayesian-Neural-Networks
"""
from torch.optim.optimizer import Optimizer, required
import numpy as np
import torch
class SGLD(Optimizer):
"""
SGLD optimiser based on pytorch's SGD.
Note that the weight decay is specified in terms of the gaussian prio... | 3,430 | 30.190909 | 111 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/data.py | import os
import logging
import torch
import torchvision
import torchvision.datasets as datasets
import numpy as np
from torchvision import transforms
from .helpers import list_models, guess_and_load_model, DEVICE
def check_args(method):
def inner(ref, **kwargs):
if kwargs.get('validation', False) and not... | 14,626 | 45.582803 | 130 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/utils_sgm.py | """
Code from the following paper:
@inproceedings{wu2020skip,
title={Skip connections matter: On the transferability of adversarial examples generated with resnets},
author={Wu, Dongxian and Wang, Yisen and Xia, Shu-Tao and Bailey, James and Ma, Xingjun},
booktitle={ICLR},
year={2020}
}
https://github.c... | 2,861 | 35.692308 | 107 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/layers.py | import torch
from PIL import Image
from torchvision.transforms import functional as F
class RandomResizePad(torch.nn.Module):
def __init__(self, min_resize):
super().__init__()
self.min_resize = min_resize
def forward(self, img):
size_original = img.size()
if size_original[-1]... | 1,083 | 40.692308 | 96 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/modelsghost.py | # adapted from torchvision ResNet implementation https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
# Add skip connection erosion
# do not use to train a model. Only for inference. Train on regular torchvision resnet
import torch
from torch import Tensor
import torch.nn as nn
try:
from torc... | 17,173 | 40.383133 | 141 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/models.py | import torch
from torch import nn
import torch.nn.functional as F
from random import randrange, shuffle
class ModelWithTemperature(nn.Module):
"""
A thin decorator, which wraps a model with temperature scaling.
Code adapted from https://github.com/gpleiss/temperature_scaling/blob/master/temperature_scalin... | 7,591 | 32.444934 | 147 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/__init__.py | 0 | 0 | 0 | py | |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/helpers.py | import os
import re
import glob
import argparse
import torch
import numpy as np
from collections import OrderedDict
try:
from art.classifiers import PyTorchClassifier
except ModuleNotFoundError:
from art.estimators.classification import PyTorchClassifier
from .models import TorchEnsemble, CifarLeNet, MnistCnn, ... | 28,359 | 45.79868 | 287 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/attacks.py | import torch
import os
import numpy as np
import scipy.stats as st
from art.attacks.evasion import FastGradientMethod, ProjectedGradientDescentPyTorch
from art.classifiers import PyTorchClassifier
from art.config import ART_NUMPY_DTYPE
from art.utils import (
random_sphere,
projection,
)
from tqdm import tqdm
f... | 23,513 | 45.562376 | 174 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/losses.py | import torch
import torch.nn.functional as F
def cross_entropy(model, input, target):
# standard cross-entropy loss function
output = model(input)
loss = F.cross_entropy(output, target)
return loss, output
def adversarial_cross_entropy(
model, input, target, lossfn=F.cross_entropy, epsilon=0.... | 3,094 | 28.47619 | 97 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/utils.py | import itertools
import torch
import os
import copy
from datetime import datetime
import math
import numpy as np
import tqdm
import torch.nn.functional as F
def flatten(lst):
tmp = [i.contiguous().view(-1, 1) for i in lst]
return torch.cat(tmp).view(-1)
def unflatten_like(vector, likeTensorList):
# Tak... | 7,489 | 26.740741 | 86 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/data.py | """
separate data loader for imagenet
"""
import os
import torch
import torchvision
import torchvision.transforms as transforms
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
def loaders(path, batch_size, num_workers, shuffle_train=True):
train_dir = os.path.join(path, "train")
# vali... | 1,851 | 25.84058 | 153 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/__init__.py | #!/usr/bin/env python3
# from . import models, posteriors, data, losses, utils
from . import posteriors, losses, utils
__all__ = [
# submodules
"utils",
# "data",
"losses",
# "models",
"posteriors",
# classes
# functions
] | 256 | 16.133333 | 55 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/posteriors/swag.py | """
implementation of SWAG
"""
import torch
import numpy as np
import itertools
from torch.distributions.normal import Normal
import copy
import gpytorch
from gpytorch.lazy import RootLazyTensor, DiagLazyTensor, AddedDiagLazyTensor
from gpytorch.distributions import MultivariateNormal
from ..utils import flatten... | 11,331 | 34.63522 | 88 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/swag/posteriors/__init__.py | #!/usr/bin/env python3
from .swag import SWAG
#from .laplace import KFACLaplace
# from .swag_laplace import | 109 | 17.333333 | 33 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/losses.py | import torch
import torch.nn.functional as F
class GaussianLikelihood:
"""
Minus Gaussian likelihood for regression problems.
Mean squared error (MSE) divided by `2 * noise_var`.
"""
def __init__(self, noise_var = 0.5):
self.noise_var = noise_var
self.mse = torch.nn.functiona... | 4,258 | 29.862319 | 97 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/utils.py | import itertools
import torch
import os
import copy
from datetime import datetime
import math
import numpy as np
import tqdm
from collections import defaultdict
from time import gmtime, strftime
import sys
import torch.nn.functional as F
def get_logging_print(fname):
cur_time = strftime("%m-%d_%H:%M:%S", gmtime(... | 9,479 | 28.349845 | 110 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/data.py | import numpy as np
import torch
import torchvision
import os
c10_classes = np.array([
[0, 1, 2, 8, 9],
[3, 4, 5, 6, 7]
], dtype=np.int32)
def camvid_loaders(path, batch_size, num_workers, transform_train, transform_test,
use_validation, val_size, shuffle_train=True,
joint_tra... | 9,867 | 39.77686 | 165 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/__init__.py | #!/usr/bin/env python3
from . import (
models,
posteriors,
data,
losses,
utils,
)
__all__ = [
"utils",
"data",
"losses",
"models",
"posteriors",
]
| 190 | 9.611111 | 22 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/preresnet.py | """
PreResNet model definition
ported from https://github.com/bearpaw/pytorch-classification/blob/master/models/cifar/preresnet.py
"""
import torch.nn as nn
import torchvision.transforms as transforms
import math
__all__ = ['PreResNet110', 'PreResNet56', 'PreResNet8', 'PreResNet83', 'PreResNet164']
def conv... | 7,349 | 30.410256 | 103 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/regression_net.py | import math
import torch
import torch.nn as nn
import torchvision.transforms as transforms
try:
import os
os.sys.path.append("/home/izmailovpavel/Documents/Projects/curves/")
import curves
except:
pass
__all__ = [
'RegNet',
'ToyRegNet',
]
class MDropout(torch.nn.Module):
def __init__(self... | 4,672 | 31.006849 | 125 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/vgg.py | """
VGG model definition
ported from https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py
"""
import math
import torch.nn as nn
import torchvision.transforms as transforms
__all__ = ['VGG16', 'VGG16BN', 'VGG19', 'VGG19BN']
def make_layers(cfg, batch_norm=False):
layers = list()
in... | 2,841 | 27.707071 | 105 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/mlp.py | import torch.nn as nn
import torchvision.transforms as transforms
import torch
__all__=['MLP', 'MLPBoston']
class MLPBase(nn.Module):
def __init__(self, num_classes=0, in_dim=1, layers=2, hidden=7):
super(MLPBase, self).__init__()
out_layer_list = [hidden for i in range(layers)]
if num_cl... | 1,419 | 27.979592 | 68 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/layers.py | """
layer definitions for 100-layer tiramisu
#from: https://github.com/bfortuner/pytorch_tiramisu
"""
import torch
import torch.nn as nn
class DenseLayer(nn.Sequential):
def __init__(self, in_channels, growth_rate):
super().__init__()
self.add_module('norm', nn.BatchNorm2d(in_channels))
... | 3,117 | 33.644444 | 82 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/wide_resnet.py | """
WideResNet model definition
ported from https://github.com/meliketoy/wide-resnet.pytorch/blob/master/networks/wide_resnet.py
"""
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
import math
__all__ = ['WideResNet28x10']
def co... | 3,660 | 32.587156 | 100 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/vgg_dropout.py | """
VGG model definition
ported from https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py
"""
import math
import torch.nn as nn
import torchvision.transforms as transforms
__all__ = ['VGG16Drop', 'VGG16BNDrop', 'VGG19Drop', 'VGG19BNDrop']
P = 0.05
def make_layers(cfg, batch_norm=False):
... | 2,927 | 27.990099 | 105 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/__init__.py | from .mlp import *
from .preresnet import *
from .preresnet_dropout import *
from .vgg import *
from .vgg_dropout import *
from .wide_resnet import *
from .wide_resnet_dropout import *
#from .mlp import *
from .regression_net import *
| 235 | 22.6 | 34 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/wide_resnet_dropout.py | """
WideResNet model definition
ported from https://github.com/meliketoy/wide-resnet.pytorch/blob/master/networks/wide_resnet.py
"""
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
import math
__all__ = ['WideResNet28x10Drop']
P =... | 3,640 | 31.508929 | 100 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/models/preresnet_dropout.py | """
PreResNet model definition
ported from https://github.com/bearpaw/pytorch-classification/blob/master/models/cifar/preresnet.py
"""
import torch.nn as nn
import torchvision.transforms as transforms
import math
__all__ = ['PreResNet110Drop', 'PreResNet56Drop', 'PreResNet8Drop', 'PreResNet164Drop']
P = 0.01... | 7,057 | 30.092511 | 103 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/ess.py | import torch
import numpy as np
from .elliptical_slice import elliptical_slice, slice_sample
from .proj_model import ProjectedModel
class EllipticalSliceSampling(torch.nn.Module):
def __init__(self, base, subspace, var, loader, criterion, num_samples = 20,
use_cuda = False, method='elliptical', *args, **... | 4,179 | 35.347826 | 126 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/elliptical_slice.py | #
# Elliptical slice sampling
#
import math
import numpy as np
def elliptical_slice(initial_theta,prior,lnpdf,
cur_lnpdf=None,angle_range=None, **kwargs):
"""
NAME:
elliptical_slice
PURPOSE:
Markov chain update for a distribution with a Gaussian "prior" factored out
I... | 4,811 | 36.59375 | 120 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/inferences.py | """
inferences class w/in the subspace
currently only fitting the Gaussian associated is implemented
"""
import abc
import torch
import numpy as np
from torch.distributions import LowRankMultivariateNormal
from .elliptical_slice import elliptical_slice
from ..utils import unflatten_like, flatten, train_epoch
... | 5,185 | 31.21118 | 145 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/vinf_model.py | import math
import torch
from ..utils import set_weights
class VINFModel(torch.nn.Module):
def __init__(self, base, subspace, flow,
prior_log_sigma=1.0, *args, **kwargs):
super(VINFModel, self).__init__()
self.base_model = base(*args, **kwargs)
self.flow = flow
... | 2,662 | 33.584416 | 103 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/swag.py | import torch
from ..utils import flatten, set_weights
from .subspaces import Subspace
class SWAG(torch.nn.Module):
def __init__(self, base, subspace_type,
subspace_kwargs=None, var_clamp=1e-6, *args, **kwargs):
super(SWAG, self).__init__()
self.base_model = base(*args, **kwargs... | 3,487 | 34.232323 | 96 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/subspaces.py | """
subspace classes
CovarianceSpace: covariance subspace
PCASpace: PCA subspace
FreqDirSpace: Frequent Directions Space
"""
import abc
import torch
import numpy as np
from sklearn.decomposition import TruncatedSVD
from sklearn.decomposition._pca import _assess_dimension
from sklearn.utils.extmath i... | 7,016 | 35.357513 | 121 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/realnvp.py | import math
import numpy as np
import torch
from torch import nn
from torch import distributions
class RealNVP(nn.Module):
def __init__(self, nets, nett, masks, prior, device=None):
super().__init__()
self.prior = prior
self.mask = nn.Parameter(masks, requires_grad=False)
self.t =... | 3,244 | 32.112245 | 101 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/proj_model.py | import torch
from ..utils import unflatten_like
class SubspaceModel(torch.nn.Module):
def __init__(self, mean, cov_factor):
super(SubspaceModel, self).__init__()
self.rank = cov_factor.size(0)
self.register_buffer('mean', mean)
self.register_buffer('cov_factor', cov_factor)
def... | 1,329 | 32.25 | 97 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/pyro.py | import numpy as np
import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc import NUTS, MCMC
from pyro.nn import AutoRegressiveNN
from ..utils import extract_parameters
from ..utils import set_weights_old as set_weights
class PyroModel(torch.nn.Module):
def __init__(self,
... | 6,618 | 37.707602 | 116 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/__init__.py | #!/usr/bin/env python3
from .swag import SWAG
from .inferences import *
from .subspaces import *
from .ess import *
from .pyro import *
from .vi_model import *
from .vinf_model import *
from .realnvp import *
| 210 | 18.181818 | 25 | py |
lgv-geometric-transferability | lgv-geometric-transferability-main/utils/subspace_inference/posteriors/vi_model.py | import math
import torch
from ..utils import extract_parameters, train_epoch
from ..utils import set_weights_old as set_weights
class VIModel(torch.nn.Module):
def __init__(self, base, subspace, init_inv_softplus_sigma=-3.0,
prior_log_sigma=3.0, eps=1e-6, with_mu=True, *args, **kwargs):
... | 4,676 | 38.635593 | 139 | py |
qPython | qPython-master/setup.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 2,873 | 31.292135 | 89 | py |
qPython | qPython-master/qpython/qconnection.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 14,532 | 36.650259 | 167 | py |
qPython | qPython-master/qpython/qreader.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 17,031 | 30.023679 | 147 | py |
qPython | qPython-master/qpython/utils.py | # Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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,882 | 25.521127 | 75 | py |
qPython | qPython-master/qpython/qtemporal.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 13,109 | 29.207373 | 127 | py |
qPython | qPython-master/qpython/qtype.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 ... | 11,669 | 26.785714 | 101 | py |
qPython | qPython-master/qpython/__init__.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 1,884 | 25.928571 | 86 | py |
qPython | qPython-master/qpython/qcollection.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 18,767 | 39.188437 | 262 | py |
qPython | qPython-master/qpython/qwriter.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 9,678 | 33.322695 | 138 | py |
qPython | qPython-master/qpython/_pandas.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 8,557 | 37.723982 | 145 | py |
qPython | qPython-master/tests/pandas_test.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 28,186 | 81.177843 | 293 | py |
qPython | qPython-master/tests/qreader_test.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 32,529 | 75.004673 | 263 | py |
qPython | qPython-master/tests/qwriter_test.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 42,699 | 107.928571 | 265 | py |
qPython | qPython-master/tests/qtypes_test.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 10,642 | 30.865269 | 127 | py |
qPython | qPython-master/samples/sync_query.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 ... | 1,817 | 38.521739 | 127 | py |
qPython | qPython-master/samples/custom_readers.py | #
# Copyright (c) 2011-2016 Exxeleron GmbH
#
# 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 agre... | 2,642 | 33.324675 | 108 | py |
qPython | qPython-master/samples/tick_subscriber.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 ... | 2,652 | 32.582278 | 155 | py |
qPython | qPython-master/samples/twistedclient.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 5,782 | 32.427746 | 123 | py |
qPython | qPython-master/samples/async_query.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 ... | 2,883 | 31.404494 | 155 | py |
qPython | qPython-master/samples/publisher.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 ... | 2,583 | 29.4 | 143 | py |
qPython | qPython-master/samples/__init__.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 599 | 36.5 | 75 | py |
qPython | qPython-master/samples/console.py | #
# Copyright (c) 2011-2014 Exxeleron GmbH
#
# 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 agre... | 1,453 | 28.673469 | 108 | py |
qPython | qPython-master/doc/source/conf.py | # -*- coding: utf-8 -*-
#
# qPython documentation build configuration file, created by
# sphinx-quickstart on Tue Sep 09 07:11:15 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.
#
# A... | 8,654 | 29.910714 | 79 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/logger.py | import os
import sys
import shutil
import os.path as osp
import json
import time
import datetime
import tempfile
from mpi4py import MPI
LOG_OUTPUT_FORMATS = ['stdout', 'log', 'csv']
# Also valid: json, tensorboard
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
class KVWriter(object):
def writekvs(self,... | 12,441 | 28.413712 | 122 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/__init__.py | 0 | 0 | 0 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.