configuration_space.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:ConfigSpace 作者: automl 项目源码 文件源码
def _check_edges(self, edges: List[Tuple[str, str]]) -> None:
        for parent_node, child_node in edges:
            # check if both nodes are already inserted into the graph
            if child_node not in self._hyperparameters:
                raise ValueError("Child hyperparameter '%s' not in configuration "
                                 "space." % child_node)
            if parent_node not in self._hyperparameters:
                raise ValueError("Parent hyperparameter '%s' not in configuration "
                                 "space." % parent_node)

        # TODO: recursively check everything which is inside the conditions,
        # this means we have to recursively traverse the condition

        tmp_dag = self._create_tmp_dag()
        for parent_node, child_node in edges:
            tmp_dag.add_edge(parent_node, child_node)

        if not ConfigSpace.nx.is_directed_acyclic_graph(tmp_dag):
            cycles = list(ConfigSpace.nx.simple_cycles(tmp_dag))  # type: List[List[str]]
            for cycle in cycles:
                cycle.sort()
            cycles.sort()
            raise ValueError("Hyperparameter configuration contains a "
                             "cycle %s" % str(cycles))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号