diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index bbb3b9a3d233fa07d1739b82cdeee635599d8b5c..f2ba117db144cf0b5d69b606690953b7a0aa181b 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5244,16 +5244,16 @@ def one_hot(input, depth, allow_out_of_range=False): if in_dygraph_mode(): inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: if not isinstance(depth, Variable): # user attribute inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: depth.stop_gradient = True inputs = {'X': input, 'depth_tensor': depth} - attrs = {} + attrs = {'allow_out_of_range': allow_out_of_range} helper.append_op( type="one_hot", inputs=inputs,