Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Kernel Initializer issue #364

Merged
merged 3 commits into from
May 28, 2020

Conversation

ananno
Copy link
Contributor

@ananno ananno commented Jul 11, 2019

To fix the kernel initializer issue in function conv2d in lmnet/lmnet/layers.py.

Motivation and Context

The argument definition of kernel_initializer of the function conv2d in lmnet/lmnet/layers/layers.py has never been passed into tf.layers.conv2d function call resulting it not effective even if it is passed from the calling function. This change is necessary to pass the parameters in tf.layers.conv2d function by defining and passing arguments like kernel_initializer or kernel_regularizer etc.

Description

The kernel_initializer argument is defined in the function argument of conv2d but never passed in tf.layers.conv2d function in the code body. This results to not passing the kernel regularizer defined or passed by the calling function.

The fix is very simple. By removing the argument definition in conv2d function in lmnet/lmnet/layers/layers.py file. The defined argument like kernel_initializer or any others supported by tf.layers.conv2d function can be automatically passed via *args, **kwargs.

Details discussion on this is documented in issue here.

How has this been tested?

From the code it is obvious that the argument definition of kernel_initializer in conv2d function has never been used.

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / Optimization (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@blueoilbot
Copy link

Can one of the admins verify this patch?

@hadusam hadusam added the CI: auto-run Run CI automatically label Jul 12, 2019
@Joeper214
Copy link
Contributor

Joeper214 commented Jul 17, 2019

@ananno Please rebase this branch from the current blueoil/master branch.

So that we can only see the commits you did on your branch.
Currently, there are 1,004 commits which many are unrelated to this PR.

@ananno ananno force-pushed the kernel_initializer_issue branch from 88ed213 to 376e1e5 Compare July 17, 2019 10:15
@ananno
Copy link
Contributor Author

ananno commented Jul 17, 2019

@ananno Please rebase this branch from the current blueoil/master branch.

So that we can only see the commits you did on your branch.
Currently, there are 1,004 commits which many are unrelated to this PR.

I've resolved the issue. Please check and confirm.
Thank you.

@Joeper214
Copy link
Contributor

run test

@blueoil-butler blueoil-butler bot added CI: test-all Run all tests once and removed CI: test-all Run all tests once labels Jul 18, 2019
@iizukak
Copy link
Member

iizukak commented Jul 30, 2019

@ananno
Thank you for fixing the bug!!
As you comment in this PR, current lmnet implementation looks not pass kernel_initializer to TensorFlow.
So, currently, TensorFlow use default value None
https://www.tensorflow.org/api_docs/python/tf/layers/conv2d

And if your code will be merged, we use xavier_initializer as default (in your screenshot).

I thinks make None as default looks better.
How do you think?

@iizukak iizukak self-requested a review July 30, 2019 05:34
@iizukak
Copy link
Member

iizukak commented Jul 30, 2019

@nlpng
This PR effect many network.
It's good to be merge?

@iizukak
Copy link
Member

iizukak commented Jul 30, 2019

@nlpng and I checked TensorFlow use glorot_uniform when kernel_initializer is None.
And glorot_uniform is Xavier initializer with uniform distribution.
So there is no problem about default initializer.

https://github.com/tensorflow/tensorflow/blob/456fbc0e498e3d10604973de9f46ca48d62267cc/tensorflow/python/keras/layers/convolutional.py#L108

@iizukak
Copy link
Member

iizukak commented Jul 31, 2019

run test

@blueoil-butler blueoil-butler bot added CI: test-all Run all tests once and removed CI: test-all Run all tests once labels Jul 31, 2019
@Joeper214
Copy link
Contributor

@ananno Please fix failed tests as well.

@ananno ananno force-pushed the kernel_initializer_issue branch from 693c64d to c83e067 Compare October 3, 2019 05:39
@bo-code-review-bot
Copy link

This PR needs Approvals as follows.

  • Ownership Approval for / from iizukak, tkng, ruimashita
  • Readability Approval for Python from tkng, tsawada

Please choose reviewers and requet reviews!

Click to see how to approve each reviews

You can approve this PR by triggered comments as follows.

  • Approve all reviews requested to you (readability and ownership) and LGTM review
    Approval, LGTM

  • Approve all ownership reviews
    Ownership Approval or OA

  • Approve all readability reviews
    Readability Approval or RA

  • Approve specified review targets

    • Example of Ownership Reviewer of /: Ownership Approval for / or OA for /
    • Example of Readability Reviewer of Python: Readability Approval for Python or RA for Python
  • Approve LGTM review
    LGTM

See all trigger comments

Please replace [Target] to review target

  • Ownership Approval
    • Ownership Approval for [Target]
    • OA for [Target]
    • Ownership Approval
    • OA
    • Approval
  • Readability Approval
    • Readability Approval for [Target]
    • RA for [Target]
    • [Target] Readability Approval
    • [Target] RA
    • Readability Approval
    • RA
    • Approval
  • LGTM
    • LGTM
    • lgtm

@ananno ananno force-pushed the kernel_initializer_issue branch from 0afb811 to 630159b Compare December 20, 2019 08:15
@ananno ananno changed the title Kernel Initializer issue WIP: Kernel Initializer issue Dec 20, 2019
@ananno ananno force-pushed the kernel_initializer_issue branch from 630159b to 07ffdf4 Compare December 20, 2019 08:49
@ananno ananno changed the title WIP: Kernel Initializer issue Kernel Initializer issue Dec 20, 2019
@ananno ananno self-assigned this Dec 20, 2019
@ananno ananno requested a review from tsawada December 20, 2019 08:52
@ananno
Copy link
Contributor Author

ananno commented Dec 20, 2019

@tsawada San: Can you please do Readability review on this PR.
Thank you

@ananno
Copy link
Contributor Author

ananno commented Dec 20, 2019

@iizukak San: You approved this PR but I think according to new policy you've to approve the ownership review. Please approve as ownership review.

Thank you

@ananno ananno requested a review from iizukak December 20, 2019 08:54
Copy link
Contributor

@tsawada tsawada left a comment

Choose a reason for hiding this comment

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

Readability Approval

@iizukak
Copy link
Member

iizukak commented Dec 20, 2019

Please check CI status.

@ananno ananno requested a review from iizukak January 28, 2020 08:36
Copy link
Member

@iizukak iizukak left a comment

Choose a reason for hiding this comment

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

Ownership Approval

@ananno
Copy link
Contributor Author

ananno commented Jan 28, 2020

@tsawada San:
Can you please review this PR for Readability Approval.

@ananno ananno force-pushed the kernel_initializer_issue branch from 12cca0c to 984cd16 Compare January 29, 2020 07:40
@tsawada tsawada removed their request for review January 29, 2020 07:41
Copy link
Contributor

@tkng tkng left a comment

Choose a reason for hiding this comment

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

Please revert this change, pull request should not include any cosmetic change without reason.

(I meant this line

kernel_initializer=tf.contrib.layers.variance_scaling_initializer,) # he initializer
)

