function_module.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def _check_unused_inputs(self, inputs, outputs, on_unused_input):
        if on_unused_input is None:
            on_unused_input = theano.config.on_unused_input

        if on_unused_input == 'ignore':
            return

        # There should be two categories of variables in inputs:
        #  - variables that have to be provided (used_inputs)
        #  - shared variables that will be updated
        used_inputs = gof.graph.ancestors(
            ([o.variable for o in outputs] +
             [i.update for i in inputs if getattr(i, 'update', False)]),
            blockers=[i.variable for i in inputs])

        msg = ("theano.function was asked to create a function computing "
               "outputs given certain inputs, but the provided input "
               "variable at index %i is not part of the computational graph "
               "needed to compute the outputs: %s.\n%s")
        warn_msg = ("To make this warning into an error, you can pass the "
                    "parameter on_unused_input='raise' to theano.function. "
                    "To disable it completely, use on_unused_input='ignore'.")
        err_msg = ("To make this error into a warning, you can pass the "
                   "parameter on_unused_input='warn' to theano.function. "
                   "To disable it completely, use on_unused_input='ignore'.")

        for i in inputs:
            if ((i.variable not in used_inputs) and (i.update is None)):
                if on_unused_input == 'warn':
                    warnings.warn(msg % (inputs.index(i), i.variable,
                                         warn_msg), stacklevel=6)
                elif on_unused_input == 'raise':
                    raise UnusedInputError(msg % (inputs.index(i),
                                                  i.variable, err_msg))
                else:
                    raise ValueError("Invalid value for keyword "
                                     "on_unused_input of theano.function: "
                                     "'%s'.\nValid values are 'raise', "
                                     "'warn', and 'ignore'." % on_unused_input)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号