Skip to content

Commit 8f9f152

Browse files
committed
fix exception bug and one_hot expand; test=develop
1 parent 53af150 commit 8f9f152

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

python/paddle/fluid/clip.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from . import layers
2222
from . import framework
2323
from . import core
24+
from .dygraph import not_support
2425

2526
__all__ = [
2627
'ErrorClipByValue',
@@ -335,6 +336,7 @@ def _create_operators(self, param, grad):
335336
return param, new_grad
336337

337338

339+
@not_support
338340
def set_gradient_clip(clip, param_list=None, program=None):
339341
"""
340342
To specify parameters that require gradient clip.

python/paddle/fluid/framework.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ def dtype(self):
655655
def lod_level(self):
656656
# TODO(minqiyang): Support lod_level in dygraph mode
657657
if in_dygraph_mode():
658-
raise Exception, "Dygraph model DO NOT supprt lod"
658+
raise Exception("Dygraph model DO NOT supprt lod")
659659
return self.desc.lod_level()
660660

661661
@property

python/paddle/fluid/layers/nn.py

+2
Original file line numberDiff line numberDiff line change
@@ -6576,6 +6576,7 @@ def one_hot(input, depth):
65766576
inputs = {'X': input}
65776577
attrs = {'depth': depth}
65786578
else:
6579+
depth.stop_gradient = True
65796580
inputs = {'X': input, 'depth_tensor': depth}
65806581
attrs = {}
65816582
helper.append_op(
@@ -9355,6 +9356,7 @@ def contain_tensor(expand_times):
93559356
new_expand_times = []
93569357
for ele in expand_times:
93579358
if isinstance(ele, Variable):
9359+
ele.stop_gradient = True
93589360
new_expand_times.append(ele)
93599361
else:
93609362
assert (isinstance(ele, int))

0 commit comments

Comments
 (0)