Source code for protomotions.agents.evaluators.config

# SPDX-FileCopyrightText: Copyright (c) 2025 The ProtoMotions Developers
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Configuration classes for evaluators."""

from typing import List, Optional, Union
from dataclasses import dataclass, field


[docs] @dataclass class EvaluatorConfig: """Configuration for base evaluator.""" _target_: str = "protomotions.agents.evaluators.base_evaluator.BaseEvaluator" eval_metrics_every: Optional[int] = field( default=200, metadata={"help": "Evaluate metrics every N epochs. None = disabled.", "min": 1} )
[docs] @dataclass class MotionWeightsRulesConfig: """Configuration for motion weights update rule.""" motion_weights_update_success_discount: float = field( default=0.999, metadata={"help": "Discount factor for successful motion weights.", "min": 0.0, "max": 1.0} ) motion_weights_update_failure_discount: float = field( default=0.999, metadata={"help": "Discount for failed motions. 0 = set weight straight to 1.", "min": 0.0, "max": 1.0} ) min_motion_weight: Union[float, str] = field( default="1/num_motions", metadata={"help": "Minimum weight for any motion. '1/num_motions' or float value."} )
[docs] @dataclass class MimicEvaluatorConfig(EvaluatorConfig): """Configuration for Mimic evaluator.""" _target_: str = "protomotions.agents.evaluators.mimic_evaluator.MimicEvaluator" eval_metric_keys: List[str] = field( default_factory=list, metadata={"help": "Metric keys to track during evaluation."} ) max_eval_steps: int = field( default=600, metadata={"help": "Maximum steps per evaluation episode.", "min": 1} ) save_predicted_motion_lib_every: Optional[int] = field( default=3, metadata={"help": "Save pred_motion_lib every M evals. None = disabled.", "min": 1} ) motion_weights_rules: MotionWeightsRulesConfig = field( default_factory=MotionWeightsRulesConfig, metadata={"help": "Rules for updating motion sampling weights."} )