コード例 #1
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def unpickle(self, fgraph):
     History.unpickle(self, fgraph)
     Validator.unpickle(self, fgraph)
     fgraph.replace_validate = partial(self.replace_validate, fgraph)
     fgraph.replace_all_validate = partial(self.replace_all_validate,
                                           fgraph)
     fgraph.replace_all_validate_remove = partial(
         self.replace_all_validate_remove, fgraph)
コード例 #2
0
 def unpickle(self, fgraph):
     History.unpickle(self, fgraph)
     Validator.unpickle(self, fgraph)
     fgraph.replace_validate = partial(self.replace_validate, fgraph)
     fgraph.replace_all_validate = partial(self.replace_all_validate,
                                           fgraph)
     fgraph.replace_all_validate_remove = partial(
         self.replace_all_validate_remove, fgraph)
コード例 #3
0
 def on_attach(self, fgraph):
     for attr in ('validate', 'validate_time'):
         if hasattr(fgraph, attr):
             raise AlreadyThere("Validator feature is already present or in"
                                " conflict with another plugin.")
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
コード例 #4
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def on_attach(self, fgraph):
     for attr in ('validate', 'validate_time'):
         if hasattr(fgraph, attr):
             raise AlreadyThere("Validator feature is already present or in"
                                " conflict with another plugin.")
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
コード例 #5
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def on_attach(self, fgraph):
     if self.fgraph is not None:
         raise Exception("A NodeFinder instance can only serve one FunctionGraph.")
     if hasattr(fgraph, 'get_nodes'):
         raise AlreadyThere("NodeFinder is already present or in conflict"
                            " with another plugin.")
     self.fgraph = fgraph
     fgraph.get_nodes = partial(self.query, fgraph)
     Bookkeeper.on_attach(self, fgraph)
コード例 #6
0
ファイル: toolbox.py プロジェクト: tsingjinyun/Theano
 def on_attach(self, fgraph):
     if self.fgraph is not None:
         raise Exception("A NodeFinder instance can only serve one FunctionGraph.")
     if hasattr(fgraph, 'get_nodes'):
         raise AlreadyThere("NodeFinder is already present or in conflict"
                            " with another plugin.")
     self.fgraph = fgraph
     fgraph.get_nodes = partial(self.query, fgraph)
     Bookkeeper.on_attach(self, fgraph)
コード例 #7
0
 def on_attach(self, fgraph):
     if hasattr(fgraph, 'checkpoint') or hasattr(fgraph, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[fgraph] = []
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
コード例 #8
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def on_attach(self, fgraph):
     if hasattr(fgraph, 'checkpoint') or hasattr(fgraph, 'revert'):
         raise AlreadyThere("History feature is already present or in"
                            " conflict with another plugin.")
     self.history[fgraph] = []
     # Don't call unpickle here, as ReplaceValidate.on_attach()
     # call to History.on_attach() will call the
     # ReplaceValidate.unpickle and not History.unpickle
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
コード例 #9
0
ファイル: unify.py プロジェクト: takuhironoda/Theano
################################

_all = {}


def var_lookup(vartype, name, *args, **kwargs):
    sig = (vartype, name)
    if sig in _all:
        return _all[sig]
    else:
        v = vartype(name, *args)
        _all[sig] = v
        return v


Var = partial(var_lookup, FreeVariable)
V = Var
OrV = partial(var_lookup, OrVariable)
NV = partial(var_lookup, NotVariable)

################################


class Unification:
    """
    This class represents a possible unification of a group of variables
    with each other or with tangible values.
    """
    def __init__(self, inplace=False):
        """
        If inplace is False, the merge method will return a new Unification
コード例 #10
0
 def unpickle(self, fgraph):
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
コード例 #11
0
 def unpickle(self, fgraph):
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
コード例 #12
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def unpickle(self, fgraph):
     fgraph.validate = partial(self.validate_, fgraph)
     fgraph.consistent = partial(self.consistent_, fgraph)
コード例 #13
0
ファイル: toolbox.py プロジェクト: alimuldal/Theano
 def unpickle(self, fgraph):
     fgraph.checkpoint = GetCheckpoint(self, fgraph)
     fgraph.revert = partial(self.revert, fgraph)
コード例 #14
0
ファイル: unify.py プロジェクト: Ambier/Theano
################################


_all = {}


def var_lookup(vartype, name, *args, **kwargs):
    sig = (vartype, name)
    if sig in _all:
        return _all[sig]
    else:
        v = vartype(name, *args)
        _all[sig] = v
        return v

Var = partial(var_lookup, FreeVariable)
V = Var
OrV = partial(var_lookup, OrVariable)
NV = partial(var_lookup, NotVariable)


################################


class Unification:
    """
    This class represents a possible unification of a group of variables
    with each other or with tangible values.
    """

    def __init__(self, inplace=False):