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 |
|---|---|---|---|---|---|---|
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/analyse_dataset.py | # -*- coding: utf-8 -*-
import associate
import numpy as np
import matplotlib.pyplot as plt
import yaml
def loadDataset(filename):
file = open(filename)
data = file.read()
lines = data.replace(","," ").replace("\t"," ").split("\n")
D = np.array([[v.strip() for v in line.split(" ") if v.strip()!=""] for line i... | 1,178 | 27.071429 | 139 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/analyse_trajectory.py | #!/usr/bin/python
import os
import yaml
import argparse
import numpy as np
import matplotlib.pyplot as plt
import svo_analysis.tum_benchmark_tools.associate as associate
import vikit_py.transformations as transformations
import vikit_py.align_trajectory as align_trajectory
from matplotlib import rc
rc('font',**{'famil... | 8,764 | 46.378378 | 164 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/hand_eye_calib.py | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 4 15:47:55 2013
@author: cforster
"""
import os
import yaml
import numpy as np
import svo_analysis.tum_benchmark_tools.associate as associate
import vikit_py.align_trajectory as align_trajectory
import vikit_py.transformations as transformations
import matplotlib.pyplot ... | 7,489 | 31.850877 | 105 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/__init__.py | 0 | 0 | 0 | py | |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/analyse_depth.py | #!/usr/bin/python
import os
import argparse
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font',**{'family':'serif','serif':['Cardo']})
rc('text', usetex=True)
def precision_plot(ax, errors, max_error, color, linestyle):
number_of_error_ranges = 500
error_step = max_error /... | 2,697 | 39.878788 | 106 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/tum_benchmark_tools/associate.py | #!/usr/bin/python
# Software License Agreement (BSD License)
#
# Copyright (c) 2013, Juergen Sturm, TUM
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must... | 5,409 | 40.29771 | 256 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/tum_benchmark_tools/evaluate_ate.py | #!/usr/bin/python
# Software License Agreement (BSD License)
#
# Copyright (c) 2013, Juergen Sturm, TUM
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must... | 8,437 | 42.05102 | 189 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/tum_benchmark_tools/evaluate_rpe.py | #!/usr/bin/python
# Software License Agreement (BSD License)
#
# Copyright (c) 2013, Juergen Sturm, TUM
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must... | 15,381 | 39.16188 | 192 | py |
rpg_svo | rpg_svo-master/svo_analysis/src/svo_analysis/tum_benchmark_tools/__init__.py | # -*- coding: utf-8 -*-
| 25 | 7.666667 | 23 | py |
rpg_svo | rpg_svo-master/svo_analysis/scripts/comparison.py | #!/usr/bin/python
import os
import sys
import time
import rospkg
import numpy as np
import matplotlib.pyplot as plt
import yaml
import argparse
import svo_analysis.analyse_depth as analyse_depth
from matplotlib import rc
# tell matplotlib to use latex font
rc('font',**{'family':'serif','serif':['Cardo']})
rc('text', ... | 7,184 | 43.90625 | 150 | py |
rpg_svo | rpg_svo-master/svo_analysis/scripts/benchmark.py | #!/usr/bin/python
"""
Created on Sat Aug 10 18:21:47 2013
@author: Christian Forster
"""
import os
import yaml
import rospkg
import argparse
import time
import vikit_py.cpu_info as cpu_info
import vikit_py.ros_node as ros_node
import evaluate
import shutil
def run_experiment(dataset, params):
# load dataset para... | 4,842 | 42.241071 | 104 | py |
rpg_svo | rpg_svo-master/svo_analysis/scripts/evaluate.py | #!/usr/bin/python
"""
Created on Sat Aug 10 18:21:47 2013
@author: Christian Forster
"""
import os
import csv
import numpy as np
import rospkg
import argparse
import yaml
import svo_analysis.analyse_logs as analyse_logs
import svo_analysis.analyse_timing as analyse_timing
import svo_analysis.analyse_trajectory as ana... | 1,753 | 29.241379 | 83 | py |
rpg_svo | rpg_svo-master/svo_analysis/scripts/compare_results.py | #!/usr/bin/python
import os
import sys
import time
import rospkg
import numpy as np
import matplotlib.pyplot as plt
import yaml
import argparse
from matplotlib import rc
# tell matplotlib to use latex font
rc('font',**{'family':'serif','serif':['Cardo']})
rc('text', usetex=True)
from mpl_toolkits.axes_grid1.in... | 6,127 | 39.582781 | 148 | py |
rpg_svo | rpg_svo-master/rqt_svo/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['rqt_svo'],
package_dir={'': 'src'},
scripts=['scripts/rqt_svo']
)
setup(**d) | 248 | 19.75 | 60 | py |
rpg_svo | rpg_svo-master/rqt_svo/src/rqt_svo/svo.py | #!/usr/bin/env python
import os
import rospy
import argparse
from qt_gui.plugin import Plugin
from .svo_widget import SvoWidget
class Svo(Plugin):
"""
Subclass of Plugin to display SVO status
"""
def __init__(self, context):
# Init Plugin
super(Svo, self).__init__(context)
self.setObjectName('... | 2,790 | 33.036585 | 117 | py |
rpg_svo | rpg_svo-master/rqt_svo/src/rqt_svo/svo_widget.py | #!/usr/bin/env python
import os
import rospy
import rospkg
import numpy as np
from python_qt_binding import loadUi
from python_qt_binding.QtGui import QWidget
from python_qt_binding.QtCore import QTimer, Slot
from svo_msgs.msg import Info
from std_msgs.msg import String
class SvoWidget(QWidget):
_last_info_msg = Inf... | 4,040 | 30.818898 | 100 | py |
rpg_svo | rpg_svo-master/rqt_svo/src/rqt_svo/__init__.py | 0 | 0 | 0 | py | |
tagperson-blender | tagperson-blender-master/tools/batch_generate.py | import bpy
from blendereid.config import get_cfg
from blendereid.utils import bpy_utils, misc
from blendereid.core import process
def parse_args():
import argparse
parser = argparse.ArgumentParser(description='args parser for blender renderer.')
parser.add_argument('--config-file', default='', help='')
... | 1,122 | 25.738095 | 109 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/shield.py | import os
import cv2
from tqdm import tqdm
import bpy
import json
import random
import numpy as np
from blendereid.core import background
def load_multiple_shield_imgs(shield_root):
print(f"start to load images from {shield_root}")
shield_img_list = []
shield_names = os.listdir(shield_root)
shield_na... | 6,000 | 38.222222 | 116 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/compositing.py | import os
import bpy
import random
import numpy as np
from blendereid.core import background, render_config
def compose_render_nodes(default_bg_file_path=None):
# TODO: remove this code
if default_bg_file_path is None:
default_bg_file_path = 'data_demo/background_demo/bg_blender_notext.png'
# add b... | 8,379 | 46.078652 | 254 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/camera_config.py | import random
def adjust_camera_roration(obj_camera, obj_person, cfg, elev=10, distance=25):
camera_rotation_euler_x_bias = cfg.CAMERA.ROTATION_EULER_X_BIAS.BIAS
if cfg.CAMERA.OCCATIONAL_JUMP.ENABLE:
if random.random() < cfg.CAMERA.OCCATIONAL_JUMP.PROB:
camera_rotation_euler_x_bias = cfg.... | 6,369 | 57.440367 | 198 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/pose_manager.py | import numpy as np
import os
import random
def fetch_pose_names(cfg, frame_count):
pose_root = cfg.POSE.ROOT
# pose_serial_candidates = ['02_01', '02_02', '02_03', '02_04', '02_05']
# pose_serial_candidates = ['02_01', '02_02', '02_03']
pose_serial_candidates = cfg.POSE.SERIALS
# pose_serial_candid... | 3,472 | 41.353659 | 109 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/attribute_manager.py | import os
import json
import numpy as np
def generate_attribute_save_path(cfg, mesh_id, camera_index, sequence_id, save_name=None):
if cfg.OUTPUT_DIR_FOR_ATTRIBUTE != '':
output_dir = cfg.OUTPUT_DIR_FOR_ATTRIBUTE
else:
output_dir = os.path.join(cfg.OUTPUT_DIR, "output_attributes")
if not os... | 4,106 | 34.713043 | 116 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/light_config.py | import random
def get_random_light_azim(cfg, camera_azim):
light_azim = (camera_azim + random.randint(cfg.LIGHT.AZIM.RANDOM_LOWER_BOUND, cfg.LIGHT.AZIM.RANDOM_UPPER_BOUND)) % 360
return light_azim
def get_random_light_elev(cfg, camera_elev):
light_elev_base = cfg.LIGHT.ELEV.BASE
light_elev_random = 0
... | 875 | 40.714286 | 123 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/expand.py | """
kind of augmentation, expand in certain factor
"""
import copy
import numpy as np
import random
import os
def expand_render_attribute_list(cfg, render_attribute_list):
expanded_list = []
base_num = len(render_attribute_list)
for render_attribute in render_attribute_list:
expanded_list.append(r... | 3,376 | 53.467742 | 199 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/world_config.py | import bpy
import random
# world color relative
DEFAULT_WORLD_BACKGROUND_COLOR = (0.05087608844041824, 0.05087608844041824, 0.05087608844041824, 1.0) # no use current
DEFAULT_WORLD_BACKGROUND_COLOR_V2 = (0.0509, 0.0509, 0.0509, 1.0) # no use current
DEFAULT_COLOR_MASK = (0.0, 0.0, 0.0, 0.0)
def get_original_worl... | 5,337 | 44.623932 | 154 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/background.py | import cv2
import os
import json
from tqdm import tqdm
import bpy
import random
def load_multiple_bg_imgs(cfg):
if cfg.BACKGROUND.USE_EMPTY_BACKGROUND:
return []
bg_root = cfg.BACKGROUND.ROOT
print(f"start to load images from {bg_root}")
bg_img_list = []
bg_names = os.listdir(bg_root)
b... | 5,203 | 32.146497 | 124 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/partner.py | import numpy as np
from blendereid.utils import mesh_utils, geometry
import os
import random
def random_select_one_partner(cfg):
random_min = cfg.PARTNER.SELECT_MESH_ID_MIN
random_max = cfg.PARTNER.SELECT_MESH_ID_MAX
partner_mesh_id = np.random.randint(random_min, random_max)
partner_mesh_file_name = m... | 1,130 | 40.888889 | 119 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/process.py |
import os
import bpy
from tqdm import tqdm
import numpy as np
from blendereid.core import background, compositing, camera_config, render_config, pose_manager, world_config, shield, attribute_manager
from blendereid.utils import bpy_utils, mesh_utils, resume_utils, geometry
from blendereid.schema.attribute import Attri... | 11,011 | 42.87251 | 197 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/process_v1.py |
import os
import bpy
import random
from blendereid.core import background, compositing, camera_config, render_config, pose_manager, world_config, \
attribute_manager
from blendereid.core import partner
from blendereid.utils import bpy_utils, mesh_utils, determinastic_utils, geometry
from blendereid.schema.attribut... | 12,514 | 50.714876 | 334 | py |
tagperson-blender | tagperson-blender-master/blendereid/core/render_config.py | import os
import bpy
import random
def compose_output_dir(cfg):
if cfg.OUTPUT_DIR_FOR_IMAGE != '':
output_dir = cfg.OUTPUT_DIR_FOR_IMAGE
else:
output_dir = os.path.join(cfg.OUTPUT_DIR, "output_persons")
return output_dir
def generate_save_path(cfg, mesh_id, camera_index, sequence_id):
... | 4,982 | 42.710526 | 188 | py |
tagperson-blender | tagperson-blender-master/blendereid/config/config.py | # encoding: utf-8
import logging
import os
from typing import Any
import yaml
from yacs.config import CfgNode as _CfgNode
BASE_KEY = "_BASE_"
class CfgNode(_CfgNode):
@staticmethod
def load_yaml_with_base(filename: str, allow_unsafe: bool = False):
"""
Just like `yaml.load(open(filename))`... | 4,518 | 32.227941 | 80 | py |
tagperson-blender | tagperson-blender-master/blendereid/config/defaults.py | from .config import CfgNode as CN
_C = CN()
_C.FIX_SEED = 19
_C.SOURCE = CN()
_C.SOURCE.ROOT = '/path/to/.mhx2'
_C.SOURCE.OBJ_POSE_NAME = 'Standing02'
# background relative
_C.BACKGROUND = CN()
_C.BACKGROUND.ROOT = '/path/to/background_dir/'
_C.BACKGROUND.NUM_LIMIT = -1
_C.BACKGROUND.FIX_RESOLUTION_PER_IMAGE = C... | 9,577 | 35.143396 | 119 | py |
tagperson-blender | tagperson-blender-master/blendereid/config/__init__.py | # encoding: utf-8
from .config import CfgNode, get_cfg
from .defaults import _C as cfg
| 88 | 16.8 | 36 | py |
tagperson-blender | tagperson-blender-master/blendereid/schema/attribute.py |
class Attribute:
mesh_id: int
camera_azim: int
camera_elev: int
camera_distance: float
light_azim: int
light_elev: int
light_distance: float
background: str
pose: str
camera_idx: int
img_width: int
img_height: int
partner_exist: bool
partner_mesh_id_list: list
... | 2,039 | 35.428571 | 437 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/resume_utils.py | import glob
import os
from blendereid.core import render_config
def check_rendering_result_exist(cfg, current_mesh_id):
if cfg.PROCESS.IMAGE_COUNT_PER_ID_RANDOM_LOWER_BOUND !=0 or cfg.PROCESS.IMAGE_COUNT_PER_ID_RANDOM_UPPER_BOUND != 0:
print(f"config is using dynamic IMAGE_COUNT_PER_ID, could not check wh... | 653 | 37.470588 | 119 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/misc.py | import random
import numpy as np
def fix_random_seeds(seed: int):
print(f"fix random seed to {seed}.")
random.seed(seed)
np.random.seed(seed) | 155 | 18.5 | 40 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/geometry.py |
import math
def calculate_target_location(origin_location, distance, azimuth, elevation):
"""
Given the origin point, distance, azimuth and elevation, find the target location
azimuth ~ (0, 360]
elevation ~ (0, 90]
"""
assert len(origin_location) == 3
# project to plane
z = dista... | 827 | 29.666667 | 109 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/mesh_utils.py | import os
import bpy
def format_mesh_file_name(mesh_id, obj_pose, suffix='mhx2'):
mesh_file_name = f"{mesh_id}_{obj_pose}.{suffix}"
return mesh_file_name
def load_object(obj_file_path):
ext = os.path.splitext(os.path.basename(obj_file_path))[1]
if ext == '.obj':
bpy.ops.import_scene.obj(filep... | 1,204 | 27.023256 | 117 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/bpy_utils.py | import bpy
import import_runtime_mhx2
import makewalk
class SampleOperator(bpy.types.Operator):
bl_idname = "object.sample_operator"
bl_label = "Sample Object Operator"
@classmethod
def poll(cls, context):
return context.active_object is not None
def register_bpy_libs():
bpy.utils.regis... | 1,817 | 27.40625 | 106 | py |
tagperson-blender | tagperson-blender-master/blendereid/utils/determinastic_utils.py |
def set_variable_according_to_determinastic_params(variable_value, variable_name: str, determinastic_params: dict):
"""
camera_azim
camera_elev
camera_distance
"""
if determinastic_params is None:
return variable_value
if variable_name not in determinastic_params:
return v... | 385 | 24.733333 | 115 | py |
tagperson-blender | tagperson-blender-master/demo/01_render_one_person.py | import os
import bpy
from tqdm import tqdm
import imageio
import cv2
import numpy as np
from blendereid.utils import bpy_utils, geometry
from blendereid.utils import mesh_utils
from blendereid.core import compositing
from blendereid.core import render_config
from blendereid.core import pose_manager
from blendereid.cor... | 7,350 | 33.350467 | 120 | py |
DACBench | DACBench-main/setup.py | import json
import os
from setuptools import setup, find_packages
def get_other_requirements():
other_requirements = {}
for file in os.listdir('./other_requirements'):
with open(f'./other_requirements/{file}', encoding='utf-8') as rq:
requirements = json.load(rq)
other_requirem... | 531 | 27 | 114 | py |
DACBench | DACBench-main/examples/container.py | from pathlib import Path
# in order to run this we need to build the container first by running
# `singularity build --fakeroot dachbench.sif dacbench/container/singularity_recipes/dachbench.def` from project root.
# For more details refer to dacbench/container/Container Roadmap.md
from dacbench.agents import RandomAge... | 1,052 | 41.12 | 118 | py |
DACBench | DACBench-main/examples/logger.py | from pathlib import Path
from dacbench.plotting import plot_performance, plot_performance_per_instance
from dacbench.logger import Logger, log2dataframe, load_logs
from dacbench.agents.simple_agents import RandomAgent
from dacbench.benchmarks import SigmoidBenchmark
from dacbench.runner import run_benchmark
from dacbe... | 1,820 | 29.35 | 78 | py |
DACBench | DACBench-main/examples/ray_ppo.py | import ray
from ray.tune.registry import register_env
from ray.rllib.agents import ppo
from dacbench import benchmarks
from dacbench.wrappers import ObservationWrapper
import argparse
def make_benchmark(config):
bench = getattr(benchmarks, config["benchmark"])()
env = bench.get_benchmark(seed=config["seed"])... | 1,902 | 30.716667 | 100 | py |
DACBench | DACBench-main/examples/tabular_rl_luby.py | """
Code adapted from
"Dynamic Algorithm Configuration:Foundation of a New Meta-Algorithmic Framework"
by A. Biedenkapp and H. F. Bozkurt and T. Eimer and F. Hutter and M. Lindauer.
Original environment authors: André Biedenkapp, H. Furkan Bozkurt
"""
import sys
import numpy as np
from dacbench.benchmarks import Luby... | 3,062 | 31.242105 | 87 | py |
DACBench | DACBench-main/examples/multi_agent_sigmoid.py | from dacbench.benchmarks import SigmoidBenchmark
bench = SigmoidBenchmark()
bench.config['multi_agent'] = True
env = bench.get_environment()
env.register_agent(0)
env.register_agent(1)
env.reset()
terminated, truncated = False, False
total_reward = 0
while not (terminated or truncated):
for a in [0, 1]:
ob... | 592 | 30.210526 | 69 | py |
DACBench | DACBench-main/examples/coax_ppo_cmaes.py | import jax
import jax.numpy as jnp
import coax
import haiku as hk
from numpy import prod
import optax
from dacbench.benchmarks import CMAESBenchmark
from dacbench.wrappers import ObservationWrapper
# the name of this script
name = 'ppo'
# the Pendulum MDP
bench = CMAESBenchmark()
env = bench.get_environment()
env =... | 2,786 | 26.058252 | 97 | py |
DACBench | DACBench-main/examples/run_dacbench.py | from dacbench.runner import run_dacbench
from dacbench.agents import RandomAgent
# Function to create an agent fulfilling the DACBench Agent interface
# In this case: a simple random agent
def make_agent(env):
return RandomAgent(env)
# Result output path
path = "dacbench_tabular"
# Run all DACBench benchmarks ... | 389 | 23.375 | 69 | py |
DACBench | DACBench-main/examples/example_utils.py | import gym
import argparse
import numpy as np
from collections import defaultdict, namedtuple
from dacbench.logger import Logger
class DummyEnv(gym.Env):
def __init__(self):
self.c_step = None
self.action_space = gym.spaces.Discrete(2)
self.observation_space = gym.spaces.Discrete(1)
... | 6,680 | 31.120192 | 89 | py |
DACBench | DACBench-main/examples/plotting/state_plotting.py | from pathlib import Path
from dacbench.logger import load_logs, log2dataframe
from dacbench.plotting import plot_state
import matplotlib.pyplot as plt
import pandas as pd
def plot_state_CMAES():
"""
Plot state information of CMA-ES run over time
"""
# Since converting the json logs to a data frame ... | 2,291 | 32.217391 | 99 | py |
DACBench | DACBench-main/examples/plotting/performance_plotting.py | from pathlib import Path
from seaborn import plotting_context
from dacbench.logger import load_logs, log2dataframe
from dacbench.plotting import plot_performance_per_instance, plot_performance
import matplotlib.pyplot as plt
def per_instance_example():
"""
Plot CMA performance for each training instance
... | 1,758 | 29.327586 | 90 | py |
DACBench | DACBench-main/examples/plotting/action_plotting.py | from pathlib import Path
from dacbench.logger import load_logs, log2dataframe
from dacbench.plotting import plot_action
import matplotlib.pyplot as plt
def plot_scalar_action():
"""
Plot Sigmoid actions over time by action component and by mean action component in intervals
"""
file = Path("./data/si... | 1,358 | 27.914894 | 96 | py |
DACBench | DACBench-main/examples/plotting/time_plotting.py | from pathlib import Path
import pandas as pd
from dacbench.logger import load_logs, log2dataframe
from dacbench.plotting import plot_step_time, plot_episode_time
import matplotlib.pyplot as plt
def step_time_example(data):
"""
Plot time spent per step on average and split by seed
Parameters
---------... | 2,181 | 28.486486 | 98 | py |
DACBench | DACBench-main/examples/wrappers/reward_noise_wrapping.py | from chainerrl import wrappers
from examples.example_utils import DummyEnv, train_chainer, make_chainer_dqn
from dacbench.wrappers import RewardNoiseWrapper
# We use a dummy env with constant reward of 1 to demontrate the different noise values
env = DummyEnv()
# Chainer requires casting
env = wrappers.CastObservation... | 1,594 | 31.55102 | 102 | py |
DACBench | DACBench-main/examples/wrappers/state_tracking_CMAES.py | from pathlib import Path
from dacbench.agents import RandomAgent
from dacbench.logger import Logger
from dacbench.runner import run_benchmark
from dacbench.benchmarks import CMAESBenchmark
from dacbench.wrappers import StateTrackingWrapper
# Make CMAESBenchmark environment
bench = CMAESBenchmark()
env = bench.get_env... | 825 | 29.592593 | 79 | py |
DACBench | DACBench-main/examples/wrappers/instance_handling.py | import numpy as np
from dacbench.benchmarks import SigmoidBenchmark
from dacbench.wrappers import InstanceSamplingWrapper
# Helper method to sample a single sigmoid instance
def sample_sigmoid():
rng = np.random.default_rng()
shifts = rng.normal(5, 2.5, 1)
slopes = rng.choice([-1, 1], 1) * rng.uniform(siz... | 2,596 | 29.916667 | 101 | py |
DACBench | DACBench-main/examples/wrappers/action_tracking_modcma.py | from pathlib import Path
from dacbench.agents import RandomAgent
from dacbench.logger import Logger
from dacbench.runner import run_benchmark
from dacbench.benchmarks import ModCMABenchmark
from dacbench.wrappers import ActionFrequencyWrapper
# Make ModeaBenchmark environment
bench = ModCMABenchmark()
env = bench.ge... | 762 | 27.259259 | 83 | py |
DACBench | DACBench-main/dacbench/run_baselines.py | import argparse
import itertools
import sys
from pathlib import Path
import numpy as np
from dacbench import benchmarks
from dacbench.agents import DynamicRandomAgent, GenericAgent, StaticAgent
from dacbench.envs.policies import NON_OPTIMAL_POLICIES, OPTIMAL_POLICIES
from dacbench.logger import Logger
from dacbench.r... | 9,836 | 28.809091 | 119 | py |
DACBench | DACBench-main/dacbench/abstract_agent.py | class AbstractDACBenchAgent:
"""Abstract class to implement for use with the runner function."""
def __init__(self, env):
"""
Initialize agent.
Parameters
----------
env : gym.Env
Environment to train on
"""
pass
def act(self, state, re... | 1,225 | 18.774194 | 71 | py |
DACBench | DACBench-main/dacbench/plotting.py | from typing import List, Tuple
import numpy as np
import pandas as pd
import seaborn as sns
sns.set_style("darkgrid")
def space_sep_upper(column_name: str) -> str:
"""
Separates strings at underscores into headings. Used to generate labels from logging names.
Parameters
----------
column_name :... | 17,495 | 29.857143 | 120 | py |
DACBench | DACBench-main/dacbench/abstract_env.py | import random
import gymnasium as gym
import numpy as np
from gymnasium.utils import seeding
class AbstractEnv(gym.Env):
"""Abstract template for environments."""
def __init__(self, config):
"""
Initialize environment.
Parameters
----------
config : dict
... | 17,933 | 30.573944 | 215 | py |
DACBench | DACBench-main/dacbench/abstract_benchmark.py | import json
from functools import partial
from types import FunctionType
import numpy as np
from gymnasium import spaces
from dacbench import wrappers
class AbstractBenchmark:
"""Abstract template for benchmark classes."""
def __init__(self, config_path=None, config: "objdict" = None):
"""
... | 20,990 | 30.901216 | 165 | py |
DACBench | DACBench-main/dacbench/logger.py | import json
from abc import ABCMeta, abstractmethod
from collections import ChainMap, defaultdict
from datetime import datetime
from functools import reduce
from itertools import chain
from numbers import Number
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, List, Tuple, Union
import numpy ... | 26,036 | 28.5875 | 156 | py |
DACBench | DACBench-main/dacbench/argument_parsing.py | from argparse import ArgumentTypeError as err
from pathlib import Path
class PathType(object):
"""
Custom argument type for path validation.
Adapted from: https://stackoverflow.com/questions/11415570/directory-path-types-with-argparse
"""
def __init__(self, exists=True, type="file", dash_ok=True... | 2,544 | 29.662651 | 97 | py |
DACBench | DACBench-main/dacbench/runner.py | from pathlib import Path
import seaborn as sb
from dacbench import benchmarks
from dacbench.logger import Logger
from dacbench.wrappers import PerformanceTrackingWrapper
sb.set_style("darkgrid")
current_palette = list(sb.color_palette())
def run_benchmark(env, agent, num_episodes, logger=None):
"""
Run sin... | 3,075 | 29.76 | 103 | py |
DACBench | DACBench-main/dacbench/__init__.py | """DACBench: a benchmark library for Dynamic Algorithm Configuration"""
__version__ = "0.2.1"
__contact__ = "automl.org"
from dacbench.abstract_benchmark import AbstractBenchmark
from dacbench.abstract_env import AbstractEnv, AbstractMADACEnv
__all__ = ["AbstractEnv", "AbstractMADACEnv", "AbstractBenchmark"]
from gy... | 856 | 29.607143 | 133 | py |
DACBench | DACBench-main/dacbench/benchmarks/sgd_benchmark.py | import csv
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from gymnasium import spaces
from torch.nn import NLLLoss
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import SGDEnv
from dacbench.envs.sgd import Reward
DEFAULT_CFG_SPA... | 6,789 | 30.004566 | 81 | py |
DACBench | DACBench-main/dacbench/benchmarks/luby_benchmark.py | import csv
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import LubyEnv, luby_gen
from dacbench.wrappers import RewardNoiseWrapper
MAX_STEPS = 2**6
LUBY_SEQUENCE = np.log2([next(lub... | 5,627 | 27.714286 | 87 | py |
DACBench | DACBench-main/dacbench/benchmarks/fast_downward_benchmark.py | import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import FastDownwardEnv
HEURISTICS = [
"tiebreaking([pdb(pattern=manual_pattern([0,1])),weight(g(),-1)])",
"tiebreaking([pdb(pat... | 6,149 | 30.218274 | 85 | py |
DACBench | DACBench-main/dacbench/benchmarks/toysgd_benchmark.py | import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
import pandas as pd
from gymnasium import spaces
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import ToySGDEnv
DEFAULT_CFG_SPACE = CS.ConfigurationSpace()
LR = CSH.UniformFloatHype... | 3,648 | 28.666667 | 84 | py |
DACBench | DACBench-main/dacbench/benchmarks/cma_benchmark.py | import csv
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from gymnasium import spaces
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import CMAESEnv
HISTORY_LENGTH = 40
INPUT_DIM = 10
DEFAULT_CFG_SPACE = CS.ConfigurationSpace()... | 4,920 | 28.291667 | 88 | py |
DACBench | DACBench-main/dacbench/benchmarks/sigmoid_benchmark.py | import csv
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import ContinuousSigmoidEnv, ContinuousStateSigmoidEnv, SigmoidEnv
ACTION_VALUES = (5, 10)
DEFAULT_CFG_SPACE = CS.Configura... | 8,827 | 32.694656 | 104 | py |
DACBench | DACBench-main/dacbench/benchmarks/modcma_benchmark.py | import itertools
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from modcma import Parameters
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import CMAStepSizeEnv, ModCMAEnv
DEFAULT_CFG_SPACE = CS.ConfigurationSpace()
ACTIVE = CS... | 5,343 | 33.701299 | 86 | py |
DACBench | DACBench-main/dacbench/benchmarks/__init__.py | # flake8: noqa: F401
import importlib
import warnings
from dacbench.benchmarks.fast_downward_benchmark import FastDownwardBenchmark
from dacbench.benchmarks.geometric_benchmark import GeometricBenchmark
from dacbench.benchmarks.luby_benchmark import LubyBenchmark
from dacbench.benchmarks.sigmoid_benchmark import Sigmo... | 1,888 | 28.984127 | 114 | py |
DACBench | DACBench-main/dacbench/benchmarks/geometric_benchmark.py | import csv
import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import numpy as np
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs import GeometricEnv
FILE_PATH = os.path.dirname(__file__)
ACTION_VALUES = (5, 10)
DEFAULT_CFG_SPACE = CS.ConfigurationSpace... | 10,145 | 31.834951 | 130 | py |
DACBench | DACBench-main/dacbench/benchmarks/theory_benchmark.py | import os
import ConfigSpace as CS
import ConfigSpace.hyperparameters as CSH
import gymnasium as gym
import numpy as np
import pandas as pd
from dacbench.abstract_benchmark import AbstractBenchmark, objdict
from dacbench.envs.theory import TheoryEnv, TheoryEnvDiscrete
INFO = {
"identifier": "Theory",
"name":... | 7,032 | 40.370588 | 178 | py |
DACBench | DACBench-main/dacbench/envs/theory.py | import logging
import uuid
from collections import deque
from copy import deepcopy
import gymnasium as gym
import numpy as np
from dacbench import AbstractEnv
class BinaryProblem:
"""An abstract class for an individual in binary representation."""
def __init__(self, n, rng=np.random.default_rng()):
... | 19,187 | 29.408875 | 136 | py |
DACBench | DACBench-main/dacbench/envs/geometric.py | """
Geometric environment.
Original environment authors: Rasmus von Glahn
"""
import bisect
import math
import os
from typing import Dict, List, Tuple
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
from mpl_toolkits import mplot3d
from dacbench import AbstractEnv
sns.set_theme(style="d... | 20,713 | 31.164596 | 112 | py |
DACBench | DACBench-main/dacbench/envs/sgd.py | import json
import math
import numbers
import random
import warnings
from enum import IntEnum, auto
from functools import reduce
import numpy as np
import torch
from backpack import backpack, extend
from backpack.extensions import BatchGrad
from torchvision import datasets, transforms
from dacbench import AbstractEnv... | 32,877 | 32.721026 | 226 | py |
DACBench | DACBench-main/dacbench/envs/cma_es.py | """
CMA-ES environment adapted from CMAWorld in
"Learning Step-size Adaptation in CMA-ES"
by G.Shala and A. Biedenkapp and N.Awad and S. Adriaensen and M.Lindauer and F. Hutter.
Original author: Gresa Shala
"""
import resource
import sys
import threading
import warnings
from collections import deque
import numpy as n... | 7,678 | 28.763566 | 88 | py |
DACBench | DACBench-main/dacbench/envs/toysgd.py | from typing import Dict, Tuple, Union
import numpy as np
import pandas as pd
from numpy.polynomial import Polynomial
from dacbench import AbstractMADACEnv
def create_polynomial_instance_set(
out_fname: str,
n_samples: int = 100,
order: int = 2,
low: float = -10,
high: float = 10,
):
"""Make ... | 7,727 | 29.666667 | 98 | py |
DACBench | DACBench-main/dacbench/envs/__init__.py | # flake8: noqa: F401
import importlib
import warnings
from dacbench.envs.fast_downward import FastDownwardEnv
from dacbench.envs.geometric import GeometricEnv
from dacbench.envs.luby import LubyEnv, luby_gen
from dacbench.envs.sigmoid import (
ContinuousSigmoidEnv,
ContinuousStateSigmoidEnv,
SigmoidEnv,
)
... | 1,631 | 25.322581 | 114 | py |
DACBench | DACBench-main/dacbench/envs/fast_downward.py | """
Planning environment from
"Learning Heuristic Selection with Dynamic Algorithm Configuration"
by David Speck, André Biedenkapp, Frank Hutter, Robert Mattmüller und Marius Lindauer.
Original environment authors: David Speck, André Biedenkapp
"""
import os
import socket
import subprocess
import time
import typing
fr... | 14,301 | 30.432967 | 180 | py |
DACBench | DACBench-main/dacbench/envs/modcma.py | import numpy as np
from IOHexperimenter import IOH_function
from modcma import ModularCMAES, Parameters
from dacbench import AbstractMADACEnv
class ModCMAEnv(AbstractMADACEnv):
def __init__(self, config):
super().__init__(config)
self.es = None
self.budget = config.budget
self.to... | 1,952 | 31.016393 | 85 | py |
DACBench | DACBench-main/dacbench/envs/cma_step_size.py | import numpy as np
from IOHexperimenter import IOH_function
from modcma import ModularCMAES, Parameters
from dacbench import AbstractEnv
class CMAStepSizeEnv(AbstractEnv):
def __init__(self, config):
super().__init__(config)
self.es = None
self.budget = config.budget
self.total_b... | 1,684 | 29.636364 | 85 | py |
DACBench | DACBench-main/dacbench/envs/sigmoid.py | """
Sigmoid environment from:
"Dynamic Algorithm Configuration:Foundation of a New Meta-Algorithmic Framework"
by A. Biedenkapp and H. F. Bozkurt and T. Eimer and F. Hutter and M. Lindauer.
Original environment authors: André Biedenkapp, H. Furkan Bozkurt
"""
from typing import List
import matplotlib.cm as cm
import... | 7,549 | 28.263566 | 117 | py |
DACBench | DACBench-main/dacbench/envs/luby.py | """
Luby environment from
"Dynamic Algorithm Configuration:Foundation of a New Meta-Algorithmic Framework"
by A. Biedenkapp and H. F. Bozkurt and T. Eimer and F. Hutter and M. Lindauer.
Original environment authors: André Biedenkapp, H. Furkan Bozkurt
"""
from typing import List
import numpy as np
from dacbench impo... | 5,640 | 30.165746 | 115 | py |
DACBench | DACBench-main/dacbench/envs/policies/csa_cma.py | def csa(env, state):
u = env.es.sigma
hsig = env.es.adapt_sigma.hsig(env.es)
env.es.hsig = hsig
delta = env.es.adapt_sigma.update2(env.es, function_values=env.cur_obj_val)
u *= delta
return u
| 216 | 26.125 | 79 | py |
DACBench | DACBench-main/dacbench/envs/policies/__init__.py | from dacbench.envs.policies.csa_cma import csa
from dacbench.envs.policies.optimal_fd import get_optimum as optimal_fd
from dacbench.envs.policies.optimal_luby import get_optimum as optimal_luby
from dacbench.envs.policies.optimal_sigmoid import get_optimum as optimal_sigmoid
OPTIMAL_POLICIES = {
"LubyBenchmark": ... | 527 | 34.2 | 81 | py |
DACBench | DACBench-main/dacbench/envs/policies/optimal_luby.py | def luby_gen(i):
"""Generator for the Luby Sequence"""
for k in range(1, 33):
if i == ((1 << k) - 1):
yield 1 << (k - 1)
for k in range(1, 9999):
if 1 << (k - 1) <= i < (1 << k) - 1:
for x in luby_gen(i - (1 << (k - 1)) + 1):
yield x
def get_optimum... | 360 | 23.066667 | 54 | py |
DACBench | DACBench-main/dacbench/envs/policies/sgd_ca.py | import math
from dacbench.abstract_agent import AbstractDACBenchAgent
class CosineAnnealingAgent(AbstractDACBenchAgent):
def __init__(self, env, base_lr=0.1, t_max=1000, eta_min=0):
self.eta_min = eta_min
self.t_max = t_max
self.base_lr = base_lr
self.current_lr = base_lr
... | 1,100 | 30.457143 | 73 | py |
DACBench | DACBench-main/dacbench/envs/policies/optimal_fd.py | import json
def get_optimum(env, state):
instance = env.get_instance()[:-12] + "optimal.json"
with open(instance, "r+") as fp:
optimal = json.load(fp)
return optimal[env.c_step]
| 200 | 21.333333 | 56 | py |
DACBench | DACBench-main/dacbench/envs/policies/optimal_sigmoid.py | import numpy as np
def sig(x, scaling, inflection):
"""Simple sigmoid function"""
return 1 / (1 + np.exp(-scaling * (x - inflection)))
def get_optimum(env, state):
sigmoids = [
np.abs(sig(env.c_step, slope, shift))
for slope, shift in zip(env.shifts, env.slopes)
]
action = []
... | 706 | 28.458333 | 79 | py |
DACBench | DACBench-main/dacbench/container/remote_runner.py | """This is strongly guided and partially copy from:https://github.com/automl/HPOBench/blob/master/hpobench/container/client_abstract_benchmark.py"""
import argparse
import logging
import os
import subprocess
import sys
from pathlib import Path
from typing import Optional, Tuple, Union
from uuid import uuid1
import Py... | 11,481 | 33.172619 | 148 | py |
DACBench | DACBench-main/dacbench/container/remote_env.py | import json
from numbers import Number
from typing import Dict, List, Tuple, Union
import numpy as np
import Pyro4
from dacbench.abstract_env import AbstractEnv
from dacbench.container.container_utils import Decoder, Encoder
NumpyTypes = Union[np.ndarray, np.int32, np.float32, np.random.RandomState]
DefaultJsonable ... | 2,618 | 23.027523 | 77 | py |
DACBench | DACBench-main/dacbench/container/container_utils.py | import enum
import json
import os
import socket
import time
from typing import Any, Dict, Union
import gymnasium as gym
import numpy as np
class Encoder(json.JSONEncoder):
"""
Json Encoder to save tuple and or numpy arrays | numpy floats / integer.
Adapted from: https://github.com/automl/HPOBench/blob/m... | 7,313 | 33.17757 | 131 | py |
DACBench | DACBench-main/dacbench/container/__init__.py | 0 | 0 | 0 | py | |
DACBench | DACBench-main/dacbench/agents/generic_agent.py | from dacbench.abstract_agent import AbstractDACBenchAgent
class GenericAgent(AbstractDACBenchAgent):
def __init__(self, env, policy):
self.policy = policy
self.env = env
def act(self, state, reward):
return self.policy(self.env, state)
def train(self, next_state, reward):
... | 382 | 21.529412 | 57 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.