提交 c37e8c25 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

do not assume that by default you are dealing only with tensors

上级 001185db
...@@ -250,10 +250,12 @@ def Rop(f, wrt, eval_points): ...@@ -250,10 +250,12 @@ def Rop(f, wrt, eval_points):
for pack in enumerate(zip(wrt, eval_points)): for pack in enumerate(zip(wrt, eval_points)):
i = pack[0] i = pack[0]
wrt_elem, eval_point = pack[1] wrt_elem, eval_point = pack[1]
if not isinstance(wrt_elem, gof.Variable):
wrt_elem = as_tensor_variable(wrt_elem) wrt_elem = as_tensor_variable(wrt_elem)
if not isinstance(eval_point, gof.Variable):
eval_point = as_tensor_variable(eval_point) eval_point = as_tensor_variable(eval_point)
try:
wrt_dim = len(wrt_elem.type.broadcastable) wrt_dim = len(wrt_elem.type.broadcastable)
eval_dim = len(eval_point.type.broadcastable) eval_dim = len(eval_point.type.broadcastable)
...@@ -265,6 +267,10 @@ def Rop(f, wrt, eval_points): ...@@ -265,6 +267,10 @@ def Rop(f, wrt, eval_points):
str(wrt_dim) + str(wrt_dim) +
' versus ' + ' versus ' +
str(eval_dim)) str(eval_dim))
except:
# wrt_elem and eval_point can be non-tensor variable which do
# not have broadcastable flags
pass
seen_nodes = {} seen_nodes = {}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论