提交 596b7746 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Replace theano.tensor alias T with tt in theano.breakpoint

上级 62c6c1ea
import numpy as np import numpy as np
import theano import theano
import theano.tensor as tt
from theano.gof import Op, Apply from theano.gof import Op, Apply
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
...@@ -35,11 +37,11 @@ class PdbBreakpoint(Op): ...@@ -35,11 +37,11 @@ class PdbBreakpoint(Op):
.. code-block:: python .. code-block:: python
import theano import theano
import theano.tensor as T import theano.tensor as tt
from theano.breakpoint import PdbBreakpoint from theano.breakpoint import PdbBreakpoint
input = T.fvector() input = tt.fvector()
target = T.fvector() target = tt.fvector()
# Mean squared error between input and target # Mean squared error between input and target
mse = (input - target) ** 2 mse = (input - target) ** 2
...@@ -48,7 +50,7 @@ class PdbBreakpoint(Op): ...@@ -48,7 +50,7 @@ class PdbBreakpoint(Op):
# than 100. The breakpoint will monitor the inputs, targets as well # than 100. The breakpoint will monitor the inputs, targets as well
# as the individual error values # as the individual error values
breakpointOp = PdbBreakpoint("MSE too high") breakpointOp = PdbBreakpoint("MSE too high")
condition = T.gt(mse.sum(), 100) condition = tt.gt(mse.sum(), 100)
mse, monitored_input, monitored_target = breakpointOp(condition, mse, mse, monitored_input, monitored_target = breakpointOp(condition, mse,
input, target) input, target)
...@@ -71,7 +73,7 @@ class PdbBreakpoint(Op): ...@@ -71,7 +73,7 @@ class PdbBreakpoint(Op):
# Ensure that condition is a theano tensor # Ensure that condition is a theano tensor
if not isinstance(condition, theano.Variable): if not isinstance(condition, theano.Variable):
condition = theano.tensor.as_tensor_variable(condition) condition = tt.as_tensor_variable(condition)
# Validate that the condition is a scalar (else it is not obvious how # Validate that the condition is a scalar (else it is not obvious how
# is should be evaluated) # is should be evaluated)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论