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
fairness-indicators
fairness-indicators-master/tensorboard_plugin/tensorboard_plugin_fairness_indicators/version.py
# Copyright 2018 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, ...
721
37
76
py
fairness-indicators
fairness-indicators-master/tensorboard_plugin/tensorboard_plugin_fairness_indicators/plugin_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
7,434
38.131579
94
py
fairness-indicators
fairness-indicators-master/tensorboard_plugin/tensorboard_plugin_fairness_indicators/demo.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
1,508
30.4375
80
py
fairness-indicators
fairness-indicators-master/tensorboard_plugin/tensorboard_plugin_fairness_indicators/__init__.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
689
45
80
py
fairness-indicators
fairness-indicators-master/tensorboard_plugin/tensorboard_plugin_fairness_indicators/summary_v2.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
2,135
38.555556
80
py
fairness-indicators
fairness-indicators-master/fairness_indicators/example_model.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
5,062
33.678082
126
py
fairness-indicators
fairness-indicators-master/fairness_indicators/version.py
# Copyright 2019 Google LLC. All Rights Reserved. # # 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 a...
722
39.166667
74
py
fairness-indicators
fairness-indicators-master/fairness_indicators/__init__.py
# Copyright 2019 Google LLC. All Rights Reserved. # # 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 a...
717
38.888889
74
py
fairness-indicators
fairness-indicators-master/fairness_indicators/example_model_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
4,656
37.808333
80
py
fairness-indicators
fairness-indicators-master/fairness_indicators/tutorial_utils/util.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
7,181
33.695652
81
py
fairness-indicators
fairness-indicators-master/fairness_indicators/tutorial_utils/__init__.py
# Copyright 2019 Google LLC. All Rights Reserved. # # 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 a...
795
45.823529
74
py
fairness-indicators
fairness-indicators-master/fairness_indicators/tutorial_utils/util_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # 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 applica...
10,697
31.516717
98
py
fairness-indicators
fairness-indicators-master/fairness_indicators/remediation/weight_utils_test.py
"""Tests for fairness_indicators.remediation.weight_utils.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections # Standard imports from fairness_indicators.remediation import weight_utils import tensorflow.compat.v1 as tf EvalResult = co...
7,739
33.70852
80
py
fairness-indicators
fairness-indicators-master/fairness_indicators/remediation/__init__.py
# Copyright 2019 Google LLC. All Rights Reserved. # # 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 a...
596
41.642857
74
py
fairness-indicators
fairness-indicators-master/fairness_indicators/remediation/weight_utils.py
"""Utilities to suggest weights based on model analysis results.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from typing import Any, Dict, Mapping, Text import tensorflow_model_analysis as tfma def create_percentage_difference_dictionary( eval...
3,613
36.645833
80
py
XGBOD
XGBOD-master/xgbod_demo.py
''' Demo codes for XGBOD. Author: Yue Zhao notes: the demo code simulates the use of XGBOD with some changes to expedite the execution. Use the full code for the production. ''' import os import random import scipy.io as scio import numpy as np from sklearn.preprocessing import StandardScaler, normalize from sklearn...
8,726
39.21659
79
py
XGBOD
XGBOD-master/plots.py
import os import matplotlib.pyplot as plt import numpy as np # initialize the results of the experiements # arrhythmia prc_gr_arr = [0.5606, 0.5976, 0.5986, 0.6053, 0.6109, 0.6219, 0.6076, 0.6115] prc_ac_arr = [0.5606, 0.5976, 0.5719, 0.5961, 0.6041, 0.5792, 0.6019, 0.6115] prc_rd_arr = [0.5606, 0.5993, 0.5788, 0.6356...
4,491
37.393162
77
py
XGBOD
XGBOD-master/xgbod_full.py
import os import pandas as pd import numpy as np import scipy.io as scio from sklearn.preprocessing import StandardScaler, Normalizer from sklearn.model_selection import train_test_split from sklearn.metrics import roc_auc_score from sklearn.neighbors import LocalOutlierFactor from sklearn.linear_model import Logistic...
12,621
35.479769
118
py
XGBOD
XGBOD-master/models/knn.py
import numpy as np from sklearn.neighbors import NearestNeighbors from sklearn.neighbors import KDTree from sklearn.exceptions import NotFittedError from scipy.stats import scoreatpercentile class Knn(object): ''' Knn class for outlier detection support original knn, average knn, and median knn ''' ...
2,777
29.195652
78
py
XGBOD
XGBOD-master/models/hbos.py
import numpy as np import math from sklearn.preprocessing import MinMaxScaler from scipy.stats import scoreatpercentile class Hbos(object): def __init__(self, bins=10, alpha=0.3, beta=0.5, contamination=0.05): self.bins = bins self.alpha = alpha self.beta = beta self.contamination...
4,636
38.632479
79
py
XGBOD
XGBOD-master/models/utility.py
import numpy as np from scipy.stats import scoreatpercentile from sklearn.metrics import precision_score from sklearn.preprocessing import StandardScaler from sklearn.metrics import roc_auc_score def get_precn(y, y_pred): ''' Utlity function to calculate precision@n :param y: ground truth :param y_pre...
2,271
26.373494
71
py
XGBOD
XGBOD-master/models/generate_TOS.py
import numpy as np import pandas as pd from models.utility import get_precn from sklearn.metrics import roc_auc_score from sklearn.neighbors import NearestNeighbors from sklearn.neighbors import LocalOutlierFactor from sklearn.svm import OneClassSVM from sklearn.ensemble import IsolationForest from PyNomaly import loop...
6,799
34.416667
81
py
XGBOD
XGBOD-master/models/glosh.py
import hdbscan import numpy as np from sklearn.preprocessing import StandardScaler from models.utility import get_precn class Glosh(object): def __init__(self, min_cluster_size=5): self.min_cluster_size = min_cluster_size def fit(self, X_train): self.X_train = X_train def sample_scores(s...
1,118
27.692308
64
py
XGBOD
XGBOD-master/models/__init__.py
0
0
0
py
XGBOD
XGBOD-master/models/select_TOS.py
import random import numpy as np from scipy.stats import pearsonr from models.utility import get_top_n def random_select(X, X_train_new_orig, roc_list, p): s_feature_rand = random.sample(range(0, len(roc_list)), p) X_train_new_rand = X_train_new_orig[:, s_feature_rand] X_train_all_rand = np.concatenate((...
1,777
29.655172
75
py
La-MAML
La-MAML-main/main.py
import importlib import datetime import argparse import time import os import ipdb from tqdm import tqdm import torch from torch.autograd import Variable import parser as file_parser from metrics.metrics import confusion_matrix from utils import misc_utils from main_multi_task import life_experience_iid, eval_iid_tas...
6,437
32.185567
154
py
La-MAML
La-MAML-main/parser.py
# coding=utf-8 import os import argparse def get_parser(): parser = argparse.ArgumentParser(description='Continual learning') parser.add_argument('--expt_name', type=str, default='test_lamaml', help='name of the experiment') # model details parser.add_argument('--model', type=s...
7,611
53.76259
127
py
La-MAML
La-MAML-main/main_multi_task.py
import time import os from tqdm import tqdm import torch from torch.autograd import Variable def eval_iid_tasks(model, tasks, args): model.eval() result = [] for t, task_loader in enumerate(tasks): rt = 0 for (i, (x, y, super_y)) in enumerate(task_loader): if args.cuda: ...
2,818
30.674157
154
py
La-MAML
La-MAML-main/download.py
######################################################################## # # Functions for downloading and extracting data-files from the internet. # # Implemented in Python 3.5 # ######################################################################## # # This file is part of the TensorFlow Tutorials available at: # #...
4,353
32.236641
86
py
La-MAML
La-MAML-main/val_data_format.py
import io import glob import os from shutil import move from os.path import join from os import listdir, rmdir target_folder = './tiny-imagenet-200/val/' val_dict = {} with open('./tiny-imagenet-200/val/val_annotations.txt', 'r') as f: for line in f.readlines(): split_line = line.split('\t') val_d...
882
26.59375
67
py
La-MAML
La-MAML-main/get_data.py
# Copyright 2019-present, IBM Research # 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 os import download import argparse def get_mnist_data(url, data_dir): print("Downloading {} into {}".format(url, data_dir))...
1,423
34.6
152
py
La-MAML
La-MAML-main/metrics/metrics.py
### We directly copied the metrics.py model file from the GEM project https://github.com/facebookresearch/GradientEpisodicMemory # Copyright 2019-present, IBM Research # 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 ...
2,348
28
128
py
La-MAML
La-MAML-main/dataloaders/idataset.py
import numpy as np from PIL import Image import torch from torchvision import datasets, transforms import os from dataloaders import cifar_info class DummyDataset(torch.utils.data.Dataset): def __init__(self, x, y, trsf, pretrsf = None, imgnet_like = False, super_y = None): self.x, self.y = x, y ...
4,465
29.8
105
py
La-MAML
La-MAML-main/dataloaders/cifar_info.py
from __future__ import print_function from PIL import Image import os import os.path import numpy as np import sys if sys.version_info[0] == 2: import cPickle as pickle else: import pickle from torchvision.datasets.vision import VisionDataset from torchvision.datasets.utils import check_integrity, download_an...
8,912
36.607595
100
py
La-MAML
La-MAML-main/dataloaders/task_sampler.py
# coding=utf-8 import numpy as np import torch import warnings import ipdb class MultiTaskSampler(object): ''' MultiTaskSampler: yield a batch of indexes at each iteration. Indexes are calculated by keeping in account 'classes_per_it' and 'num_samples', In fact at every iteration the batch indexes will...
3,363
39.047619
103
py
La-MAML
La-MAML-main/dataloaders/class_incremental_loader.py
import random import numpy as np import torch from PIL import Image from torch.utils.data import DataLoader from torch.utils.data.sampler import SubsetRandomSampler from torchvision import datasets, transforms from dataloaders.idataset import _get_datasets, DummyDataset import random import ipdb # -------- # Datase...
14,676
38.138667
119
py
La-MAML
La-MAML-main/dataloaders/multi_task_loader.py
import random import numpy as np import torch from PIL import Image from torch.utils.data import DataLoader from torch.utils.data.sampler import SubsetRandomSampler from torchvision import datasets, transforms from dataloaders.idataset import _get_datasets, DummyDataset from dataloaders.task_sampler import MultiTaskS...
21,088
41.863821
164
py
La-MAML
La-MAML-main/dataloaders/task_incremental_loader.py
import numpy as np import torch from PIL import Image from torch.utils.data import DataLoader from torchvision import datasets from dataloaders.idataset import DummyArrayDataset import os class IncrementalLoader: def __init__( self, opt, shuffle=True, seed=1, ): self....
3,964
30.468254
120
py
La-MAML
La-MAML-main/utils/misc_utils.py
import datetime import glob import json import os import random import ipdb import numpy as np import torch from tqdm import tqdm def to_onehot(targets, n_classes): onehot = torch.zeros(targets.shape[0], n_classes).to(targets.device) onehot.scatter_(dim=1, index=targets.long().view(-1, 1), value=1.) retu...
4,173
26.642384
103
py
La-MAML
La-MAML-main/model/lamaml.py
import random import numpy as np import ipdb import math import torch import torch.nn as nn from model.lamaml_base import * class Net(BaseNet): def __init__(self, n_inputs, n_outputs, n_tasks, args): super(Net, self).__init__...
3,695
31.421053
126
py
La-MAML
La-MAML-main/model/meta-bgd.py
import random from random import shuffle import numpy as np import ipdb import math import torch from torch.autograd import Variable import torch.nn as nn import model.meta.learner as Learner import model.meta.modelfactory as mf from model.optimizers_lib import optimizers_lib from ast import literal_eval """ This ba...
11,558
34.897516
121
py
La-MAML
La-MAML-main/model/gem.py
### This is a copy of GEM from https://github.com/facebookresearch/GradientEpisodicMemory. ### In order to ensure complete reproducability, we do not change the file and treat it as a baseline. # Copyright 2019-present, IBM Research # All rights reserved. # # This source code is licensed under the license found in th...
9,366
36.468
112
py
La-MAML
La-MAML-main/model/lamaml_base.py
import random from random import shuffle import numpy as np import ipdb import math import torch from torch.autograd import Variable import torch.nn as nn import model.meta.learner as Learner import model.meta.modelfactory as mf from scipy.stats import pearsonr import datetime class BaseNet(torch.nn.Module): def ...
4,545
29.10596
112
py
La-MAML
La-MAML-main/model/lamaml_cifar.py
import random import numpy as np import ipdb import math import torch import torch.nn as nn from model.lamaml_base import * class Net(BaseNet): def __init__(self, n_inputs, n_outputs, n_tasks, args): super(Net, self).__init__(n...
5,732
35.987097
119
py
La-MAML
La-MAML-main/model/agem.py
### This is a pytorch implementation of AGEM based on https://github.com/facebookresearch/agem. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.optim as optim from torch.autograd import Variable i...
9,569
34.576208
112
py
La-MAML
La-MAML-main/model/meralg1.py
# An implementation of MER Algorithm 1 from https://openreview.net/pdf?id=B1gTShAct7 # Copyright 2019-present, IBM Research # 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 torch import torch.nn as nn import torch.o...
6,478
31.888325
159
py
La-MAML
La-MAML-main/model/iid2.py
import torch import numpy as np import random import model.meta.learner as Learner import model.meta.modelfactory as mf import ipdb import sys if not sys.warnoptions: import warnings warnings.simplefilter("once") """ Multi task big batch size, set increment 100 so that it is treated as 1 task with all c...
2,878
30.637363
107
py
La-MAML
La-MAML-main/model/eralg4.py
# An implementation of Experience Replay (ER) with reservoir sampling and without using tasks from Algorithm 4 of https://openreview.net/pdf?id=B1gTShAct7 # Copyright 2019-present, IBM Research # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory o...
9,335
32.342857
154
py
La-MAML
La-MAML-main/model/icarl.py
# Copyright 2017-present, Facebook, Inc. # 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 torch import numpy as np import random import model.meta.learner as Learner import model.meta.modelfactory as mf import sys ...
10,217
40.536585
116
py
La-MAML
La-MAML-main/model/meta/modelfactory.py
import ipdb class ModelFactory(): def __init__(self): pass @staticmethod def get_model(model_type, sizes, dataset='mnist', args=None): net_list = [] if "mnist" in dataset: if model_type=="linear": for i in range(0, len(sizes) - 1): n...
2,530
30.246914
116
py
La-MAML
La-MAML-main/model/meta/learner.py
import math import os import sys import traceback import numpy as np import ipdb import torch from torch import nn from torch.nn import functional as F class Learner(nn.Module): def __init__(self, config, args = None): """ :param config: network config file, type:list of (string, list) :...
10,679
34.364238
143
py
La-MAML
La-MAML-main/model/optimizers_lib/bgd_optimizer.py
import torch from torch.optim.optimizer import Optimizer class BGD(Optimizer): """Implements BGD. A simple usage of BGD would be: for samples, labels in batches: for mc_iter in range(mc_iters): optimizer.randomize_weights() output = model.forward(samples) loss = ...
5,328
46.580357
119
py
La-MAML
La-MAML-main/model/optimizers_lib/optimizers_lib.py
import torch.optim as optim from .bgd_optimizer import BGD def bgd(model, **kwargs): # logger = kwargs.get("logger", None) # assert(logger is not None) bgd_params = { "mean_eta": kwargs.get("mean_eta", 1), "std_init": kwargs.get("std_init", 0.02), "mc_iters": kwargs.get("mc_iters",...
2,099
37.181818
151
py
La-MAML
La-MAML-main/model/optimizers_lib/__init__.py
from .optimizers_lib import *
29
29
29
py
fiery
fiery-master/evaluate.py
from argparse import ArgumentParser import torch from tqdm import tqdm from fiery.data import prepare_dataloaders from fiery.trainer import TrainingModule from fiery.metrics import IntersectionOverUnion, PanopticMetric from fiery.utils.network import preprocess_batch from fiery.utils.instance import predict_instance_...
3,908
36.951456
106
py
fiery
fiery-master/visualise.py
import os from argparse import ArgumentParser from glob import glob import cv2 import numpy as np import torch import torchvision import matplotlib as mpl import matplotlib.pyplot as plt from PIL import Image from fiery.trainer import TrainingModule from fiery.utils.network import NormalizeInverse from fiery.utils.in...
5,095
36.470588
118
py
fiery
fiery-master/train.py
import os import time import socket import torch import pytorch_lightning as pl from pytorch_lightning.plugins import DDPPlugin from fiery.config import get_parser, get_cfg from fiery.data import prepare_dataloaders from fiery.trainer import TrainingModule def main(): args = get_parser().parse_args() cfg = g...
1,540
29.215686
101
py
fiery
fiery-master/fiery/losses.py
import torch import torch.nn as nn import torch.nn.functional as F class SpatialRegressionLoss(nn.Module): def __init__(self, norm, ignore_index=255, future_discount=1.0): super(SpatialRegressionLoss, self).__init__() self.norm = norm self.ignore_index = ignore_index self.future_di...
3,378
33.835052
111
py
fiery
fiery-master/fiery/data.py
import os from PIL import Image import numpy as np import cv2 import torch import torchvision from pyquaternion import Quaternion from nuscenes.nuscenes import NuScenes from nuscenes.utils.splits import create_splits_scenes from nuscenes.utils.data_classes import Box from lyft_dataset_sdk.lyftdataset import LyftDatas...
19,735
41.62635
136
py
fiery
fiery-master/fiery/config.py
import argparse from fvcore.common.config import CfgNode as _CfgNode def convert_to_dict(cfg_node, key_list=[]): """Convert a config node to dictionary.""" _VALID_TYPES = {tuple, list, str, int, float, bool} if not isinstance(cfg_node, _CfgNode): if type(cfg_node) not in _VALID_TYPES: ...
4,568
29.46
114
py
fiery
fiery-master/fiery/metrics.py
from typing import Optional import torch from pytorch_lightning.metrics.metric import Metric from pytorch_lightning.metrics.functional.classification import stat_scores_multiple_classes from pytorch_lightning.metrics.functional.reduction import reduce class IntersectionOverUnion(Metric): """Computes intersection...
11,415
43.59375
117
py
fiery
fiery-master/fiery/trainer.py
import torch import torch.nn as nn import pytorch_lightning as pl from fiery.config import get_cfg from fiery.models.fiery import Fiery from fiery.losses import ProbabilisticLoss, SpatialRegressionLoss, SegmentationLoss from fiery.metrics import IntersectionOverUnion, PanopticMetric from fiery.utils.geometry import cu...
11,419
42.754789
112
py
fiery
fiery-master/fiery/models/distributions.py
import torch import torch.nn as nn from fiery.layers.convolutions import Bottleneck class DistributionModule(nn.Module): """ A convolutional net that parametrises a diagonal Gaussian distribution. """ def __init__( self, in_channels, latent_dim, min_log_sigma, max_log_sigma): super()...
1,871
31.842105
114
py
fiery
fiery-master/fiery/models/future_prediction.py
import torch from fiery.layers.convolutions import Bottleneck from fiery.layers.temporal import SpatialGRU class FuturePrediction(torch.nn.Module): def __init__(self, in_channels, latent_dim, n_gru_blocks=3, n_res_layers=3): super().__init__() self.n_gru_blocks = n_gru_blocks # Convoluti...
1,488
39.243243
97
py
fiery
fiery-master/fiery/models/fiery.py
import torch import torch.nn as nn from fiery.models.encoder import Encoder from fiery.models.temporal_model import TemporalModelIdentity, TemporalModel from fiery.models.distributions import DistributionModule from fiery.models.future_prediction import FuturePrediction from fiery.models.decoder import Decoder from fi...
15,090
43.385294
118
py
fiery
fiery-master/fiery/models/temporal_model.py
import torch.nn as nn from fiery.layers.temporal import Bottleneck3D, TemporalBlock class TemporalModel(nn.Module): def __init__( self, in_channels, receptive_field, input_shape, start_out_channels=64, extra_in_channels=0, n_spatial_layers_between_temporal_layers=0, use_pyramid_pooling=Tr...
2,120
32.666667
104
py
fiery
fiery-master/fiery/models/encoder.py
import torch.nn as nn from efficientnet_pytorch import EfficientNet from fiery.layers.convolutions import UpsamplingConcat class Encoder(nn.Module): def __init__(self, cfg, D): super().__init__() self.D = D self.C = cfg.OUT_CHANNELS self.use_depth_distribution = cfg.USE_DEPTH_DIST...
3,910
36.247619
119
py
fiery
fiery-master/fiery/models/decoder.py
import torch.nn as nn from torchvision.models.resnet import resnet18 from fiery.layers.convolutions import UpsamplingAdd class Decoder(nn.Module): def __init__(self, in_channels, n_classes, predict_future_flow): super().__init__() backbone = resnet18(pretrained=False, zero_init_residual=True) ...
3,676
38.967391
106
py
fiery
fiery-master/fiery/layers/convolutions.py
from collections import OrderedDict from functools import partial import torch import torch.nn as nn import torch.nn.functional as F class ConvBlock(nn.Module): """2D convolution followed by - an optional normalisation (batch norm or instance norm) - an optional activation (ReLU, LeakyReLU, or ...
7,593
34.32093
114
py
fiery
fiery-master/fiery/layers/temporal.py
from collections import OrderedDict import torch import torch.nn as nn from fiery.layers.convolutions import ConvBlock from fiery.utils.geometry import warp_features class SpatialGRU(nn.Module): """A GRU cell that takes an input tensor [BxTxCxHxW] and an optional previous state and passes a convolutional ga...
11,152
38.549645
120
py
fiery
fiery-master/fiery/utils/visualisation.py
import numpy as np import torch import matplotlib.pylab from fiery.utils.instance import predict_instance_segmentation_and_trajectories DEFAULT_COLORMAP = matplotlib.pylab.cm.jet def flow_to_image(flow: np.ndarray, autoscale: bool = False) -> np.ndarray: """ Applies colour map to flow which should be a 2 ch...
12,488
32.572581
121
py
fiery
fiery-master/fiery/utils/network.py
import torch import torch.nn as nn import torchvision def pack_sequence_dim(x): b, s = x.shape[:2] return x.view(b * s, *x.shape[2:]) def unpack_sequence_dim(x, b, s): return x.view(b, s, *x.shape[1:]) def preprocess_batch(batch, device, unsqueeze=False): for key, value in batch.items(): if...
1,236
27.113636
89
py
fiery
fiery-master/fiery/utils/geometry.py
import PIL import numpy as np import torch from pyquaternion import Quaternion def resize_and_crop_image(img, resize_dims, crop): # Bilinear resizing followed by cropping img = img.resize(resize_dims, resample=PIL.Image.BILINEAR) img = img.crop(crop) return img def update_intrinsics(intrinsics, top...
10,875
33.526984
117
py
fiery
fiery-master/fiery/utils/instance.py
from typing import Tuple import torch import torch.nn.functional as F import numpy as np from scipy.optimize import linear_sum_assignment from fiery.utils.geometry import mat2pose_vec, pose_vec2mat, warp_features # set ignore index to 0 for vis def convert_instance_mask_to_center_and_offset_label(instance_img, futu...
13,871
40.657658
119
py
fiery
fiery-master/fiery/utils/lyft_splits.py
TRAIN_LYFT_INDICES = [1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 55, 56, 59, 60, 62, 63, 65, 68, 69, 70, 71, 7...
1,113
64.529412
86
py
public-apis
public-apis-master/scripts/validate/format.py
# -*- coding: utf-8 -*- import re import sys from string import punctuation from typing import List, Tuple, Dict # Temporary replacement # The descriptions that contain () at the end must adapt to the new policy later punctuation = punctuation.replace('()', '') anchor = '###' auth_keys = ['apiKey', 'OAuth', 'X-Masha...
8,464
29.44964
168
py
public-apis
public-apis-master/scripts/validate/__init__.py
# -*- coding: utf-8 -*- from validate import format from validate import links
80
15.2
27
py
public-apis
public-apis-master/scripts/validate/links.py
# -*- coding: utf-8 -*- import re import sys import random from typing import List, Tuple import requests from requests.models import Response def find_links_in_text(text: str) -> List[str]: """Find links in a text and return a list of URLs.""" link_pattern = re.compile(r'((?:https?://|www\d{0,3}[.]|[a-z0-...
8,022
28.281022
211
py
public-apis
public-apis-master/scripts/tests/test_validate_links.py
# -*- coding: utf-8 -*- import unittest from validate.links import find_links_in_text from validate.links import check_duplicate_links from validate.links import fake_user_agent from validate.links import get_host_from_link from validate.links import has_cloudflare_protection class FakeResponse(): def __init__(...
5,725
32.098266
100
py
public-apis
public-apis-master/scripts/tests/__init__.py
# -*- coding: utf-8 -*-
24
11.5
23
py
public-apis
public-apis-master/scripts/tests/test_validate_format.py
# -*- coding: utf-8 -*- import unittest from validate.format import error_message from validate.format import get_categories_content from validate.format import check_alphabetical_order from validate.format import check_title from validate.format import check_description, max_description_length from validate.format i...
18,154
37.875803
155
py
LiDAR2INS
LiDAR2INS-master/eigen3/debug/gdb/printers.py
# -*- coding: utf-8 -*- # This file is part of Eigen, a lightweight C++ template library # for linear algebra. # # Copyright (C) 2009 Benjamin Schindler <[email protected]> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this ...
9,617
29.533333
160
py
LiDAR2INS
LiDAR2INS-master/eigen3/debug/gdb/__init__.py
# Intentionally empty
22
10.5
21
py
LiDAR2INS
LiDAR2INS-master/eigen3/scripts/relicense.py
# This file is part of Eigen, a lightweight C++ template library # for linear algebra. # # Copyright (C) 2012 Keir Mierle <[email protected]> # # This Source Code Form is subject to the terms of the Mozilla # Public License v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at http://m...
2,368
32.842857
77
py
LiDAR2INS
LiDAR2INS-master/ceres/scripts/make_docs.py
#!/usr/bin/python # encoding: utf-8 # # Ceres Solver - A fast non-linear least squares minimizer # Copyright 2015 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
4,409
34.28
87
py
LiDAR2INS
LiDAR2INS-master/ceres/docs/source/conf.py
# -*- coding: utf-8 -*- # # Ceres Solver documentation build configuration file, created by # sphinx-quickstart on Sun Jan 20 20:34:07 2013. # # 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. # ...
7,957
31.748971
94
py
LiDAR2INS
LiDAR2INS-master/ceres/internal/ceres/schur_eliminator_template.py
# Ceres Solver - A fast non-linear least squares minimizer # Copyright 2017 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source cod...
5,928
37.00641
86
py
LiDAR2INS
LiDAR2INS-master/ceres/internal/ceres/generate_bundle_adjustment_tests.py
# Ceres Solver - A fast non-linear least squares minimizer # Copyright 2018 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source cod...
11,723
42.910112
82
py
LiDAR2INS
LiDAR2INS-master/ceres/internal/ceres/partitioned_matrix_view_template.py
# Ceres Solver - A fast non-linear least squares minimizer # Copyright 2015 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source cod...
5,983
38.111111
101
py
LiDAR2INS
LiDAR2INS-master/ceres/internal/ceres/generate_template_specializations.py
# Ceres Solver - A fast non-linear least squares minimizer # Copyright 2015 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source cod...
9,677
38.182186
80
py
xgboost
xgboost-master/tests/ci_build/test_r_package.py
"""Utilities for packaging R code and running tests.""" import argparse import os import shutil import subprocess from pathlib import Path from platform import system from test_utils import R_PACKAGE, ROOT, DirectoryExcursion, cd, print_time, record_time def get_mingw_bin() -> str: return os.path.join("c:/rtools...
10,217
31.438095
88
py
xgboost
xgboost-master/tests/ci_build/tidy.py
#!/usr/bin/env python import argparse import json import os import re import shutil import subprocess import sys from multiprocessing import Pool, cpu_count from time import time import yaml def call(args): '''Subprocess run wrapper.''' completed = subprocess.run(args, stdout=s...
10,858
34.486928
82
py
xgboost
xgboost-master/tests/ci_build/change_version.py
""" 1. Modify ``CMakeLists.txt`` in source tree and ``python-package/xgboost/VERSION`` if needed, run CMake . If this is a RC release, the Python version has the form <major>.<minor>.<patch>rc1 2. Modify ``DESCRIPTION`` and ``configure.ac`` in R-package. Run ``autoreconf``. 3. Run ``mvn`` in ``jvm-packages`` If...
5,198
31.49375
88
py
xgboost
xgboost-master/tests/ci_build/lint_python.py
import argparse import os import pathlib import subprocess import sys from collections import Counter from multiprocessing import Pool, cpu_count from typing import Dict, List, Tuple from test_utils import PY_PACKAGE, ROOT, cd, print_time, record_time class LintersPaths: """The paths each linter run on.""" ...
8,177
29.401487
96
py
xgboost
xgboost-master/tests/ci_build/rename_whl.py
import os import sys from contextlib import contextmanager @contextmanager def cd(path): path = os.path.normpath(path) cwd = os.getcwd() os.chdir(path) print("cd " + path) try: yield path finally: os.chdir(cwd) if len(sys.argv) != 4: print('Usage: {} [wheel to rename] [co...
1,240
25.978261
96
py
xgboost
xgboost-master/tests/ci_build/test_utils.py
"""Utilities for the CI.""" import os from datetime import datetime, timedelta from functools import wraps from typing import Any, Callable, Dict, TypedDict, TypeVar, Union class DirectoryExcursion: def __init__(self, path: Union[os.PathLike, str]) -> None: self.path = path self.curdir = os.path.n...
2,141
24.807229
82
py
xgboost
xgboost-master/tests/python/test_data_iterator.py
from typing import Callable, Dict, List import numpy as np import pytest from hypothesis import given, settings, strategies from scipy.sparse import csr_matrix import xgboost as xgb from xgboost import testing as tm from xgboost.data import SingleBatchInternalIter as SingleBatch from xgboost.testing import IteratorFo...
5,556
29.201087
89
py
xgboost
xgboost-master/tests/python/test_dmatrix.py
import os import tempfile import numpy as np import pytest import scipy.sparse from hypothesis import given, settings, strategies from scipy.sparse import csr_matrix, rand import xgboost as xgb from xgboost import testing as tm from xgboost.testing.data import np_dtypes rng = np.random.RandomState(1) dpath = 'demo/...
16,765
34.748401
95
py
xgboost
xgboost-master/tests/python/test_survival.py
import json import os from typing import List, Optional, Tuple, cast import numpy as np import pytest import xgboost as xgb from xgboost import testing as tm dpath = tm.data_dir(__file__) @pytest.fixture(scope="module") def toy_data() -> Tuple[xgb.DMatrix, np.ndarray, np.ndarray]: X = np.array([1, 2, 3, 4, 5])...
5,895
33.887574
87
py
xgboost
xgboost-master/tests/python/test_interaction_constraints.py
import numpy as np import pytest import xgboost from xgboost import testing as tm dpath = 'demo/data/' rng = np.random.RandomState(1994) class TestInteractionConstraints: def run_interaction_constraints( self, tree_method, feature_names=None, interaction_constraints='[[0, 1]]' ): x1 = np.ran...
4,864
39.882353
91
py