theanets/util.py
def outputs_matching(outputs, patterns):
    '''Get the outputs from a network that match a pattern.

    Parameters
    ----------
    outputs : dict or sequence of (str, theano expression)
        Output expressions to filter for matches. If this is a dictionary, its
        ``items()`` will be processed for matches.
    patterns : sequence of str
        A sequence of glob-style patterns to match against. Any parameter
        matching any pattern in this sequence will be included in the match.

    Yields
    ------
    matches : pair of str, theano expression
        Generates a sequence of (name, expression) pairs. The name is the name
        of the output that matched, and the expression is the symbolic output in
        the network graph.
    '''
    if isinstance(patterns, basestring):
        patterns = (patterns, )
    if isinstance(outputs, dict):
        outputs = outputs.items()
    for name, expr in outputs:
        for pattern in patterns:
            if fnmatch.fnmatch(name, pattern):
                yield name, expr
                break
def outputs_matching(outputs, patterns):
    '''Get the outputs from a network that match a pattern.

    Parameters
    ----------
    outputs : dict or sequence of (str, theano expression)
        Output expressions to filter for matches. If this is a dictionary, its
        ``items()`` will be processed for matches.
    patterns : sequence of str
        A sequence of glob-style patterns to match against. Any parameter
        matching any pattern in this sequence will be included in the match.

    Yields
    ------
    matches : pair of str, theano expression
        Generates a sequence of (name, expression) pairs. The name is the name
        of the output that matched, and the expression is the symbolic output in
        the network graph.
    '''
    if isinstance(patterns, basestring):
        patterns = (patterns, )
    if isinstance(outputs, dict):
        outputs = outputs.items()
    for name, expr in outputs:
        for pattern in patterns:
            if fnmatch.fnmatch(name, pattern):
                yield name, expr
                break
def outputs_matching ( outputs , patterns ) : if isinstance ( patterns , basestring ) : patterns = ( patterns , ) if isinstance ( outputs , dict ) : outputs = outputs . items ( ) for name , expr in outputs : for pattern in patterns : if fnmatch . fnmatch ( name , pattern ) : yield name , expr break
Get the outputs from a network that match a pattern.

    Parameters
    ----------
    outputs : dict or sequence of (str, theano expression)
        Output expressions to filter for matches. If this is a dictionary, its
        ``items()`` will be processed for matches.
    patterns : sequence of str
        A sequence of glob-style patterns to match against. Any parameter
        matching any pattern in this sequence will be included in the match.

    Yields
    ------
    matches : pair of str, theano expression
        Generates a sequence of (name, expression) pairs. The name is the name
        of the output that matched, and the expression is the symbolic output in
        the network graph.
Get the outputs from a network that match a pattern .