python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import argparse import math import json import re from datetime import datetime from typing import Any, Dict, Optional, Union import matplotlib.pypl...
AutoCAT-main
src/cyclone_data/draw_figure.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. from typing import Any, Dict, Optional import torch import torch.nn as nn from cache_ppo_mlp_model import CachePPOMlpModel from cache_ppo_lstm_model...
AutoCAT-main
src/rlmeta/model_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import logging from typing import Dict, Optional, Sequence import hydra from omegaconf import DictConfig, OmegaConf import numpy as np import torc...
AutoCAT-main
src/rlmeta/sample_cyclone.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import copy import logging import os import time import hydra from omegaconf import DictConfig, OmegaConf import torch import torch.multiprocessing ...
AutoCAT-main
src/rlmeta/train_ppo_attack.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. # Author: Mulong Luo # date: 2022.6.28 # usage: to train the svm classifier of cycloen by feeding # the date from TextbookAgent as malicious traces ...
AutoCAT-main
src/rlmeta/cyclone_svm_trainer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import logging import os import sys from typing import Dict, Optional, Sequence, Union import hydra from omegaconf import DictConfig, OmegaConf imp...
AutoCAT-main
src/rlmeta/sample_cchunter.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. from rlmeta.core.callbacks import EpisodeCallbacks from rlmeta.core.types import Action, TimeStep class MetricCallbacks(EpisodeCallbacks): def _...
AutoCAT-main
src/rlmeta/metric_callbacks.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import os import sys from typing import Dict, List, Tuple import gym import torch import torch.nn as nn import torch.nn.functional as F import rlm...
AutoCAT-main
src/rlmeta/cache_ppo_transformer_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. from cProfile import label from tkinter import font import matplotlib.pyplot as plt import pandas as pd import numpy as np import numpy as np import m...
AutoCAT-main
src/rlmeta/cchunter_plot.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import logging import os import sys from typing import Dict, Optional, Sequence, Union import hydra from omegaconf import DictConfig, OmegaConf imp...
AutoCAT-main
src/rlmeta/sample_cchunter_textbook.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. # script for plotting figure on paper import logging from typing import Dict #import hydra #import torch #import torch.nn import os import sys sys...
AutoCAT-main
src/rlmeta/plot_cchunter.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import logging from typing import Dict, Optional import hydra from omegaconf import DictConfig, OmegaConf import torch import torch.nn import rlme...
AutoCAT-main
src/rlmeta/sample_attack.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import copy import logging import os import time import hydra from omegaconf import DictConfig, OmegaConf import torch import torch.multiprocessing ...
AutoCAT-main
src/rlmeta/train_ppo_cchunter.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import argparse import math import json import re from datetime import datetime from typing import Any, Dict, Optional, Union import matplotlib.pypl...
AutoCAT-main
src/rlmeta/plot_figure_remap.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import os import sys from typing import Dict, List, Tuple import gym import torch import torch.nn as nn import torch.nn.functional as F import rlm...
AutoCAT-main
src/rlmeta/cache_ppo_mlp_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import logging import os import sys from typing import Dict, Optional, Sequence, Union import hydra from omegaconf import DictConfig, OmegaConf imp...
AutoCAT-main
src/rlmeta/sample_cyclone_textbook.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import os import sys from typing import Any, Dict from rlmeta.envs.env import Env, EnvFactory from rlmeta.envs.gym_wrapper import GymWrapper sys.pa...
AutoCAT-main
src/rlmeta/cache_env_wrapper.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import os import sys from typing import Dict, List, Tuple import gym import torch import torch.nn as nn import torch.nn.functional as F import rlm...
AutoCAT-main
src/rlmeta/cache_ppo_lstm_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. # a textbook prime probe attacker that serve as the agent # which can have high reward for the cache guessing game # used to generate the attack sequ...
AutoCAT-main
src/rlmeta/textbook_attacker.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import seaborn as sns data=[[2, 6, 1, 1, 1, 2, 1, 1, 9, 5, 1, 4, 1, 8, 0, 2, 2, 0, 6, 1, 2, 2, 0, 0, 1, 2, 1, 1, 2, 4, 3, 3, 1, 0, 1, 2, 0, 3, 2, 1],...
AutoCAT-main
src/rlmeta/plot_heatmap.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import copy import logging import os import time import hydra from omegaconf import DictConfig, OmegaConf import torch import torch.multiprocessing ...
AutoCAT-main
src/rlmeta/train_ppo_cyclone.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. import argparse import json import re from tabulate import tabulate from typing import Any, Dict, Optional, Union from rlmeta.utils.stats_dict impor...
AutoCAT-main
src/rlmeta/data/show_log.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. #!/usr/bin/env python import matplotlib.pyplot as plt fontaxes = { 'family': 'Arial', 'color': 'black', 'weight': 'bold', ...
AutoCAT-main
src/stealthy_streamline/plot/plot_error_rate.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This software may be used and distributed according to the terms of the # GNU General Public License version 2. #!/usr/bin/env python Error_all = [[ 0 for i in range(5)] for j in range(5)] for test_idx in range(5): for bandwidth_idx in range (1,6): ...
AutoCAT-main
src/stealthy_streamline/process_error_rate_1thread/collect_stat.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 pathlib import Path import argparse import json import os import random import signal import sys import time import ur...
barlowtwins-main
evaluate.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 torch from torchvision.models.resnet import resnet50 as _resnet50 dependencies = ['torch', 'torchvision'] def res...
barlowtwins-main
hubconf.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 pathlib import Path import argparse import json import math import os import random import signal import subprocess im...
barlowtwins-main
main.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import datetime import logging import math import time import sys from torch.distributed.distributed_c10d import reduce from utils.ap_calculator import APCalculator from utils.misc import SmoothedValue from utils.dist import ( all_gather_dict, all...
3detr-main
engine.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch def build_optimizer(args, model): params_with_decay = [] params_without_decay = [] for name, param in model.named_parameters(): if param.requires_grad is False: continue if args.filter_biases_wd and (len(param.sha...
3detr-main
optimizer.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.nn as nn import numpy as np import torch.nn.functional as F from utils.box_util import generalized_box3d_iou from utils.dist import all_reduce_average from utils.misc import huber_loss from scipy.optimize import linear_sum_assignment class M...
3detr-main
criterion.py
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import os import sys import pickle import numpy as np import torch from torch.multiprocessing import set_start_method from torch.utils.data import DataLoader, DistributedSampler # 3DETR codebase specific imports from datasets import build_dataset fro...
3detr-main
main.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Modified from https://github.com/facebookresearch/votenet Dataset for 3D object detection on SUN RGB-D (with support of vote supervision). A sunrgbd oriented bounding box is parameterized by (cx,cy,cz), (l,w,h) -- (dx,dy,dz) in upright depth coord (Z is up, Y i...
3detr-main
datasets/sunrgbd.py
# Copyright (c) Facebook, Inc. and its affiliates. from .scannet import ScannetDetectionDataset, ScannetDatasetConfig from .sunrgbd import SunrgbdDetectionDataset, SunrgbdDatasetConfig DATASET_FUNCTIONS = { "scannet": [ScannetDetectionDataset, ScannetDatasetConfig], "sunrgbd": [SunrgbdDetectionDataset, Sunrgb...
3detr-main
datasets/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Modified from https://github.com/facebookresearch/votenet Dataset for object bounding box regression. An axis aligned bounding box is parameterized by (cx,cy,cz) and (dx,dy,dz) where (cx,cy,cz) is the center point of the box, dx is the x-axis length of the box. "...
3detr-main
datasets/scannet.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import numpy as np from collections import deque from typing import List from utils.dist import is_distributed, barrier, all_reduce_sum def my_worker_init_fn(worker_id): np.random.seed(np.random.get_state()[1][0] + worker_id) @torch.jit.ignore def ...
3detr-main
utils/misc.py
# Copyright (c) Facebook, Inc. and its affiliates. from setuptools import setup, Extension from Cython.Build import cythonize import numpy as np # hacky way to find numpy include path # replace with actual path if this does not work np_include_path = np.__file__.replace("__init__.py", "core/include/") INCLUDE_PATH =...
3detr-main
utils/cython_compile.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Generic Code for Object Detection Evaluation Input: For each class: For each image: Predictions: box, score Groundtruths: box Output: For each class: precision-recal and average precision Autho...
3detr-main
utils/eval_det.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Utility functions for processing point clouds. Author: Charles R. Qi and Or Litany """ import os import sys import torch # Point cloud IO import numpy as np from plyfile import PlyData, PlyElement # Mesh IO import trimesh # -----------------------------------...
3detr-main
utils/pc_util.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import os from utils.dist import is_primary def save_checkpoint( checkpoint_dir, model_no_ddp, optimizer, epoch, args, best_val_metrics, filename=None, ): if not is_primary(): return if filename is None: ...
3detr-main
utils/io.py
# Copyright (c) Facebook, Inc. and its affiliates. import os from urllib import request import torch import pickle ## Define the weights you want and where to store them dataset = "scannet" encoder = "_masked" # or "" epoch = 1080 base_url = "https://dl.fbaipublicfiles.com/3detr/checkpoints" local_dir = "/tmp/" ###...
3detr-main
utils/download_weights.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np # boxes are axis aigned 2D boxes of shape (n,5) in FLOAT numbers with (x1,y1,x2,y2,score) """ Ref: https://www.pyimagesearch.com/2015/02/16/faster-non-maximum-suppression-python/ Ref: https://github.com/vickyboy47/nms-python/blob/master/nms.py """...
3detr-main
utils/nms.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch try: from tensorboardX import SummaryWriter except ImportError: print("Cannot import tensorboard. Will log to txt files only.") SummaryWriter = None from utils.dist import is_primary class Logger(object): def __init__(self, log_dir=Non...
3detr-main
utils/logger.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np def check_aspect(crop_range, aspect_min): xy_aspect = np.min(crop_range[:2]) / np.max(crop_range[:2]) xz_aspect = np.min(crop_range[[0, 2]]) / np.max(crop_range[[0, 2]]) yz_aspect = np.min(crop_range[1:]) / np.max(crop_range[1:]) re...
3detr-main
utils/random_cuboid.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Utilities for bounding box manipulation and GIoU. """ import torch from torchvision.ops.boxes import box_area from typing import List try: from box_intersection import batch_intersect except ImportError: print("Could not import cythonize...
3detr-main
utils/box_ops3d.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Helper functions for calculating 2D and 3D bounding box IoU. Collected and written by Charles R. Qi Last modified: Apr 2021 by Ishan Misra """ import torch import numpy as np from scipy.spatial import ConvexHull, Delaunay from utils.misc import to_list_1d, to_lis...
3detr-main
utils/box_util.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper functions and class to calculate Average Precisions for 3D object detection. """ import logging import os import sys from collectio...
3detr-main
utils/ap_calculator.py
# Copyright (c) Facebook, Inc. and its affiliates. import pickle import torch import torch.distributed as dist def is_distributed(): if not dist.is_available() or not dist.is_initialized(): return False return True def get_rank(): if not is_distributed(): return 0 return dist.get_ra...
3detr-main
utils/dist.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from functools import partial import numpy as np import torch import torch.nn as nn from third_party.pointnet2.pointnet2_modules import PointnetSAModuleVotes from third_party.pointnet2.pointnet2_utils import furthest_point_sample from utils.pc_util import ...
3detr-main
models/model_3detr.py
# Copyright (c) Facebook, Inc. and its affiliates. from .model_3detr import build_3detr MODEL_FUNCS = { "3detr": build_3detr, } def build_model(args, dataset_config): model, processor = MODEL_FUNCS[args.model_name](args, dataset_config) return model, processor
3detr-main
models/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Modified from DETR Transformer class. Copy-paste from torch.nn.Transformer with modifications: * positional encodings are passed in MHattention * extra LN at the end of encoder is removed * decoder returns a stack of activations fro...
3detr-main
models/transformer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Various positional encodings for the transformer. """ import math import torch from torch import nn import numpy as np from utils.pc_util import shift_scale_points class PositionEmbeddingCoordsSine(nn.Module): def __init__( self, ...
3detr-main
models/position_embedding.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch.nn as nn from functools import partial import copy class BatchNormDim1Swap(nn.BatchNorm1d): """ Used for nn.Transformer that uses a HW x N x C rep """ def forward(self, x): """ x: HW x N x C permute to N x C x HW ...
3detr-main
models/helpers.py
# Copyright (c) Facebook, Inc. and its affiliates. ''' Modified based on Ref: https://github.com/erikwijmans/Pointnet2_PyTorch ''' import torch import torch.nn as nn from typing import List, Tuple class SharedMLP(nn.Sequential): def __init__( self, args: List[int], *, ...
3detr-main
third_party/pointnet2/pytorch_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension import glob import os.path as osp this_dir ...
3detr-main
third_party/pointnet2/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. ''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch ''' from __future__ import ( division, absolute_import, with_statement, print_function, unicode_literals, ) import torch from torch.autograd import Function import torch.nn as ...
3detr-main
third_party/pointnet2/pointnet2_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. ''' Testing customized ops. ''' import torch from torch.autograd import gradcheck import numpy as np import os import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(BASE_DIR) import pointnet2_utils def test_interpolation_grad(): batch...
3detr-main
third_party/pointnet2/pointnet2_test.py
# Copyright (c) Facebook, Inc. and its affiliates. ''' Pointnet2 layers. Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch Extended with the following: 1. Uniform sampling in each local region (sample_uniformly) 2. Return sampled points indices to support votenet. ''' import torch import torch.nn as ...
3detr-main
third_party/pointnet2/pointnet2_modules.py
# Copyright (c) 2019-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. # from contextual.contextual_models import * from contextual.contextual_linucb import * from tqdm import trange from collections ...
ContextualBanditsAttacks-main
isoexp/test_distance_attack_one_user.py
# Copyright (c) 2019-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 sys sys.path.append('/private/home/broz/workspaces/bandits_attacks') import isoexp.contextual.contextual_models as arm...
ContextualBanditsAttacks-main
isoexp/devfair_reward_attack.py
# Copyright (c) 2019-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. # from isoexp.contextual.contextual_models import RandomContextualLinearArms from isoexp.contextual.contextual_linucb import * fro...
ContextualBanditsAttacks-main
isoexp/main_attacked_context.py
# Copyright (c) 2019-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. # __version__ = '0.0.dev0'
ContextualBanditsAttacks-main
isoexp/__init__.py
# Copyright (c) 2019-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. # def in_hull(points, x): n_points = len(points) n_dim = len(x) c = np.zeros(n_points) A = np.r_[points.T, np.on...
ContextualBanditsAttacks-main
isoexp/main_attack_one_user.py
# Copyright (c) 2019-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 sys sys.path.append('/isoexp') import numpy as np import isoexp.mab.arms as arms import pickle from isoexp.mab.smab_algs...
ContextualBanditsAttacks-main
isoexp/main_mab.py
# Copyright (c) 2019-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 numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pickle import tikzplotlib im...
ContextualBanditsAttacks-main
isoexp/parse_reward_attack.py
# Copyright (c) 2019-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. # from isoexp.contextual.contextual_models import RandomContextualLinearArms from isoexp.contextual.contextual_linucb import * fr...
ContextualBanditsAttacks-main
isoexp/main_attack_reward.py
# Copyright (c) 2019-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. # __version__ = '0.0.dev0'
ContextualBanditsAttacks-main
isoexp/contextual/__init__.py
# Copyright (c) 2019-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 numpy as np import cvxpy as cp from scipy.optimize import minimize class RandomArm(object): def __init__(self, ini...
ContextualBanditsAttacks-main
isoexp/contextual/contextual_linucb.py
# Copyright (c) 2019-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 numpy as np import pickle import matplotlib.pyplot as plt class ContextualLinearMABModel(object): def __init__(sel...
ContextualBanditsAttacks-main
isoexp/contextual/contextual_models.py
# Copyright (c) 2019-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 numpy as np import cvxpy as cp from scipy.optimize import minimize class RandomArm(object): def __init__(self, ini...
ContextualBanditsAttacks-main
isoexp/linear/linearbandit.py
# Copyright (c) 2019-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 numpy as np class LinearMABModel(object): def __init__(self, random_state=0, noise=0.1, features=None, theta=None)...
ContextualBanditsAttacks-main
isoexp/linear/linearmab_models.py
# Copyright (c) 2019-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 numpy as np from .linearmab_models import LinearMABModel class ColdStartFromDatasetModel(LinearMABModel): def __in...
ContextualBanditsAttacks-main
isoexp/linear/coldstart.py
# Copyright (c) 2019-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 math import numpy as np import sys import numpy.random as npr from tqdm import tqdm class contextEpsGREEDY(): """ ...
ContextualBanditsAttacks-main
isoexp/mab/contextual_mab_algs.py
# Copyright (c) 2019-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 numpy as np import math from scipy.stats import truncnorm class ContextualLinearMABModel(object): def __init__(sel...
ContextualBanditsAttacks-main
isoexp/mab/contextual_arms.py
# Copyright (c) 2019-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 numpy as np import sys import numpy.random as npr import cvxpy as cp from tqdm import trange from tqdm import tqdm def ...
ContextualBanditsAttacks-main
isoexp/mab/smab_algs.py
# Copyright (c) 2019-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 numpy as np import math from scipy.stats import truncnorm class AbstractArm(object): def __init__(self, mean, varia...
ContextualBanditsAttacks-main
isoexp/mab/arms.py
# Copyright (c) 2019-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. # __version__ = '0.0.dev0'
ContextualBanditsAttacks-main
isoexp/mab/__init__.py
# Copyright (c) 2019-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 sys sys.path.append('/isoexp') import numpy as np import isoexp.mab.arms as arms import pickle from isoexp.mab.smab_algs...
ContextualBanditsAttacks-main
isoexp/mab/main_mab.py
# Copyright (c) 2019-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. # #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 3 23:30:58 2019 @author: evrardgarcelon """ import nump...
ContextualBanditsAttacks-main
examples/parse_real_data_results.py
# Copyright (c) 2019-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 numpy as np from isoexp.monenvs import Env1 from sklearn.isotonic import IsotonicRegression import matplotlib.pyplot as p...
ContextualBanditsAttacks-main
examples/show_confidence.py
# Copyright (c) 2019-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. # #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 1 14:23:15 2019 @author: evrardgarcelon """ import nump...
ContextualBanditsAttacks-main
examples/untitled0.py
# Copyright (c) 2019-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 datetime import json import logging import os import pickle from collections import namedtuple import numpy as np from ...
ContextualBanditsAttacks-main
examples/linear_contextual_bandit.py
# Copyright (c) 2019-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 numpy as np from isoexp.linear.linearbandit import EfficientLinearBandit, LinearBandit, LinPHE from isoexp.conservative....
ContextualBanditsAttacks-main
examples/main_linearmab.py
# Copyright (c) 2019-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 datetime import json import os import pickle import sys from collections import namedtuple import numpy as np from jobl...
ContextualBanditsAttacks-main
examples/experiment_one_context.py
# Copyright (c) 2019-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 numpy as np import isoexp.mab.arms as arms import pickle from isoexp.mab.smab_algs import UCB1, UCBV, BootstrapedUCB, PH...
ContextualBanditsAttacks-main
examples/main_mab.py
# Copyright (c) 2019-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 datetime import json import os import pickle import sys from collections import namedtuple import numpy as np from jobl...
ContextualBanditsAttacks-main
examples/experiment_all_contexts.py
# Copyright (c) 2019-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 numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pickle import tikzplotlib imp...
ContextualBanditsAttacks-main
examples/parse_linear_results.py
# Copyright (c) 2019-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 sys sys.path[0] = '/Users/evrard/Desktop/monotone_mabs/' import numpy as np import isoexp.linear.linearmab_models as arm...
ContextualBanditsAttacks-main
examples/runner_GLM.py
# Copyright (c) 2019-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 numpy as np import os from cycler import cycler import matplotlib.pyplot as plt import tikzplotlib n = 9 # Number of c...
ContextualBanditsAttacks-main
examples/merge_real_data_results.py
# Copyright (c) 2019-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. # #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 22 15:37:36 2019 @author: evrard """ filename = '/Users...
ContextualBanditsAttacks-main
examples/reader_GLM.py
# Copyright (c) 2019-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. # from isoexp.isotonicsim import LIsotron import matplotlib.pyplot as plt import numpy as np from isoexp.LPAV_cvx import cvx_lip_i...
ContextualBanditsAttacks-main
examples/run_lisotron.py
# Copyright (c) 2019-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. # from isoexp.knnmab import KnnMab from isoexp.isomab import IsoMab import isoexp.monenvs as monenvs import matplotlib.pyplot as ...
ContextualBanditsAttacks-main
examples/main.py
# Copyright (c) 2019-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 numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import pickle import tikzplotlib imp...
ContextualBanditsAttacks-main
examples/parse_mab_results.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2019-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. # """ Created on Thu Aug 22 15:37:36 2019 @author: evrard """ import pickle impor...
ContextualBanditsAttacks-main
examples/parse_batch_results.py
# Copyright (c) 2019-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. # #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 22 15:37:36 2019 @author: evrard """ filename = '201908...
ContextualBanditsAttacks-main
examples/reader_linear.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 pickle import numpy as np import os np.random.seed(1234) # we want 500 for training, 100 for test for wach class n = ...
Adversarial-Continual-Learning-main
ACL-resnet/data/split_miniimagenet.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 sys, time, os import numpy as np import torch import copy import utils from copy import deepcopy from tqdm import tqd...
Adversarial-Continual-Learning-main
ACL-resnet/src/acl.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 os import numpy as np from copy import deepcopy import pickle import time import uuid from subprocess import call #####...
Adversarial-Continual-Learning-main
ACL-resnet/src/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 os,argparse,time import numpy as np from omegaconf import OmegaConf from copy import deepcopy import torch import torc...
Adversarial-Continual-Learning-main
ACL-resnet/src/main.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 __future__ import print_function from PIL import Image import os import os.path import sys if sys.version_info[0] == 2:...
Adversarial-Continual-Learning-main
ACL-resnet/src/dataloaders/cifar100.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. # https://github.com/pytorch/vision/blob/8635be94d1216f10fb8302da89233bd86445e449/torchvision/datasets/utils.py import os im...
Adversarial-Continual-Learning-main
ACL-resnet/src/dataloaders/utils.py