Thanks to visit codestin.com
Credit goes to github.com

Skip to content

use correct initialisation in linear module#14034

Closed
mrTsjolder wants to merge 3 commits into
pytorch:masterfrom
mrTsjolder:patch-1
Closed

use correct initialisation in linear module#14034
mrTsjolder wants to merge 3 commits into
pytorch:masterfrom
mrTsjolder:patch-1

Conversation

@mrTsjolder

Copy link
Copy Markdown
Contributor

From this discussion it appears that the linear layer should be initialised according to (LeCun et al., 1998). However, LeCun et al. promote a variance of 1/n, rather than a uniform distribution with bounds 1/n! Also biases are generally expected to be initialised with zeros.

@ezyang ezyang added the module: bc-breaking Related to a BC-breaking change label Nov 15, 2018
@ezyang

ezyang commented Nov 15, 2018

Copy link
Copy Markdown
Contributor

@soumith I'm not sure we can change the default initialization of linear, this might be too BC-breaking. Thoughts?

@ezyang

ezyang commented Dec 6, 2018

Copy link
Copy Markdown
Contributor

I'm going to say that we are not going to change this. If you want to submit a doc patch suggesting the alternate initialization method, I'd be very happy to accept it.

@ezyang ezyang closed this Dec 6, 2018
@ssnl

ssnl commented Dec 6, 2018

Copy link
Copy Markdown
Collaborator

I’d say we should initialize bias to zeros. It is very standard and reasonable. We did a similar patch for BN recently.

@ezyang

ezyang commented Dec 6, 2018

Copy link
Copy Markdown
Contributor

OK, reopening.

@ezyang ezyang reopened this Dec 6, 2018

@fmassa fmassa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about changing the initialization. This is a backward-incompatible change and people's code might suffer performance change, which will be hard to catch.

Comment thread torch/nn/modules/linear.py Outdated
Comment thread torch/nn/modules/linear.py Outdated
From [this discussion](https://discuss.pytorch.org/t/whats-the-default-initialization-methods-for-layers/3157/17) it appears that the linear layer should be initialised according to (LeCun et al., 1998). However, LeCun et al. promote a variance of `1/n`, rather than a uniform distribution with bounds `1/n`! Also biases are generally initialised to be zero.
@kostmo

kostmo commented Dec 20, 2019

Copy link
Copy Markdown
Member

💊 CircleCI build failures summary and remediations

As of commit f76098a:

  • 1/3 broken upstream at merge base 348d421 (see grid view)

    You may want to rebase on the viable/strict branch (expand for instructions)

    If your commit is newer than viable/strict, you can try basing on an older, stable commit:

    git fetch viable/strict
    git rebase --onto viable/strict $(git merge-base origin/master HEAD)
    

    If your commit is older than viable/strict:

    git fetch viable/strict
    git rebase viable/strict
    

    Check out the recency history of this "viable master" tracking branch.

  • 2/3 failures introduced in this PR

Detailed failure analysis

One may explore the probable reasons each build failed interactively on the Dr. CI website.

🕵️ 2 new failures recognized by patterns

The following build failures don't appear to be due to upstream breakage:

See CircleCI build caffe2_onnx_py2_gcc5_ubuntu16_04_test (1/2)

Step: "Test" (full log | pattern match details)

Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_linear FAILED [ 2%]
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_gather_opset11 PASSED   [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_ge PASSED               [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_gelu PASSED             [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_gt PASSED               [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_hardtanh PASSED         [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_implicit_expand PASSED  [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_index PASSED            [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_isnan PASSED            [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_layer_norm_aten PASSED  [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_le PASSED               [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_linear FAILED           [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_log_sigmoid PASSED      [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_logsoftmax PASSED       [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_lt PASSED               [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_master_opset PASSED     [  2%] 
Dec 20 00:30:15 test/onnx/test_operators.py::TestOperators::test_max PASSED              [  2%] 
Dec 20 00:30:16 test/onnx/test_operators.py::TestOperators::test_maxpool PASSED          [  2%] 
Dec 20 00:30:16 test/onnx/test_operators.py::TestOperators::test_maxpool_dilations PASSED [  2%] 
Dec 20 00:30:16 test/onnx/test_operators.py::TestOperators::test_maxpool_indices PASSED  [  2%] 
Dec 20 00:30:16 test/onnx/test_operators.py::TestOperators::test_mean PASSED             [  3%] 
Dec 20 00:30:16 test/onnx/test_operators.py::TestOperators::test_mean_dtype PASSED       [  3%] 

See CircleCI build caffe2_onnx_py3_6_clang7_ubuntu16_04_test (2/2)

Step: "Test" (full log | pattern match details)

Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_linear FAILED [ 2%]
Dec 20 00:39:07 test/onnx/test_operators.py::TestOperators::test_gather_opset11 PASSED   [  2%] 
Dec 20 00:39:07 test/onnx/test_operators.py::TestOperators::test_ge PASSED               [  2%] 
Dec 20 00:39:07 test/onnx/test_operators.py::TestOperators::test_gelu PASSED             [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_gt PASSED               [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_hardtanh PASSED         [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_implicit_expand PASSED  [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_index PASSED            [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_isnan PASSED            [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_layer_norm_aten PASSED  [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_le PASSED               [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_linear FAILED           [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_log_sigmoid PASSED      [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_logsoftmax PASSED       [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_lt PASSED               [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_master_opset PASSED     [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_max PASSED              [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_maxpool PASSED          [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_maxpool_dilations PASSED [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_maxpool_indices PASSED  [  2%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_mean PASSED             [  3%] 
Dec 20 00:39:08 test/onnx/test_operators.py::TestOperators::test_mean_dtype PASSED       [  3%] 

🚧 1 upstream failure recognized by patterns:

These builds matched patterns, but were probably caused by upstream breakages:


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 2 times.

@pytorchbot

Copy link
Copy Markdown
Collaborator

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
Stale pull requests will automatically be closed 30 days after being marked Stale

@pytorchbot pytorchbot added Stale and removed Stale labels Apr 12, 2022
@github-actions

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the Stale label Jun 11, 2022
@github-actions github-actions Bot closed this Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants