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
3DG-STFM
3DG-STFM-master/configs/data/__init__.py
0
0
0
py
3DG-STFM
3DG-STFM-master/configs/data/megadepth_test_1500.py
from configs.data.base import cfg ''' TEST_BASE_PATH = "inference/megadepth_test_1500_scene_info" cfg.DATASET.TEST_DATA_SOURCE = "MegaDepth" cfg.DATASET.TEST_DATA_ROOT = "data/megadepth/test" cfg.DATASET.TEST_NPZ_ROOT = f"{TEST_BASE_PATH}" cfg.DATASET.TEST_LIST_PATH = f"{TEST_BASE_PATH}/megadepth_test_1500.txt" cfg.D...
830
42.736842
108
py
3DG-STFM
3DG-STFM-master/configs/data/scannet_trainval.py
from configs.data.base import cfg TRAIN_BASE_PATH = "data/scannet/index" cfg.DATASET.TRAINVAL_DATA_SOURCE = "ScanNet" cfg.DATASET.TRAIN_DATA_ROOT = "data/scannet/train" cfg.DATASET.TRAIN_NPZ_ROOT = f"{TRAIN_BASE_PATH}/scene_data/train" cfg.DATASET.TRAIN_LIST_PATH = f"{TRAIN_BASE_PATH}/scene_data/train_list/scannet_al...
897
48.888889
101
py
tencent-ml-images
tencent-ml-images-master/finetune.py
#!/usr/bin/python """ Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You ...
11,795
42.688889
305
py
tencent-ml-images
tencent-ml-images-master/flags.py
#!/usr/bin/python """ Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You m...
5,301
42.105691
305
py
tencent-ml-images
tencent-ml-images-master/extract_feature.py
#!/usr/bin/python """ Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You m...
3,623
33.188679
305
py
tencent-ml-images
tencent-ml-images-master/image_classification.py
#!/usr/bin/python """ Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You m...
3,620
34.5
305
py
tencent-ml-images
tencent-ml-images-master/train.py
""" Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy o...
11,270
39.253571
305
py
tencent-ml-images
tencent-ml-images-master/models/resnet.py
"""ResNet model Related papers: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Deep Residual Learning for Image Recognition. arXiv:1512.03385 [2] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Identity Mappings in Deep Residual Networks. arXiv: 1603.05027 """ from __future__ import absolute_im...
7,099
33.803922
111
py
tencent-ml-images
tencent-ml-images-master/models/__init__.py
0
0
0
py
tencent-ml-images
tencent-ml-images-master/data_processing/image_preprocessing.py
""" Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy o...
7,279
41.080925
305
py
tencent-ml-images
tencent-ml-images-master/data_processing/dataset.py
""" Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy o...
2,371
39.896552
305
py
tencent-ml-images
tencent-ml-images-master/data_processing/__init__.py
0
0
0
py
tencent-ml-images
tencent-ml-images-master/data/download_urls_multithreading.py
#!/usr/bin/env python """ Tencent is pleased to support the open source community by making Tencent ML-Images available. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. ...
3,639
42.333333
207
py
tencent-ml-images
tencent-ml-images-master/data/tfrecord.py
#!/usr/bin/python import sys import os import tensorflow as tf import numpy as np import imghdr import threading import argparse parser = argparse.ArgumentParser() parser.add_argument("-idx","--indexs", type=str, default="", help="dirs contains train index files") parser.add_argument("-tfs", "--tfrecords", type=str, de...
5,799
33.117647
123
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/main.py
import sys import argparse import os import random import numpy import pandas as pd import torch import torch.backends.cudnn as cudnn import torch.nn.parallel import torch.optim import torch.utils.data import agents import utils numpy.set_printoptions(edgeitems=5, linewidth=160, formatter={'float': '{:0.6f}'.format}) ...
6,839
51.21374
134
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/example.py
# Code reused from: https://github.com/kuangliu/pytorch-cifar import torch import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import net import losses import tools from torchmetrics import AUROC import random import numpy import torchnet as tnt base_seed = 42 ...
8,369
41.923077
164
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/calculate_log.py
from __future__ import print_function import numpy as np import numpy as np def get_curve(dir_name, stypes=['Baseline', 'Gaussian_LDA']): tp, fp = dict(), dict() tnr_at_tpr95 = dict() for stype in stypes: known = np.loadtxt('{}/confidence_{}_In.txt'.format(dir_name, stype), delimiter='\n') ...
3,803
39.042105
95
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/detect.py
from __future__ import print_function import argparse import torch import models import os import losses import data_loader import calculate_log as callog from torchvision import transforms parser = argparse.ArgumentParser(description='PyTorch code: OOD detector') parser.add_argument('--batch_size', type=int, default=...
7,841
44.593023
140
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/data_loader.py
import torch from torchvision import datasets import os def getSVHN(batch_size, TF, data_root='data', train=True, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'svhn')) kwargs.pop('input_size', None) ds = [] if train: train_loader = torch.utils.data.DataLoader( ...
3,956
46.674699
158
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/tools.py
# Code reused from: https://github.com/kuangliu/pytorch-cifar '''Some helper functions for PyTorch, including: - get_mean_and_std: calculate the mean and std value of dataset. - msr_init: net parameter initialization. - progress_bar: progress bar mimic xlua.progress. ''' import os import sys import time _...
2,429
24.578947
68
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/net.py
# Code reused from: https://github.com/kuangliu/pytorch-cifar import math import torch import torch.nn as nn import torch.nn.functional as F import losses class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNor...
5,441
40.861538
107
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/analyze.py
import argparse import os import torch import sys import numpy as np import pandas as pd import random pd.options.display.float_format = '{:,.4f}'.format pd.set_option('display.width', 160) parser = argparse.ArgumentParser(description='Analize results in csv files') parser.add_argument('-p', '--path', default="", ty...
6,074
43.343066
135
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/loaders/image.py
import random import torchvision import torchvision.transforms as transforms from torch.utils.data import DataLoader class ImageLoader: def __init__(self, args): self.args = args self.mnist = False if args.dataset == "cifar10": self.normalize = transforms.Normalize((0.491, 0.4...
4,367
52.925926
151
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/loaders/__init__.py
from .image import *
21
10
20
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/models/densenet.py
# code reused from: https://github.com/kuangliu/pytorch-cifar import math import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes)...
7,490
39.274194
127
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/models/__init__.py
from .proper_resnet import * from .densenet import *
53
17
28
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/models/proper_resnet.py
# code reused from: https://github.com/akamaster/pytorch_resnet_cifar10 ''' Properly implemented ResNet-s for CIFAR10 as described in paper [1]. The implementation and structure of this file is hugely influenced by [2] which is implemented for ImageNet and doesn't have option A for identity. Moreover, most of the imple...
6,110
35.375
130
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/agents/classifier.py
import os import sys import torch import models import loaders import losses import statistics import math import torchnet as tnt import numpy as np import utils class ClassifierAgent: def __init__(self, args): self.args = args self.epoch = None # create dataset image_loaders = lo...
25,791
58.842227
164
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/agents/__init__.py
from .classifier import *
26
12.5
25
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/utils/procedures.py
import os import pickle import torch.nn.parallel import torch.optim import torch.utils.data import torch import torch.nn.functional as F import csv import numpy as np from sklearn import metrics def compute_weights(iterable): return [sum(iterable) / (iterable[i] * len(iterable)) if iterable[i] != 0 else float("in...
6,271
29.595122
126
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/utils/__init__.py
from .procedures import *
26
12.5
25
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/losses/softmax.py
import torch.nn as nn import torch import math class SoftMaxLossFirstPart(nn.Module): def __init__(self, num_features, num_classes, temperature=1.0): super(SoftMaxLossFirstPart, self).__init__() self.num_features = num_features self.num_classes = num_classes self.temperature = temp...
1,694
41.375
111
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/losses/isomaxplus.py
import torch.nn as nn import torch.nn.functional as F import torch class IsoMaxPlusLossFirstPart(nn.Module): """This part replaces the model classifier output layer nn.Linear()""" def __init__(self, num_features, num_classes, temperature=1.0): super(IsoMaxPlusLossFirstPart, self).__init__() se...
2,771
52.307692
169
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/losses/__init__.py
from .softmax import * from .isomax import * from .isomaxplus import *
71
17
25
py
entropic-out-of-distribution-detection
entropic-out-of-distribution-detection-master/losses/isomax.py
import torch.nn as nn import torch.nn.functional as F import torch class IsoMaxLossFirstPart(nn.Module): """This part replaces the model classifier output layer nn.Linear()""" def __init__(self, num_features, num_classes, temperature=1.0): super(IsoMaxLossFirstPart, self).__init__() self.num_f...
2,571
50.44
117
py
stable-continual-learning
stable-continual-learning-master/__init__.py
0
0
0
py
stable-continual-learning
stable-continual-learning-master/stable_sgd/main.py
import os import torch import numpy as np import pandas as pd import torch.nn as nn from stable_sgd.models import MLP, ResNet18 from stable_sgd.data_utils import get_permuted_mnist_tasks, get_rotated_mnist_tasks, get_split_cifar100_tasks from stable_sgd.utils import parse_arguments, DEVICE, init_experiment, end_experim...
4,867
29.425
128
py
stable-continual-learning
stable-continual-learning-master/stable_sgd/utils.py
import uuid import torch import argparse import matplotlib import numpy as np import pandas as pd matplotlib.use('Agg') import seaborn as sns from pathlib import Path import matplotlib.pyplot as plt from external_libs.hessian_eigenthings import compute_hessian_eigenthings TRIAL_ID = uuid.uuid4().hex.upper()[0:6] EXPE...
5,329
35.758621
122
py
stable-continual-learning
stable-continual-learning-master/stable_sgd/data_utils.py
import numpy as np import torch import torchvision from torch.utils.data import TensorDataset, DataLoader import torchvision.transforms.functional as TorchVisionFunc def get_permuted_mnist(task_id, batch_size): """ Get the dataset loaders (train and test) for a `single` task of permuted MNIST. This function will b...
5,087
34.333333
200
py
stable-continual-learning
stable-continual-learning-master/stable_sgd/models.py
import torch import torch.nn as nn from torch.nn.functional import relu, avg_pool2d class MLP(nn.Module): """ Two layer MLP for MNIST benchmarks. """ def __init__(self, hiddens, config): super(MLP, self).__init__() self.W1 = nn.Linear(784, hiddens) self.relu = nn.ReLU(inplace=True) self.dropout_1 = nn.Dro...
3,240
27.182609
87
py
stable-continual-learning
stable-continual-learning-master/stable_sgd/__init__.py
0
0
0
py
stable-continual-learning
stable-continual-learning-master/external_libs/__init__.py
0
0
0
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/lanczos.py
""" Use scipy/ARPACK implicitly restarted lanczos to find top k eigenthings """ import numpy as np import torch from scipy.sparse.linalg import LinearOperator as ScipyLinearOperator from scipy.sparse.linalg import eigsh from warnings import warn def lanczos( operator, num_eigenthings=10, which="LM", m...
2,585
29.785714
87
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/utils.py
""" small helpers """ import shutil import sys import time TOTAL_BAR_LENGTH = 65.0 term_width = shutil.get_terminal_size().columns def log(msg): # TODO make this an actual logger lol print("[hessian_eigenthings] " + str(msg)) last_time = time.time() begin_time = last_time def format_time(seconds): "...
2,585
24.60396
79
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/hvp_operator.py
""" This module defines a linear operator to compute the hessian-vector product for a given pytorch model using subsampled data. """ import torch from .power_iter import Operator, deflated_power_iteration from .lanczos import lanczos class HVPOperator(Operator): """ Use PyTorch autograd for Hessian Vec produc...
6,060
32.486188
86
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/power_iter.py
""" This module contains functions to perform power iteration with deflation to compute the top eigenvalues and eigenvectors of a linear operator """ import numpy as np import torch from .utils import log, progress_bar class Operator: """ maps x -> Lx for a linear operator L """ def __init__(self, s...
4,147
28.841727
87
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/__init__.py
""" Top-level module for hessian eigenvec computation This library is cited in our paper. """ from .power_iter import power_iteration, deflated_power_iteration from .lanczos import lanczos from .hvp_operator import HVPOperator, compute_hessian_eigenthings __all__ = [ "power_iteration", "deflated_power_iteratio...
425
24.058824
66
py
stable-continual-learning
stable-continual-learning-master/external_libs/hessian_eigenthings/spectral_density.py
import numpy as np import torch def _lanczos_step(vec, size, current_draw): pass def lanczos( operator, max_steps=20, tol=1e-6, num_lanczos_vectors=None, init_vec=None, use_gpu=False, ): """ Use the scipy.sparse.linalg.eigsh hook to the ARPACK lanczos algorithm to find the t...
1,764
27.467742
87
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/fc_mnist.py
# Copyright (c) Facebook, Inc. and its 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. """ Training script for permute MNIST experiment. """ from __future__ import print_function import argparse import os import ...
28,906
47.501678
201
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/extract_res.py
from six.moves import cPickle as pickle with open('./ring.pickle', 'rb') as f: data = pickle.load(f)['mean'] print(data.shape) print(data[0][-1][-1])
153
18.25
39
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/conv_split_cifar.py
# Copyright (c) Facebook, Inc. and its 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. """ Training script for split CIFAR 100 experiment. """ from __future__ import print_function import argparse import os impor...
37,561
48.816976
201
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/er_utils.py
import numpy as np def update_reservior(images, labels, episodic_images, episodic_labels, M, N): """ Update the episodic memory with current example using the reservior sampling """ for er_x, er_y in zip(images, labels): if M > N: episodic_images[N] = er_x episodic_label...
4,885
42.625
183
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/vgg_utils.py
# Copyright (c) Facebook, Inc. and its 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 tensorflow as tf import numpy as np def vgg_conv_layer(x, kernel_size, out_channels, stride, var_list, pad...
2,219
36.627119
128
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/utils.py
# Copyright (c) Facebook, Inc. and its 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. """ Define some utility functions """ import numpy as np import tensorflow as tf def clone_variable_list(variable_list): ...
17,295
41.600985
166
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/data_utils.py
# Copyright (c) Facebook, Inc. and its 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. """ Define utility functions for manipulating datasets """ import os import numpy as np import sys from copy import deepcopy ...
21,460
31.665145
130
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/vis_utils.py
# Copyright (c) Facebook, Inc. and its 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. """ Define some utility functions """ import numpy as np import matplotlib matplotlib.use('agg') import matplotlib.colors as ...
4,627
34.875969
128
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/__init__.py
# Copyright (c) Facebook, Inc. and its 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. from .data_utils import construct_permute_mnist, construct_split_mnist, construct_split_cifar, construct_rotate_mnist from .da...
1,214
85.785714
181
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/utils/resnet_utils.py
# Copyright (c) Facebook, Inc. and its 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 tensorflow as tf import numpy as np def _conv(x, kernel_size, out_channels, stride, var_list, pad="SAME", ...
5,216
38.225564
133
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/model/model.py
# Copyright (c) Facebook, Inc. and its 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. """ Model defintion """ import tensorflow as tf import numpy as np import mat...
66,852
48.520741
223
py
stable-continual-learning
stable-continual-learning-master/external_libs/continual_learning_algorithms/model/__init__.py
# Copyright (c) Facebook, Inc. and its 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. from .model import Model
219
30.428571
70
py
snare
snare-master/train.py
import os from pathlib import Path import hydra from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint import numpy as np import random import torch import models from data.dataset import CLIPGraspingDataset from torch.utils.data import DataLoader @hydra.main(config_path="cfgs...
2,139
28.315068
97
py
snare
snare-master/models/single_cls.py
import numpy as np import json import os from pathlib import Path import torch import torch.nn as nn import torch.nn.functional as F from pytorch_lightning import LightningModule import wandb import models.aggregator as agg class SingleClassifier(LightningModule): def __init__(self, cfg, train_ds, val_ds): ...
16,049
36.066975
226
py
snare
snare-master/models/zero_shot_cls.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from models.single_cls import SingleClassifier class ZeroShotClassifier(SingleClassifier): def __init__(self, cfg, train_ds, val_ds): super().__init__(cfg, train_ds, val_ds) self.logit_scale = nn.Parameter(torch...
3,277
31.78
109
py
snare
snare-master/models/aggregator.py
import torch import torch.nn as nn class MaxPool(nn.Module): def __init__(self, cfg): super().__init__() self.cfg = cfg def forward(self, x): x, _ = x.max(dim=-2) # [B 14 512] -> [B 512] return x class MeanPool(nn.Module): def __init__(self, cfg): super().__init_...
1,455
26.471698
86
py
snare
snare-master/models/rotator.py
import numpy as np import collections import json import os import torch import torch.nn as nn import torch.nn.functional as F import wandb from models.single_cls import SingleClassifier class Rotator(SingleClassifier): def __init__(self, cfg, train_ds, val_ds): self.estimate_init_state = False ...
23,767
41.980108
335
py
snare
snare-master/models/__init__.py
from models.single_cls import SingleClassifier from models.zero_shot_cls import ZeroShotClassifier from models.rotator import Rotator names = { # classifiers 'single_cls': SingleClassifier, 'zero_shot_cls': ZeroShotClassifier, # rotators 'rotator': Rotator, }
282
20.769231
51
py
snare
snare-master/scripts/extract_clip_features.py
import os import torch from PIL import Image import numpy as np from numpy import asarray import clip import pickle, gzip, json from tqdm import tqdm # Set filepaths shapenet_images_path = './data/shapenet-images/screenshots' ann_files = ["train.json", "val.json", "test.json"] folds = './amt/folds_adversarial' keys...
1,724
25.953125
89
py
snare
snare-master/scripts/aggregate_results.py
import argparse import json import os import numpy as np import pandas as pd from scipy.stats import ttest_ind from tqdm import tqdm clip_model_types = ['clip-single_cls-maxpool', 'clip-single_cls-meanpool', 'clip-single_cls-random_index', 'clip-single_cls-...
13,282
46.270463
187
py
snare
snare-master/data/dataset.py
import os import json import torch import torch.utils.data import numpy as np import gzip import json class CLIPGraspingDataset(torch.utils.data.Dataset): def __init__(self, cfg, mode='train'): self.total_views = 14 self.cfg = cfg self.mode = mode self.folds = os.path.join(self.cf...
3,365
30.754717
130
py
snare
snare-master/data/__init__.py
0
0
0
py
pySDC
pySDC-master/pySDC/__init__.py
0
0
0
py
pySDC
pySDC-master/pySDC/core/Lagrange.py
import numpy as np from scipy.special import roots_legendre def computeFejerRule(n): """ Compute a Fejer rule of the first kind, using DFT (Waldvogel 2006) Inspired from quadpy (https://github.com/nschloe/quadpy @Nico_Schlömer) Parameters ---------- n : int Number of points for the qu...
7,567
31.34188
111
py
pySDC
pySDC-master/pySDC/core/Nodes.py
import numpy as np from scipy.linalg import eigh_tridiagonal NODE_TYPES = ['EQUID', 'LEGENDRE', 'CHEBY-1', 'CHEBY-2', 'CHEBY-3', 'CHEBY-4'] QUAD_TYPES = ['GAUSS', 'RADAU-LEFT', 'RADAU-RIGHT', 'LOBATTO'] class NodesError(Exception): """Exception class to handle error in NodesGenerator class""" pass class ...
7,344
33.646226
124
py
pySDC
pySDC-master/pySDC/core/Sweeper.py
import logging import numpy as np import scipy.linalg import scipy.optimize as opt from pySDC.core.Errors import ParameterError from pySDC.core.Level import level from pySDC.core.Collocation import CollBase from pySDC.helpers.pysdc_helper import FrozenClass # short helper class to add params as attributes class _Pa...
16,446
37.607981
118
py
pySDC
pySDC-master/pySDC/core/ConvergenceController.py
import logging from pySDC.helpers.pysdc_helper import FrozenClass # short helper class to add params as attributes class Pars(FrozenClass): def __init__(self, params): self.control_order = 0 # integer that determines the order in which the convergence controllers are called self.useMPI = None # ...
17,029
37.355856
120
py
pySDC
pySDC-master/pySDC/core/Collocation.py
import logging import numpy as np from pySDC.core.Nodes import NodesGenerator from pySDC.core.Errors import CollocationError from pySDC.core.Lagrange import LagrangeApproximation class CollBase(object): """ Generic collocation class, that contains everything to do integration over intervals and between n...
8,334
34.021008
108
py
pySDC
pySDC-master/pySDC/core/Common.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Description ----------- Module containing utility classe(s) from which inherit some of the pySDC base classes. """ from pySDC.core.Errors import ReadOnlyError class _MetaRegisterParams(type): """Metaclass for RegisterParams base class""" def __new__(cls, na...
2,606
33.302632
99
py
pySDC
pySDC-master/pySDC/core/Level.py
from pySDC.helpers.pysdc_helper import FrozenClass # short helper class to add params as attributes class _Pars(FrozenClass): def __init__(self, params): self.dt = None self.dt_initial = None self.restol = -1.0 self.nsweeps = 1 self.residual_type = 'full_abs' for k,...
5,436
29.038674
116
py
pySDC
pySDC-master/pySDC/core/Hooks.py
import logging from collections import namedtuple Entry = namedtuple('Entry', ['process', 'time', 'level', 'iter', 'sweep', 'type', 'num_restarts']) # noinspection PyUnusedLocal,PyShadowingBuiltins,PyShadowingNames class hooks(object): """ Hook class to contain the functions called during the controller run...
8,349
33.504132
120
py
pySDC
pySDC-master/pySDC/core/BaseTransfer.py
import logging import scipy.sparse as sp from pySDC.core.Errors import UnlockError from pySDC.helpers.pysdc_helper import FrozenClass from pySDC.core.Lagrange import LagrangeApproximation # short helper class to add params as attributes class _Pars(FrozenClass): def __init__(self, pars): self.finter = F...
8,395
33.838174
119
py
pySDC
pySDC-master/pySDC/core/__init__.py
0
0
0
py
pySDC
pySDC-master/pySDC/core/Controller.py
import logging import os import sys import numpy as np from pySDC.core.BaseTransfer import base_transfer from pySDC.helpers.pysdc_helper import FrozenClass from pySDC.implementations.convergence_controller_classes.check_convergence import CheckConvergence from pySDC.implementations.hooks.default_hook import DefaultHoo...
13,707
39.081871
124
py
pySDC
pySDC-master/pySDC/core/SpaceTransfer.py
import logging from pySDC.helpers.pysdc_helper import FrozenClass # short helper class to add params as attributes class _Pars(FrozenClass): def __init__(self, pars): self.periodic = False self.equidist_nested = True self.iorder = 2 self.rorder = 2 for k, v in pars.items()...
2,000
29.318182
93
py
pySDC
pySDC-master/pySDC/core/Step.py
import logging from pySDC.core import Level as levclass from pySDC.core.BaseTransfer import base_transfer from pySDC.core.Errors import ParameterError from pySDC.helpers.pysdc_helper import FrozenClass # short helper class to add params as attributes class _Pars(FrozenClass): def __init__(self, params): ...
11,352
33.195783
118
py
pySDC
pySDC-master/pySDC/core/Problem.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Description ----------- Module containing the base Problem class for pySDC """ import logging from pySDC.core.Common import RegisterParams class WorkCounter(object): """ Utility class for counting iterations. Contains one attribute `niter` initialized...
3,945
30.31746
135
py
pySDC
pySDC-master/pySDC/core/Errors.py
class DataError(Exception): """ Error Class handling/indicating problems with data types """ pass class ParameterError(Exception): """ Error Class handling/indicating problems with parameters (mostly within dictionaries) """ pass class UnlockError(Exception): """ Error clas...
1,382
16.2875
89
py
pySDC
pySDC-master/pySDC/projects/__init__.py
0
0
0
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/emulate_hard_faults.py
import copy as cp import random as rd import numpy as np # dirty, but easiest: global variables to control the injection and recovery hard_iter = None hard_step = None strategy = None hard_random = 0.0 hard_stats = [] refdata = None def hard_fault_injection(S): """ Injects a node failure and recovers using ...
9,040
31.174377
116
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/postproc_hard_faults_test.py
import matplotlib.pyplot as plt import numpy as np from pylab import rcParams # import os def create_plots(setup, cwd=''): """ Function to create heatmaps for faults at different steps and iterations Args: setup (str): name of the setup (heat or advection) cwd: current working directory...
2,887
28.773196
90
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/postproc_hard_faults_detail.py
import matplotlib matplotlib.use('Agg') import numpy as np import matplotlib.pyplot as plt from pylab import rcParams # import os def create_plots(setup, cwd=''): """ Function to create detailed heatmaps and the iteration plot for a single fault Args: setup (str): name of the setup (heat or ad...
5,794
29.182292
115
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/animate_convergence.py
import matplotlib.pyplot as plt import numpy as np from matplotlib import animation from matplotlib import rc def create_animation(cwd=''): """ Function to create an animated convergence plot Args: cwd: current working directory """ rc('font', family='sans-serif', size=30) rc('legend...
4,289
31.014925
109
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/postproc_boussinesq.py
import matplotlib matplotlib.use('Agg') import numpy as np # import os import matplotlib.pyplot as plt from pylab import rcParams axis_font = {'fontname': 'Arial', 'size': '8', 'family': 'serif'} fs = 8 ms = 8 lw = 2 def create_plots(cwd=''): """ Function to plot the results of the fault-tolerant Boussine...
5,161
29.187135
110
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/hard_faults_detail.py
import numpy as np import pySDC.projects.deprecated.node_failure.emulate_hard_faults as ft from pySDC.helpers.stats_helper import get_sorted, filter_stats from pySDC.implementations.problem_classes.AdvectionEquation_ND_FD import advectionNd from pySDC.implementations.problem_classes.HeatEquation_ND_FD import heatNd_f...
6,315
38.72327
111
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/__init__.py
0
0
0
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/postproc_grayscott.py
import os import numpy as np import pySDC.helpers.plot_helper as plt_helper axis_font = {'fontname': 'Arial', 'size': '8', 'family': 'serif'} fs = 8 ms = 8 lw = 2 def create_plots(cwd=''): """ Function to visualize the results of the Gray-Scott show case Args: cwd: current working directory ...
5,592
32.291667
120
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/grayscott_example.py
import numpy as np import pySDC.projects.node_failure.emulate_hard_faults as ft from pySDC.helpers.stats_helper import get_sorted, filter_stats from pySDC.implementations.problem_classes.GrayScott_1D_FEniCS_implicit import fenics_grayscott from pySDC.implementations.sweeper_classes.generic_LU import generic_LU from p...
5,276
34.655405
112
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/controller_nonMPI_hard_faults.py
from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI from pySDC.implementations.convergence_controller_classes.check_convergence import CheckConvergence from pySDC.projects.node_failure.emulate_hard_faults import hard_fault_injection class controller_nonMPI_hard_faults(controller_...
11,076
36.805461
117
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/boussinesq_example.py
import numpy as np import pySDC.projects.node_failure.emulate_hard_faults as ft from pySDC.helpers.stats_helper import get_sorted, filter_stats from pySDC.implementations.problem_classes.Boussinesq_2D_FD_imex import boussinesq_2d_imex from pySDC.implementations.sweeper_classes.imex_1st_order import imex_1st_order fro...
5,580
35.960265
112
py
pySDC
pySDC-master/pySDC/projects/deprecated/node_failure/hard_faults_test.py
import numpy as np import pySDC.projects.deprecated.node_failure.emulate_hard_faults as ft from pySDC.helpers.stats_helper import get_sorted from pySDC.implementations.problem_classes.AdvectionEquation_ND_FD import advectionNd from pySDC.implementations.problem_classes.HeatEquation_ND_FD import heatNd_forced from pyS...
6,806
38.12069
112
py