@ananno ananno force-pushed the kernel_initializer_issue branch from c6c0987 to d5e602b Compare February 3, 2020 03:23
@ananno
Copy link
Contributor Author

ananno commented Feb 3, 2020

Please revert this change, pull request should not include any cosmetic change without reason.

(I meant this line

kernel_initializer=tf.contrib.layers.variance_scaling_initializer,) # he initializer

)

@tkng San:
Thank you for the explanation. I've revert the cosmetic change. Please review one more time.

@ananno ananno requested a review from tkng February 3, 2020 03:25
@tkng
Copy link
Contributor

tkng commented Feb 3, 2020

Readability Approval
Ownership Approval

@tkng
Copy link
Contributor

tkng commented Feb 3, 2020

/ready

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Feb 3, 2020

⏳Merge job is queued...

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Feb 3, 2020

😥Status check failed. Please fix problems and send /ready again.

@Joeper214 Joeper214 added the CI: test-all Run all tests once label Feb 3, 2020
@blueoil-butler blueoil-butler bot removed the CI: test-all Run all tests once label Feb 3, 2020
@tkng tkng added the CI: test-lmnet Run lmnet test once label Feb 3, 2020
@blueoil-butler blueoil-butler bot removed the CI: test-lmnet Run lmnet test once label Feb 3, 2020
@ananno ananno force-pushed the kernel_initializer_issue branch from a575dd5 to c93b5c1 Compare February 5, 2020 08:37
ananno added 2 commits May 26, 2020 17:40
Without defining kernel_initializer parameter it will have the default value provided by TF. Also it can be provided via network kwargs.
In darknet the kernel_initializer was wrongly implemented, i.e. function call instead of function name. This bug was hiding under the `kernel_initializer` argument issue in `conv_2D` function in `layers.py`.
@ananno ananno force-pushed the kernel_initializer_issue branch from 4307767 to d745070 Compare May 26, 2020 08:40
@ananno
Copy link
Contributor Author

ananno commented May 26, 2020

/ready

@ananno
Copy link
Contributor Author

ananno commented May 28, 2020

/ready

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented May 28, 2020

⏳Merge job is queued...

@bo-mergebot bo-mergebot bot merged commit f1e3b43 into blue-oil:master May 28, 2020
@ananno ananno deleted the kernel_initializer_issue branch May 28, 2020 06:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants