-
Notifications
You must be signed in to change notification settings - Fork 200
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
Use class-resolver
for readouts and enable choosing MaxReadout
#68
base: master
Are you sure you want to change the base?
Conversation
Hi! That's a useful update. Do you want to add more commits or shall I mark this ready for review? |
I have a few more ideas for this if you can give me another day to put them in! |
Specifically, I'd like to us the |
@KiddoZhu is there any automated testing in this package? |
class-resolver
for readouts and enable choosing MaxReadout
I read the post and that's a pretty cool idea. Actually we came up with a very similar idea in Currently, we only resolve call-by-name for models, tasks, and optimizers. Ideally, we want everything has a unique name in the registry, so that |
@cthoyt No, there are some tests already but I am not very familiar with the CI system. Do you know any reference for designing a CI for such a library, especially when some of the test script relies on GPU hardware? |
Ideally code works the same whether you’re on cpu or gpu - the hardware details are abstracted by pytorch. I’ve never had to explore testing on GPU. I’m not really sure how to interpret your feedback. Are you saying the registry system accomplishes the same thing as the class resolver? I think after reading the linked documentation I am only more confused. I also see you’ve reverted all of my changes - is there a reason, like you don’t want to add an external dependency? At least I think it would make sense to make a helper function to reduce all of this code duplication |
I revert the code to a naive branching implementation. The class-resolver is awesome. However, if we want to adopt that, we need to make it consistent everywhere in the codebase (e.g. covering the activation functions and some others). At this moment, we are not ready for this. Feel free to open another issue or pull request to discuss this feature. |
@cthoyt Sorry I put the wrong link -- it's this one, from torchdrug.core import Registry as R
@R.register("layers.readout.max")
class MaxReadout(nn.Module):
...
readout = "max"
if isinstance(readout, str):
readout = R.search(readout)() We are also considering to augment the registry to support both lowercase and canonical names, very similar to yours. We've already applied this for reconstructing model from nested dict of hyperparameters, resolving molecule features, and probably use it for metrics in the near future. I like your |
7392070
to
e73d2c9
Compare
This pull request does the following:
class-resolver
to reduce the if/else logic used to pick readouts