本文整理汇总了Python中nn.base.NNBase.grad_check方法的典型用法代码示例。如果您正苦于以下问题:Python NNBase.grad_check方法的具体用法?Python NNBase.grad_check怎么用?Python NNBase.grad_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nn.base.NNBase
的用法示例。
在下文中一共展示了NNBase.grad_check方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grad_check
# 需要导入模块: from nn.base import NNBase [as 别名]
# 或者: from nn.base.NNBase import grad_check [as 别名]
def grad_check(self, x, y, outfd=sys.stderr, **kwargs):
"""
Wrapper for gradient check on RNNs;
ensures that backprop-through-time is run to completion,
computing the full gradient for the loss as summed over
the input sequence and predictions.
Do not modify this function!
"""
NNBase.grad_check(self, x, y, outfd=outfd, **kwargs)
示例2: grad_check
# 需要导入模块: from nn.base import NNBase [as 别名]
# 或者: from nn.base.NNBase import grad_check [as 别名]
def grad_check(self, x, y, outfd=sys.stderr, **kwargs):
"""
Wrapper for gradient check on RNNs;
ensures that backprop-through-time is run to completion,
computing the full gradient for the loss as summed over
the input sequence and predictions.
Do not modify this function!
"""
bptt_old = self.bptt
self.bptt = len(y)
print >> outfd, "NOTE: temporarily setting self.bptt = len(y) = %d to compute true gradient." % self.bptt
NNBase.grad_check(self, x, y, outfd=outfd, **kwargs)
self.bptt = bptt_old
print >> outfd, "Reset self.bptt = %d" % self.bptt