python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
"""Euclidean Knowledge Graph embedding models where embeddings are in real space."""
import numpy as np
import torch
from torch import nn
from models.base import KGModel
from utils.euclidean import euc_sqdistance, givens_rotations, givens_reflection
EUC_MODELS = ["TransE", "CP", "MurE", "RotE", "RefE", "AttE"]
clas... | KGEmb-master | models/euclidean.py |
"""Knowledge Graph embedding model optimizer."""
import numpy as np
import torch
import torch.nn.functional as F
import tqdm
from torch import nn
class KGOptimizer(object):
"""Knowledge Graph embedding model optimizer.
KGOptimizers performs loss computations with negative sampling and gradient descent steps.... | KGEmb-master | optimizers/kg_optimizer.py |
from .kg_optimizer import KGOptimizer
from .regularizers import *
| KGEmb-master | optimizers/__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 abc import ABC, abstractmethod
from typing import Tuple
import torch
from torch import nn
class Regularizer(nn.Mod... | KGEmb-master | optimizers/regularizers.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import detectron2.utils.comm as comm
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import get_cfg
from detectron2.engine import default_argument_parser, default_setup, launch
from adapteacher... | adaptive_teacher-main | train_net.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from detectron2.config import CfgNode as CN
def add_ateacher_config(cfg):
"""
Add config for semisupnet.
"""
_C = cfg
_C.TEST.VAL_LOSS = True
_C.MODEL.RPN.UNSUP_LOSS_WEIGHT = 1.0
_C.MODEL.RPN.LOSS = "CrossEntropy"
... | adaptive_teacher-main | adapteacher/config.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from .config import add_ateacher_config
| adaptive_teacher-main | adapteacher/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from detectron2.checkpoint.c2_model_loading import align_and_update_state_dicts
from detectron2.checkpoint import DetectionCheckpointer
# for load_student_model
from typing import Any
from fvcore.common.checkpoint import _strip_prefix_if_present, _... | adaptive_teacher-main | adapteacher/checkpoint/detection_checkpoint.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from detectron2.config import CfgNode
from detectron2.solver.lr_scheduler import WarmupCosineLR, WarmupMultiStepLR
from .lr_scheduler import WarmupTwoStageMultiStepLR
def build_lr_scheduler(
cfg: CfgNode, optimizer: torch.optim.Op... | adaptive_teacher-main | adapteacher/solver/build.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from bisect import bisect_right
from typing import List
import torch
from detectron2.solver.lr_scheduler import _get_warmup_factor_at_iter
class WarmupTwoStageMultiStepLR(torch.optim.lr_scheduler._LRScheduler):
def __init__(
self,
... | adaptive_teacher-main | adapteacher/solver/lr_scheduler.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
import torch
import torch.nn as nn
from torch.nn import functional as F
from detectron2.modeling.meta_arch.build import META_ARCH_REGISTRY
from detectron2.modeling.meta_arch.rcnn import GeneralizedRCNN
from detectron2.config impo... | adaptive_teacher-main | adapteacher/modeling/meta_arch/rcnn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch.nn as nn
import copy
import torch
from typing import Union, List, Dict, Any, cast
from detectron2.modeling.backbone import (
ResNet,
Backbone,
build_resnet_backbone,
BACKBONE_REGISTRY
)
from detectron2.modeling.backbone.... | adaptive_teacher-main | adapteacher/modeling/meta_arch/vgg.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from torch.nn.parallel import DataParallel, DistributedDataParallel
import torch.nn as nn
class EnsembleTSModel(nn.Module):
def __init__(self, modelTeacher, modelStudent):
super(EnsembleTSModel, self).__init__()
if isinstance(... | adaptive_teacher-main | adapteacher/modeling/meta_arch/ts_ensemble.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Dict, Optional
import torch
from detectron2.structures import ImageList, Instances
from detectron2.modeling.proposal_generator import RPN
from detectron2.modeling.proposal_generator.build import PROPOSAL_GENERATOR_REGISTRY
@PRO... | adaptive_teacher-main | adapteacher/modeling/proposal_generator/rpn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.modeling.roi_heads.fast_rcnn import (
FastRCNNOutputLayers,
FastRCNNOutputs,
)
# focal loss
class FastRCNNFocaltLossOutputLayers(FastRCNNOutputLayers):
... | adaptive_teacher-main | adapteacher/modeling/roi_heads/fast_rcnn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from typing import Dict, List, Optional, Tuple, Union
from detectron2.structures import Boxes, ImageList, Instances, pairwise_iou
from detectron2.modeling.proposal_generator.proposal_utils import (
add_ground_truth_to_proposals,
)
f... | adaptive_teacher-main | adapteacher/modeling/roi_heads/roi_heads.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from .coco_evaluation import COCOEvaluator
from .pascal_voc_evaluation import PascalVOCDetectionEvaluator
# __all__ = [k for k in globals().keys() if not k.startswith("_")]
__all__ = [
"COCOEvaluator",
"PascalVOCDetectionEvaluator"
]
| adaptive_teacher-main | adapteacher/evaluation/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import contextlib
import copy
import io
import itertools
import json
import logging
import numpy as np
import os
import pickle
from collections import OrderedDict
import pycocotools.mask as mask_util
import torch
from pycocotools.coco import COCO
from pycocotools.cocoe... | adaptive_teacher-main | adapteacher/evaluation/coco_evaluation.py |
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
import os
import tempfile
import xml.etree.ElementTree as ET
from collections import OrderedDict, defaultdict
from functools import lru_cache
import torch
from detectron2.data import MetadataCatalog
from detec... | adaptive_teacher-main | adapteacher/evaluation/pascal_voc_evaluation.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import numpy as np
import operator
import json
import torch.utils.data
from detectron2.utils.comm import get_world_size
from detectron2.data.common import (
DatasetFromList,
MapDataset,
)
from detectron2.data.dataset_mapper im... | adaptive_teacher-main | adapteacher/data/build.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from .build import (
build_detection_test_loader,
build_detection_semisup_train_loader,
)
| adaptive_teacher-main | adapteacher/data/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import torchvision.transforms as transforms
from adapteacher.data.transforms.augmentation_impl import (
GaussianBlur,
)
def build_strong_augmentation(cfg, is_train):
"""
Create a list of :class:`Augmentation` from config... | adaptive_teacher-main | adapteacher/data/detection_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
import numpy as np
from PIL import Image
import torch
import detectron2.data.detection_utils as utils
import detectron2.data.transforms as T
from detectron2.data.dataset_mapper import DatasetMapper
from adapteacher.data.d... | adaptive_teacher-main | adapteacher/data/dataset_mapper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from detectron2.data.common import MapDataset, AspectRatioGroupedDataset
class MapDatasetTwoCrop(MapDataset):
"""
Map a function over the elements in a dataset.
This customized MapDataset transforms an image with two au... | adaptive_teacher-main | adapteacher/data/common.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import contextlib
from detectron2.data import DatasetCatalog, MetadataCatalog
from fvcore.common.timer import Timer
# from fvcore.common.file_io import PathManager
from iopath.common.file_io import PathManager
from detectron2.data.dataset... | adaptive_teacher-main | adapteacher/data/datasets/builtin.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import functools
import json
import logging
import multiprocessing as mp
import numpy as np
import os
from itertools import chain
import pycocotools.mask as mask_util
from PIL import Image
from detectron2.structures import BoxMode
from detectron2.utils.comm import get... | adaptive_teacher-main | adapteacher/data/datasets/cityscapes_foggy.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import random
from PIL import ImageFilter
class GaussianBlur:
"""
Gaussian blur augmentation in SimCLR https://arxiv.org/abs/2002.05709
Adapted from MoCo:
https://github.com/facebookresearch/moco/blob/master/moco/loader.py
Note... | adaptive_teacher-main | adapteacher/data/transforms/augmentation_impl.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from detectron2.engine.hooks import HookBase
import detectron2.utils.comm as comm
import torch
import numpy as np
from contextlib import contextmanager
class LossEvalHook(HookBase):
def __init__(self, eval_period, model, data_loader, model_ou... | adaptive_teacher-main | adapteacher/engine/hooks.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from detectron2.structures import pairwise_iou
class OpenMatchTrainerProbe:
def __init__(self, cfg):
self.BOX_AP = 0.5
self.NUM_CLASSES = cfg.MODEL.ROI_HEADS.NUM_CLASSES
# self.bbox_stat_list = ['compute_fp_gtoutlier', 'c... | adaptive_teacher-main | adapteacher/engine/probe.py |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import time
import logging
import torch
from torch.nn.parallel import DistributedDataParallel
from fvcore.nn.precise_bn import get_bn_modules
import numpy as np
from collections import OrderedDict
import detectron2.utils.comm as comm
from... | adaptive_teacher-main | adapteacher/engine/trainer.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# from d2go.config import CfgNode as CN
def add_aut_config(cfg):
"""
Add config for SemiSupSegRunner.
"""
_C = cfg
#New added for discriminator
_C.UNBIASEDTEACHER.DIS_LOSS_WEIGHT = 0.1
_C.UNBIASED... | adaptive_teacher-main | prod_lib/config/defaults.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import os
from collections import OrderedDict
from functools import lru_cache
import d2go.utils.abnormal_checker as abnormal_checker
import detectron2.utils.comm as comm
from d2go.config import CONFIG_SCALING... | adaptive_teacher-main | prod_lib/runner/runner.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# from .runner import SemiSupSegRunner, SemiSupHandTrackingRunner # noqa
from .runner import BaseUnbiasedTeacherRunner # noqa
from .runner import DAobjUnbiasedTeacherRunner # noqa
| adaptive_teacher-main | prod_lib/runner/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch.nn as nn
import copy
import torch
from typing import Union, List, Dict, Any, cast
from detectron2.modeling.backbone import (
ResNet,
Backbone,
build_resnet_backbone,
BACKBONE_REGISTRY
)
from detec... | adaptive_teacher-main | prod_lib/modeling/vgg.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
import torch
import torch.nn as nn
from torch.nn import functional as F
from detectron2.data.detection_utils import convert_image_to_rgb
from detectron2.modeling import META_ARCH_REGISTRY, GeneralizedRCNN
... | adaptive_teacher-main | prod_lib/modeling/daobj_rcnn.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from .coco_evaluation import COCOEvaluator
from .pascal_voc_evaluation import PascalVOCDetectionEvaluator
# __all__ = [k for k in globals().keys() if not k.startswith("_")]
__all__ = [
"COCOEvaluator",
"PascalVOCDetectionEvaluator"
]
| adaptive_teacher-main | prod_lib/evaluation/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import contextlib
import copy
import io
import itertools
import json
import logging
import numpy as np
import os
import pickle
from collections import OrderedDict
import pycocotools.mask as mask_util
import torch
from pycocotools.coco import COCO
from pycocotools.cocoe... | adaptive_teacher-main | prod_lib/evaluation/coco_evaluation.py |
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
import os
import tempfile
import xml.etree.ElementTree as ET
from collections import OrderedDict, defaultdict
from functools import lru_cache
import torch
from detectron2.data import MetadataCatalog
from detec... | adaptive_teacher-main | prod_lib/evaluation/pascal_voc_evaluation.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import contextlib
import io
import logging
import os
import json
from detectron2.data import DatasetCatalog, MetadataCatalog
from d2go.data.utils import CallFuncWithJsonFile
from detectron2.utils.file_io import PathManager
f... | adaptive_teacher-main | prod_lib/data/builtin.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import functools
import json
import logging
import multiprocessing as mp
import numpy as np
import os
from itertools import chain
import pycocotools.mask as mask_util
from PIL import Image
from detectron2.structures import BoxMode
from detectron2.utils.comm import get... | adaptive_teacher-main | prod_lib/data/cityscapes_foggy.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from detectron2.structures import pairwise_iou
class OpenMatchTrainerProbe:
def __init__(self, cfg):
self.BOX_AP = 0.5
self.NUM_CLASSES = cfg.MODEL.ROI_HEADS.NUM_CLASSES
# self.bbox_stat_list = ['c... | adaptive_teacher-main | prod_lib/engine/probe.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import time
from collections import OrderedDict
from typing import Dict
import detectron2.utils.comm as comm
import numpy as np
import torch
from detectron2.engine import SimpleTrainer
from detectron2.structur... | adaptive_teacher-main | prod_lib/engine/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.
'''
Author: Mulong Luo
Date: 2022.4.1
Usage: defines various replacement policy to be used in AutoCAT
'''
import block
import random
INVALID_TAG = '-... | AutoCAT-main | src/replacement_policy.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 2021.12.3
# description: environment for study RL for side channel attack
from calendar import c
from collections import d... | AutoCAT-main | src/cache_guessing_game_env_impl.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 math, block, response
import pprint
from replacement_policy import *
class Cache:
def __init__(self, name, word_size, block_size, n_block... | AutoCAT-main | src/cache.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.
class Response:
def __init__(self, hit_list, time, data=''):
self.hit_list = hit_list
self.time = time
self.data = data
... | AutoCAT-main | src/response.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.
# simpple SVM based detector
# based on Cyclone
# window_size = 4
# interval_size = 20
# 1 bucket
import copy
from typing import Any, Dict, Sequence... | AutoCAT-main | src/cyclone_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.
#!/usr/bin/env python
# encoding: utf-8
import logging
# now we patch Python code to add color support to logging.StreamHandler
def add_coloring_to_em... | AutoCAT-main | src/colorer.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
from typing import Any, Dict, Sequence, Tuple
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import gym
from a... | AutoCAT-main | src/cchunter_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 numpy as np
def autocorrelation(x: np.ndarray, p: int, normalized: bool = True) -> float:
if p == 0:
return 1.0
mean = x.mean... | AutoCAT-main | src/autocorrelation.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.
class Block:
def __init__(self, block_size, current_step, dirty, address, domain_id = -1):
self.size = block_size
self.dirty_bit =... | AutoCAT-main | src/block.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 yaml, cache, argparse, logging, pprint
from terminaltables.other_tables import UnixTable
from replacement_policy import ... | AutoCAT-main | src/cache_simulator.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 torch
import torch.nn as nn
import torch.nn.functional as F
class ResidualBlock(nn.Module):
def __init__(self, dim: int) -> None:
... | AutoCAT-main | src/models/dnn.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
import torch
import torch.nn as nn
import torch.nn.functional as F
sys.path.append(os.path.dirname(os.path.dirname(os.path.absp... | AutoCAT-main | src/models/backbone.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 Dict, List, Tuple
import gym
import torch
import torch.nn as nn
import torch.nn.functional as F
from ray.rllib.models import Mod... | AutoCAT-main | src/models/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 typing import Dict, List, Tuple
import gym
import torch
import torch.nn as nn
import torch.nn.functional as F
from ray.rllib.models import Mod... | AutoCAT-main | src/models/dnn_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.
'''
Author Mulong Luo
Date 2022.1.24
usage: resotre the ray checkpoint to replay the agent and extract the attack pattern
'''
from copy import deepco... | AutoCAT-main | src/rllib/replay_checkpoint.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.7.10
Description:
split the agent into two different agent
P1: just generate the sequence but not the guess
P2: ... | AutoCAT-main | src/rllib/run_gym_rllib_guessability.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.
'''
CacheSimulatorSIMDWrapper
wraps multiple environment with different initialization into a single env
'''
#from msilib.schema import DuplicateFile
... | AutoCAT-main | src/rllib/run_gym_rllib_simd.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 sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))+ '/third_party/cachequery/tool/')
f... | AutoCAT-main | src/rllib/cache_query_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.
'''
Author: Mulong Luo
Date: 2022.7.10
Function: Add one reveal action so that the agent has to explicit reveal the secret,
once the secret is reveale... | AutoCAT-main | src/rllib/run_gym_rllib_reveal_action.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.
# look at https://github.com/ray-project/ray/blob/ea2bea7e309cd60457aa0e027321be5f10fa0fe5/rllib/examples/custom_env.py#L2
#from CacheSimulator.src.gy... | AutoCAT-main | src/rllib/run_gym_rllib_agent_blacklist.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 cache_guessing_game_env_impl as env
import sys
import pandas as pd
from pandas.core.arrays import numeric
#def number_of_set(x):
# return x%2... | AutoCAT-main | src/rllib/categorization.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.
| AutoCAT-main | src/rllib/__init__.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.7.10
Usage: wrapper fucntion to solve the import issues
'''
import sys
import os
import gym
sys.path.append(os.pat... | AutoCAT-main | src/rllib/cache_guessing_game_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.
'''
Author: Mulong Luo
Date: 2022.7.12
Usage: wrapper for cachequery that interact with the gym environment
the observation space and action space sho... | AutoCAT-main | src/rllib/cache_query_env.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.7.11
Function: An example rllib training script
'''
from random import random
import sys
import os
###sys.path.appen... | AutoCAT-main | src/rllib/run_gym_rllib_example.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.
# using ray 1.92 to run
# python 3.9
from ray.rllib.agents.ppo.ppo_torch_policy import PPOTorchPolicy
from ray.rllib.agents.a3c.a3c_torch_policy impo... | AutoCAT-main | src/rllib/test_custom_policy_diversity_works.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.7.11
Function: An example rllib training script
'''
from random import random
import sys
import os
###sys.path.appen... | AutoCAT-main | src/rllib/run_gym_rllib_example_multicore.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.7.11
Function: An example rllib training script
'''
from random import random
import sys
import os
###sys.path.appen... | AutoCAT-main | src/rllib/run_gym_rllib_example_multicore_largel3.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 sys
import pandas as pd
from cache_guessing_game_env_wrapper import CacheGuessingGameEnvWrapper as CacheGuessingGameEnv
from pandas.core.arrays... | AutoCAT-main | src/rllib/categorization_parser.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
# usage: process the json file plotted by rllib
import json
from matplotlib import pyplot as plt
import numpy as np
import sys
im... | AutoCAT-main | src/rllib/process_record.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.7.11
Function: An example rllib training script
'''
from random import random
import sys
import os
###sys.path.appen... | AutoCAT-main | src/rllib/run_gym_rllib_example_multicore_flush.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.7.11
Function: An example rllib training script
'''
from random import random
import sys
import os
###sys.path.appen... | AutoCAT-main | src/rllib/run_gym_rllib_example_multicore_largel2.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.
baseline_attack=[
0.03511984,
0.01022458,
0.11334784,
0.01202186,
0.02987794,
0.13556209,
0.07939993,
0.16500453,
0.17601161,
0.13473269,
0.15670964,
... | AutoCAT-main | src/cyclone_data/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 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.