question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An issue about the default initialize methods.

See original GitHub issue

Hello, I’m training some custom models with ESPNet2. And I find that the default initialize method checking the bias parameters of NN by the p.dim() function. This check is not precise (some parameters my also make p.dim() == 1 be True ) and set them to zero may lead to abnormal training. (I found one of my module always output zeros and the training may dead with ReLU. After removing the following lines, the training becomes OK. )

https://github.com/espnet/espnet/blob/96bd74641ceb463096067223d0734f70bddd8def/espnet2/torch_utils/initialize.py#L77-L80

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
popcornellcommented, Aug 10, 2022
for name, p in model.named_parameters(): 
    if 'bias' in name:
        p.data.zero_() 

maybe make it case insensitive too just to be sure. This is difficult to implement in a scalable way. Current solution thus makes sense.

Maybe raising a warning also could be useful so user knows that the bias is set to zero. But warning should be likely raised once (e.g. for each layer of that class) otherwise will be too verbose maybe.

0reactions
kan-bayashicommented, Oct 3, 2022

I found this issue has an impact on the most of TTS models since TTS modules is initialized using this method as a default. https://github.com/espnet/espnet/blob/14fcb2d42b2609f766ffaa7a79e9c921cd8398d9/espnet2/tts/fastspeech2/fastspeech2.py#L470-L475 https://github.com/espnet/espnet/blob/14fcb2d42b2609f766ffaa7a79e9c921cd8398d9/espnet2/tts/fastspeech2/fastspeech2.py#L828-L829

The model including BatchNorm2d or BatchNorm1d modules should be improved with this changes. (I’m not sure what is happened before fixing this issue…)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default initialization - cppreference.com
Default initialization is performed in three situations: 1) when a variable with automatic, static, or thread-local storage duration is declared ...
Read more >
Problem of initialization in C++ - GeeksforGeeks
In this article, we will discuss the problem of initialization in C++, the data members of a class have private scope by default, ......
Read more >
PSA: Don't initialize default values in Java - Google Groups
Whether or not we initialise default values I think the real problem is that calling a non-final method in a constructor gives non-intuitive ......
Read more >
java - When is an interface with a default method initialized?
Before a class is initialized, its direct superclass must be initialized, but interfaces implemented by the class are not initialized. Similarly ...
Read more >
Lint/UselessMethodDefinition marks empty `initialize ... - GitHub
Lint/UselessMethodDefinition marks empty initialize methods that take arguments as a violation even though they differ from the default ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found