Skip to content

Commit

Permalink
Grid designer now properly uses attr.fields instead of class-level …
Browse files Browse the repository at this point in the history
…attributes.

PiperOrigin-RevId: 567034563
  • Loading branch information
chansoo-google authored and copybara-github committed Sep 20, 2023
1 parent 7b4962f commit 1eb8518
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions vizier/_src/algorithms/designers/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@
from __future__ import annotations

"""Grid Search Designer which searches over a discretized grid of Trial parameter values."""

import copy
import random
from typing import Dict, List, Optional, Sequence

from absl import logging
import attrs
import numpy as np
from vizier import algorithms
from vizier import pyvizier
from vizier.interfaces import serializable
from vizier.pyvizier import converters


GridValues = Dict[str, List[pyvizier.ParameterValue]]


@attrs.define(auto_attribs=False, init=False)
class GridSearchDesigner(algorithms.PartiallySerializableDesigner):
"""Grid Search designer.
Expand All @@ -39,11 +44,12 @@ class GridSearchDesigner(algorithms.PartiallySerializableDesigner):
use in Pythia, thus requiring load/dump implementations.
"""

_unshuffled_grid_values: GridValues
_grid_values: GridValues
_current_index: int
_shuffle_seed: Optional[int]
_double_grid_resolution: int
_unshuffled_grid_values: GridValues = attrs.field()
_grid_values: GridValues = attrs.field()
_current_index: int = attrs.field()
_shuffle_seed: Optional[int] = attrs.field()
_double_grid_resolution: int = attrs.field()

_metadata_ns: str = 'grid' # class-level constant.

def __init__(
Expand Down

0 comments on commit 1eb8518

Please sign in to comment.