diff --git a/dygraph/transformer/model.py b/dygraph/transformer/model.py index b4ae428e3bc19a496f1ebdd12a65904a558a5adb..0187438dbdea428dd2371785b6b2ea92264e8991 100644 --- a/dygraph/transformer/model.py +++ b/dygraph/transformer/model.py @@ -88,9 +88,9 @@ class PrePostProcessLayer(Layer): bias_attr=fluid.ParamAttr( initializer=fluid.initializer.Constant(0.))))) elif cmd == "d": # add dropout - if dropout_rate: - self.functors.append(lambda x: layers.dropout( - x, dropout_prob=dropout_rate, is_test=False)) + self.functors.append(lambda x: layers.dropout( + x, dropout_prob=dropout_rate, is_test=False) + if dropout_rate else x) def forward(self, x, residual=None): for i, cmd in enumerate(self.process_cmd):