Compute a point in a search space from a hyperparameter assignment. Parameters: ----------- space - a pyll graph involving hp nodes (see `pyll_utils`). hp_assignment - a dictionary mapping hp node labels to values.
(space, hp_assignment)
| 599 | |
| 600 | |
| 601 | def space_eval(space, hp_assignment): |
| 602 | """Compute a point in a search space from a hyperparameter assignment. |
| 603 | |
| 604 | Parameters: |
| 605 | ----------- |
| 606 | space - a pyll graph involving hp nodes (see `pyll_utils`). |
| 607 | |
| 608 | hp_assignment - a dictionary mapping hp node labels to values. |
| 609 | """ |
| 610 | space = pyll.as_apply(space) |
| 611 | nodes = pyll.toposort(space) |
| 612 | memo = {} |
| 613 | for node in nodes: |
| 614 | if node.name == "hyperopt_param": |
| 615 | label = node.arg["label"].eval() |
| 616 | if label in hp_assignment: |
| 617 | memo[node] = hp_assignment[label] |
| 618 | rval = pyll.rec_eval(space, memo=memo) |
| 619 | return rval |
| 620 | |
| 621 | |
| 622 | # -- flake8 doesn't like blank last line |