def monitors(self, **kwargs):
regs = regularizers.from_kwargs(self, **kwargs)<EOL>outputs, _ = self.build_graph(regs)<EOL>monitors = [('<STR_LIT>', self.losses[<NUM_LIT:0>](outputs))]<EOL>def matching(pattern):<EOL><INDENT>'''<STR_LIT>'''<EOL>for name, expr in util.outputs_matching(outputs, pattern):<EOL><INDENT>yield name, expr<EOL><DEDENT>for name, expr in util.params_matching(self.layers, pattern):<EOL><INDENT>yield name, expr<EOL><DEDENT><DEDENT>def parse_levels(levels):<EOL><INDENT>'''<STR_LIT>'''<EOL>if isinstance(levels, dict):<EOL><INDENT>levels = levels.items()<EOL><DEDENT>if isinstance(levels, (int, float)):<EOL><INDENT>levels = [levels]<EOL><DEDENT>for level in levels:<EOL><INDENT>if isinstance(level, (tuple, list)):<EOL><INDENT>label, call = level<EOL>yield '<STR_LIT>'.format(label), call<EOL><DEDENT>if isinstance(level, (int, float)):<EOL><INDENT>def call(expr):<EOL><INDENT>return (expr < level).mean()<EOL><DEDENT>yield '<STR_LIT>'.format(level), call<EOL><DEDENT><DEDENT><DEDENT>inputs = kwargs.get('<STR_LIT>', {})<EOL>if isinstance(inputs, dict):<EOL><INDENT>inputs = inputs.items()<EOL><DEDENT>for pattern, levels in inputs:<EOL><INDENT>for name, expr in matching(pattern):<EOL><INDENT>for key, value in parse_levels(levels):<EOL><INDENT>monitors.append(('<STR_LIT>'.format(name, key), value(expr)))<EOL><DEDENT><DEDENT><DEDENT>return monitors<EOL>
Return expressions that should be computed to monitor training.

        Returns
        -------
        monitors : list of (name, expression) pairs
            A list of named monitor expressions to compute for this network.