diff --git a/python/paddle/fluid/input.py b/python/paddle/fluid/input.py index ba84d221b1d039b19d28610574ed21fe4689d62c..68d145ca467b415d6abb70f1374a4512cd2e152a 100644 --- a/python/paddle/fluid/input.py +++ b/python/paddle/fluid/input.py @@ -104,16 +104,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_v2", inputs=inputs, diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index a975ca5b60939c26f36f7cfdb40c94a1b46a6881..1234c6f83de30e7e0fb0e7cad63dd7c0e1719135 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -8731,16 +8731,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,