-
Notifications
You must be signed in to change notification settings - Fork 16
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
CLN: Refactor model abstraction, fix #737 #726 #753
Merged
NickleDave
merged 48 commits into
main
from
refactor-model-class-to-not-subclass-lightning-module
May 6, 2024
Merged
CLN: Refactor model abstraction, fix #737 #726 #753
NickleDave
merged 48 commits into
main
from
refactor-model-class-to-not-subclass-lightning-module
May 6, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…, not Type[ModelDefinition]
…d to have class variables definition and family, that are *both* used by the from_config method to make a new instance of the family with instances of the definition's attributes (trust me, this makes perfect sense)
…s Model, then make a new instance of the subclass, add that instance to the registry, and then return the instance. This makes it possible to call the 'from_config' method of the instance and get a new class instance. Think of the instance as a Singleton
…, remove from_config method
…ove from_config method
…ingleton that can return new lightning.Module instances with the appropriate instances of network + loss + optimizer + metrics from its from_config method
…ParametricUmapModel
…f LightningModule, not vak.base.Model
…ibutes, that are used by from_config method
…ass anymore, but we do change Model instance's __name__,__doc__, and __module__ to match those of the definition
…ot pytorch_lightning.LightningModule :eyeroll:) and to no longer pass network, loss, etc to super().__init__ since its no longer a sub-class of models.base.Model
…ghtning.pytorch.LightningModule) and to no longer pass network, loss, etc to super().__init__ since its no longer a sub-class of models.base.Model
…optimizer/metrics as attributes on self
…izer/metrics as attributes on self
…assification_model.py
…n src/vak/config/model.py
…etwork.encoder sub-table
…rc/vak/models/decorator.py
…ing with duplicate values -- we need to not use the 'epoch' Scalar since it's all zeros
NickleDave
deleted the
refactor-model-class-to-not-subclass-lightning-module
branch
May 6, 2024 17:00
NickleDave
added a commit
that referenced
this pull request
May 6, 2024
NickleDave
added a commit
that referenced
this pull request
May 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the model abstraction, basically as described here: #737 (comment)
We replace
vak.models.base.Model
, that sub-classedlightning.LightningModule
, withvak.models.factory.ModelFactory
, that no longer sub-classesLightningModule
. Instead, its__init__
takes a model definition and a model family, the latter of which is alightning.LightningModule
, and itsfrom_config
andfrom_instances
methods return new instances of thefamily
, with instances of thenetwork
,loss
,optimizer
, andmetrics
attributes of the definition.This is really just a shim, in the form of several layers of indirection, to fix the broken logging for now. I'm not sure it makes it much easier to add a model (see #751).
But it does appear to fix the logging issue--logs look as expected when I inspect them now.