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

new interface to clone used internally quite a bit

上级 ab092bd2
......@@ -725,3 +725,18 @@ def flatten(l):
"""flattens a list by one level only"""
return sum(l , [])
def reconstruct_graph(inputs, outputs, tag):
"""
Different interface to clone, that allows you to pass inputs.
Compared to clone, this method always replaces the inputs with
new variables of the same type, and returns those ( in the same
order as the original inputs).
"""
nw_inputs = [safe_new(x,tag) for x in inputs]
givens = {}
for nw_x, x in zip(nw_inputs, inputs):
givens[x] = nw_x
nw_outputs = clone( outputs, replace=givens)
return (nw_inputs, nw_outputs)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论