def params_matching(layers, patterns):
if isinstance(patterns, basestring):<EOL><INDENT>patterns = (patterns, )<EOL><DEDENT>for layer in layers:<EOL><INDENT>for param in layer.params:<EOL><INDENT>name = param.name<EOL>for pattern in patterns:<EOL><INDENT>if fnmatch.fnmatch(name, pattern):<EOL><INDENT>yield name, param<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Get the parameters from a network that match a pattern.

    Parameters
    ----------
    layers : list of :class:`theanets.layers.Layer`
        A list of network layers to retrieve parameters from.
    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 parameter that matched, and the expression represents the
        parameter symbolically.