diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 00523c07987cb32fe3cf922a3cd76240b6b67139..ee165d092c1571f1775ac1072fc00777d1c99744 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -26,7 +26,7 @@ from ..initializer import Normal, Constant from ..framework import Variable, OpProtoHolder from ..param_attr import ParamAttr from .layer_function_generator import autodoc, templatedoc, _generate_doc_string_ -from .tensor import concat +from .tensor import concat, assign from . import utils from .. import unique_name from functools import reduce diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index d66d92b1df7fd4aa8312cca186c29a571d7c4af0..5d5657eae5210a06d8f1c82ed41446f34a42b63a 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -310,7 +310,10 @@ def assign(input, output=None, init_once=False): if output is None: if init_once: output = helper.create_parameter( - attr=ParamAttr(), shape=input.shape, dtype=input.dtype) + attr=ParamAttr(), + shape=input.shape, + dtype=input.dtype, + default_initializer=Constant(0.0)) else: output = helper.create_variable_for_type_inference( dtype=input.dtype)