Skip to content

Commit

Permalink
[ASR] Remove fluid api and useless import, test=asr (#2944)
Browse files Browse the repository at this point in the history
* remove fluid api and useless import.

* fix variable name
  • Loading branch information
zxcd authored Feb 21, 2023
1 parent e8deb1d commit dcf8ef0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from collections import defaultdict
from turtle import Turtle
from typing import Dict
from typing import List
from typing import Tuple
Expand Down
6 changes: 3 additions & 3 deletions paddlespeech/s2t/training/gradclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def _dygraph_clip(self, params_grads):
if len(sum_square_list) == 0:
return params_grads

global_norm_var = layers.concat(sum_square_list)
global_norm_var = paddle.concat(sum_square_list)
global_norm_var = paddle.sum(global_norm_var)
global_norm_var = paddle.sqrt(global_norm_var)

# debug log
logger.debug(f"Grad Global Norm: {float(global_norm_var)}!!!!")

max_global_norm = layers.fill_constant(
shape=[1], dtype=global_norm_var.dtype, value=self.clip_norm)
max_global_norm = paddle.full(
shape=[1], dtype=global_norm_var.dtype, fill_value=self.clip_norm)
clip_var = paddle.divide(
x=max_global_norm,
y=paddle.maximum(x=global_norm_var, y=max_global_norm))
Expand Down

0 comments on commit dcf8ef0

Please sign in to comment.