Hyperband
smac.intensifier.hyperband #
Hyperband #
Hyperband(
scenario: Scenario,
eta: int = 3,
n_seeds: int = 1,
instance_seed_order: str | None = "shuffle_once",
max_incumbents: int = 10,
incumbent_selection: str = "highest_observed_budget",
seed: int | None = None,
)
请参阅 SuccessiveHalving
的文档。
源代码位于 smac/intensifier/successive_halving.py
中
get_callback #
get_callback() -> Callback
强化器利用回调函数根据运行历史记录高效地更新最优配置(每当新信息可用时)。此外,在此处集成回调函数也为开发者提供了未来更多的选择。
源代码位于 smac/intensifier/abstract_intensifier.py
中
get_incumbent #
在单目标设置中返回当前最优配置。
源代码位于 smac/intensifier/abstract_intensifier.py
中
get_incumbent_instance_seed_budget_key_differences #
get_incumbent_instance_seed_budget_key_differences(
compare: bool = False,
) -> list[InstanceSeedBudgetKey]
在某些情况下,最优配置会在比其他配置更多的试验中进行评估。此方法返回不属于所有最优配置最低实例交集的实例。
源代码位于 smac/intensifier/abstract_intensifier.py
中
get_incumbent_instance_seed_budget_keys #
get_incumbent_instance_seed_budget_keys(
compare: bool = False,
) -> list[InstanceSeedBudgetKey]
找到所有最优配置的 instance-seed-budget 键的最低交集。
源代码位于 smac/intensifier/abstract_intensifier.py
中
get_incumbents #
返回运行历史记录中的最优配置(帕累托前沿上的点)的副本。在单目标优化的情况下,只返回一个最优配置(如果存在)。
返回#
configs : list[Configuration] 帕累托前沿的配置。 sort_by : str,默认为 None 按 cost
(成本最低优先)或 num_trials
(试验次数最少的配置优先)对试验进行排序。
源代码位于 smac/intensifier/abstract_intensifier.py
中
get_instance_seed_budget_keys #
get_instance_seed_budget_keys(
config: Configuration, compare: bool = False
) -> list[InstanceSeedBudgetKey]
返回给定配置的 instance-seed-budget 键。此方法支持 highest_budget
,它只返回最高预算(如果指定)的 instance-seed-budget 键。在这种情况下,update_incumbents
中的最优配置只有在最高预算下的成本更低时才会改变。
参数#
config: Configuration 要查询的配置 compare : bool,默认为 False 在比较配置是否在相同的 instance-seed 键上进行评估时,去除预算信息。
源代码位于 smac/intensifier/successive_halving.py
中
get_instance_seed_keys_of_interest #
get_instance_seed_keys_of_interest(
*, validate: bool = False, seed: int | None = None
) -> list[InstanceSeedKey]
返回 instance-seed 键列表。考虑运行历史记录中的种子和实例(self._tf_seeds
和 self._tf_instances
)。如果未找到种子或实例,则根据全局强化器种子生成新的种子和实例。
警告#
传入的种子仅用于验证。对于训练,使用全局强化器种子。
参数#
validate : bool,默认为 False 是否获取验证试验或训练试验。唯一的区别在于不同的种子。 seed : int | None,默认为 None 用于验证试验的种子。
返回#
instance_seed_keys : list[InstanceSeedKey] 相关的 Instance-seed 键。
源代码位于 smac/intensifier/abstract_intensifier.py
中
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
get_rejected_configs #
get_rejected_configs() -> list[Configuration]
返回与最优配置竞争失败而被拒绝的配置。
源代码位于 smac/intensifier/abstract_intensifier.py
中
load #
加载强化器的最新状态,包括最优配置和轨迹。
源代码位于 smac/intensifier/abstract_intensifier.py
中
print_tracker #
打印每个 bracket/阶段中的配置数量。
源代码位于 smac/intensifier/successive_halving.py
中
reset #
save #
保存强化器的当前状态。除了状态(通过 get_state
获取)外,此方法还保存最优配置和轨迹。
源代码位于 smac/intensifier/abstract_intensifier.py
中
update_incumbents #
更新最优配置。每次将试验添加到运行历史记录时,都会调用此方法。由于只使用了受影响的配置和当前最优配置,因此此方法效率很高。此外,一个配置只有在所有最优配置实例上的性能更好时才被认为是最优配置。
关键是,如果(开始时)没有最优配置,则第一个配置将获得最优配置状态。对于下一个配置,我们需要检查该配置在已针对最优配置进行评估的所有实例上是否更好。如果是这样,我们就可以替换最优配置。否则,a) 我们需要重新排队该配置以获取缺失的 instance-seed-budget 组合,或 b) 将此配置标记为劣等(“被拒绝”)以不再考虑它。比较行为由 self.get_instance_seed_budget_keys() 和 self.get_incumbent_instance_seed_budget_keys() 控制。
值得注意的是,此方法旨在支持多保真度和多目标优化。get_instance_seed_budget_keys() 方法和 self.get_incumbent_instance_seed_budget_keys() 用于实现多保真度行为,而 calculate_pareto_front() 作为硬编码方式用于支持多目标优化,包括将单目标作为特例。calculate_pareto_front() 在所有(在 MO 情况下)最优配置集合上调用,该集合补充了挑战者配置,前提是它在 seed-instance-budget 组合中有足够的重叠。
最后,如果我们有一个 self._max_incumbents 并且帕累托前沿提供的最优配置数量超过此指定值,我们将使用拥挤距离截断最优配置。
源代码位于 smac/intensifier/abstract_intensifier.py
中
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
|