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

separate Sup3rGen and Sup3rGan #116

Merged
merged 4 commits into from
Nov 18, 2022
Merged

separate Sup3rGen and Sup3rGan #116

merged 4 commits into from
Nov 18, 2022

Conversation

malihass
Copy link
Collaborator

@malihass malihass commented Nov 17, 2022

In prevision of the addition of the conditional moment models, make Sup3rGan inherit from Sup3rGen which is a model that contains only the generator details.

This way, the conditional moment model will be able to inherit from the Sup3rGen class and will not carry the extra attributes associated with the discriminator.

I am opening the PR now in order to avoid large branch divergence since this PR changes how we call the base model

loss = loss_gen
elif train_disc:
loss = loss_disc
# print("min max out = %g / %g " %
Copy link
Collaborator

Choose a reason for hiding this comment

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

forgot to remove this

@@ -22,12 +21,11 @@
logger = logging.getLogger(__name__)


class Sup3rGan(AbstractSup3rGan):
"""Basic sup3r GAN model."""
class Sup3rGen(AbstractSup3rGan):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Separating this is a good idea

logger = logging.getLogger(__name__)


class Sup3rGan(Sup3rGen):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Im wondering if we should still call this file base.py, since it includes the "base" Gan model. This would avoid all the renamed imports, although that alone shouldn't prevent an improvement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, now that I think more about it, aside from the conditional moments models, all the models are GANs, so we can probably keep it as base

@malihass malihass merged commit edc18ce into main Nov 18, 2022
@malihass malihass deleted the interfaceGan branch November 18, 2022 15:59
github-actions bot pushed a commit that referenced this pull request Nov 18, 2022
separate Sup3rGen and Sup3rGan
@grantbuster
Copy link
Member

grantbuster commented Nov 18, 2022

@malihass a few comments:

  1. You might want to consider a forked inheritance hierarchy instead of a linear one. The Sup3rGan and Sup3rGen have different purposes and different model structures so having one be a subclass of the other may not be good OOP practice. For example, the majority of methods in Sup3rGan are just revising/overwriting the methods from Sup3rGen. You're basically writing two set's of methods for the two classes, a sign that maybe they should be parallel, not parent/child. The common methods should be abstracted into another parent class. This might not seem like a big deal, but one example where this kind of architecture causes problems down the road is because Sup3rGen has it's own purpose for the conditional moments so you might find yourself adding new methods specifically for that purpose, which would have to be removed or overwritten in the Sup3rGan.
  2. You should use super().__init__ methods - the init's have lots of duplicated lines
  3. If you add a new class that is meant to be instantiated and used directly (not abstract) you should add tests with that class.
  4. Nitpicky - Sup3rGan and Sup3rGen look very similar, would be better to rename Sup3rGen to Sup3rGenerator or Sup3rRegression (I prefer the latter)

@malihass malihass restored the interfaceGan branch November 18, 2022 17:07
@malihass
Copy link
Collaborator Author

My plan was to make Sup3rCondMom inherit from Sup3rGen, but then having 2 instantiated class and one being not used may be misleading still, and also points towards having just Sup3rCondMom and Sup3rGan and make them being siblings rather than parent/offspring.
I'll open another PR where I rework that interface by adding another abstract class which grabs all the utilities we have for training in Sup3rGan and that Sup3rCondMom can inherit from. I won't add Sup3rCondMom or Sup3rGen for now.

@grantbuster
Copy link
Member

My plan was to make Sup3rCondMom inherit from Sup3rGen, but then having 2 instantiated class and one being not used may be misleading still, and also points towards having just Sup3rCondMom and Sup3rGan and make them being siblings rather than parent/offspring. I'll open another PR where I rework that interface by adding another abstract class which grabs all the utilities we have for training in Sup3rGan and that Sup3rCondMom can inherit from. I won't add Sup3rCondMom or Sup3rGen for now.

Gotcha yeah agree with everything you just said. Here's one structure that I think might be most clean:

AbstractInterface (rename current AbstractSup3rGan) ->
AbstractSingleModel (has the non-overwritten common methods in Sup3rGan+Sup3rGen; "single" as opposed to the multi step models that use AbstractInterface) ->
Sup3rCondMom + Sup3rGan

@malihass malihass deleted the interfaceGan branch November 18, 2022 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants