Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load trainability status of layers when importing them from JSON configuration #153

Closed
mkaze opened this issue Jun 24, 2021 · 4 comments · Fixed by #337
Closed

Load trainability status of layers when importing them from JSON configuration #153

mkaze opened this issue Jun 24, 2021 · 4 comments · Fixed by #337
Assignees
Labels
good first issue Good for newcomers
Milestone

Comments

@mkaze
Copy link
Contributor

mkaze commented Jun 24, 2021

Similar to #107, the trainability status of a layer is not taken into account when importing it from JSON configuration, e.g. if a layer is freezed in the saved JSON configuration it might be loaded as trainable (depending on the default value of isTrainable property for that layer).

To fix this, either each of the layer creator functions in ModelLoader.kt should be modified to set the isTrainable property of the created layer with value of config.trainable; or alternatively, this could be done in a single place like convertToLayer function for all layers. Further, one should take into account this issue when implementing a fix.

@zaleslaw
Copy link
Collaborator

I agree that it could be implemented now, but in reality, we need to add more check/IllegalStateExceptions if the layer implementing the NoGradients layer has an isTrainable == true status.

The idea is the following: layers with NoGradient marker interface should have this status as false.

@zaleslaw zaleslaw added the good first issue Good for newcomers label Jun 24, 2021
@zaleslaw zaleslaw added this to the 0.3 milestone Jun 24, 2021
@dosier
Copy link
Contributor

dosier commented Jul 8, 2021

I can do this one

@dosier
Copy link
Contributor

dosier commented Jul 8, 2021

I agree that it could be implemented now, but in reality, we need to add more check/IllegalStateExceptions if the layer implementing the NoGradients layer has an isTrainable == true status.

The idea is the following: layers with NoGradient marker interface should have this status as false.

Should these checks u mention for NoGradients layers be applied only to these, or to other layers as well. Because some layers do set isTrainable to false but do not implement NoGradients. So should these other layers implement NoGradients, or should we make another interface that every non trainable layers extends?

dosier added a commit to dosier/KotlinDL that referenced this issue Jul 8, 2021
@dosier
Copy link
Contributor

dosier commented Jul 8, 2021

Yo @zaleslaw or @mkaze what do ya think about something like this:
dosier@8e41418

I don't really like how the default value is true but can't nicely change it to something like:

    public var isTrainable: Boolean = this is NoGradients

without leaking this in the constructor.

I see three options:

  • keep it like in the commit I made
  • leak this in constructor of Layer class
  • add isTrainable as constructor param

But maybe one of your has a better idea (or anyone else!!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
3 participants