neurospin / pylearn-epac

Embarrassingly Parallel Array Computing: EPAC is a machine learning workflow builder.
BSD 3-Clause "New" or "Revised" License
12 stars 3 forks source link

RowSlicer.slices haven't been updated in epac_mapper #10

Closed JinpengLI closed 11 years ago

JinpengLI commented 11 years ago
>>> cpXy = Xy
>>> print curr_key
Perms/Perm(nb=1)/CV/CV(nb=0)/CVGridSearchRefit
>>> curr_node = tree.get_node(curr_key)
>>> for node_common2curr in curr_node.get_path_from_node(common_parent):
...     if node_common2curr is common_parent: # skip commom ancestor
...         continue
...     if node_common2curr is curr_node: # do not process current node
...         break
...     func = getattr(node_common2curr, function)
...     cpXy = func(recursion=False, **cpXy)
... 
Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "/home/jinpeng/github/pylearn-epac/epac/workflow/base.py", line 523, in fit_predict
    Xy_train = self.fit(recursion=False, **Xy_train)
  File "/home/jinpeng/github/pylearn-epac/epac/workflow/splitters.py", line 363, in fit
    return self.transform(recursion=False, sample_set="train", **Xy)
  File "/home/jinpeng/github/pylearn-epac/epac/workflow/splitters.py", line 332, in transform
    raise ValueError("Slicing hasn't been initialized. "
ValueError: Slicing hasn't been initialized. Slicers constructors such as CV or Perm should be called with a sample. Ex.: CV(..., y=y), Perm(..., y=y)
>>> 

When we get a set of nodes using curr_node.get_path_from_node(common_parent), and then node_common2curr run fit_predict to produce "_sclices", but their children (RowSlicer.slices from curr_node.get_path_from_node(common_parent) ) won't copy it. Thus, it will produce those above errors.

JinpengLI commented 11 years ago

This issue has been fixed by reloading node in each iteration node_common2curr = tree.get_node(node_common2curr.get_key())

    curr_node = tree.get_node(curr_key)
    for node_common2curr in curr_node.get_path_from_node(common_parent):
        if node_common2curr is common_parent: # skip commom ancestor
            continue
        if node_common2curr is curr_node: # do not process current node
            break
        node_common2curr = tree.get_node(node_common2curr.get_key()) ####### #10
        func = getattr(node_common2curr, function)
        cpXy = func(recursion=False, **cpXy)