Browse Source

[bugfix]修改了modules/utils.py中`initial_parameter()`函数的bug (#300)

* fix bug

* Update utils.py
tags/v0.6.0
郑恒毅 GitHub 4 years ago
parent
commit
94be3315a6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      fastNLP/modules/utils.py

+ 4
- 1
fastNLP/modules/utils.py View File

@@ -66,7 +66,10 @@ def initial_parameter(net, initial_method=None):
init.normal_(w.data) # bias
elif m is not None and hasattr(m, 'weight') and \
hasattr(m.weight, "requires_grad"):
init_method(m.weight.data)
if len(m.weight.size()) > 1:
init_method(m.weight.data)
else:
init.normal_(m.weight.data) # batchnorm or layernorm
else:
for w in m.parameters():
if w.requires_grad:


Loading…
Cancel
Save