layers -> xlayers
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
from .basic_space import Categorical
|
||||
from .basic_space import Continuous
|
||||
from .basic_space import Integer
|
||||
from .basic_space import Space
|
||||
from .basic_space import VirtualNode
|
||||
from .basic_op import has_categorical
|
||||
from .basic_op import has_continuous
|
||||
from .basic_op import get_min
|
||||
|
@@ -7,6 +7,7 @@ import math
|
||||
import copy
|
||||
import random
|
||||
import numpy as np
|
||||
from collections import OrderedDict
|
||||
|
||||
from typing import Optional
|
||||
|
||||
@@ -44,6 +45,32 @@ class Space(metaclass=abc.ABCMeta):
|
||||
return copy.deepcopy(self)
|
||||
|
||||
|
||||
class VirtualNode(Space):
|
||||
"""For a nested search space, we represent it as a tree structure.
|
||||
|
||||
For example,
|
||||
"""
|
||||
|
||||
def __init__(self, id=None, value=None):
|
||||
self._id = id
|
||||
self._value = value
|
||||
self._attributes = OrderedDict()
|
||||
|
||||
def has(self, x):
|
||||
for key, value in self._attributes.items():
|
||||
if isinstance(value, Space) and value.has(x):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
strs = [self.__class__.__name__ + "("]
|
||||
indent = " " * 4
|
||||
for key, value in self._attributes.items():
|
||||
strs.append(indent + strs(value))
|
||||
strs.append(")")
|
||||
return "\n".join(strs)
|
||||
|
||||
|
||||
class Categorical(Space):
|
||||
"""A space contains the categorical values.
|
||||
It can be a nested space, which means that the candidate in this space can also be a search space.
|
||||
|
Reference in New Issue
Block a user