-
Notifications
You must be signed in to change notification settings - Fork 79
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
Adding GPU functionality, enabling data loaders/tuples as input #38
Conversation
@ajratner @bhancock8 first working cut at adding cuda/dev loader support (have tested it preliminarily on one of my applications). Comments welcome, tried to minimally change the interface (particularly to not change the interface to |
@jdunnmon Can we merge this into @bhancock8 thoughts on this? @jdunnmon once you've done this & tests are passing, tag me here so I can review then? Thanks! |
Yeah, I can prep the PR for |
Cool! I also suggest bc looks like this PR is already pulling in changes from master into dev, so will probably be cleaner anyway! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to make these same changes for the MultitaskClassifier? Any reason why we wouldn't?
I like the cuda changes. Thanks for adding those.
So the philosophy now is that they either pass in a tuple or a dataloader and we make a dataloader, then internally our train method always gets dataloaders, right?
My main concern with this PR is in the comment on the evaluate method; not sure we need a separate method to essentially just do some pre-formatting and then predict. (Though either way, it makes sense to have a batch[method name] version, of course).
metal/classifier.py
Outdated
|
||
else: | ||
raise ValueError( | ||
"Unrecognized input data structure, use tuple or DataLoader!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need an exclamation point. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, sounds good. Will update
@bhancock8 couple thoughts: (a) can go back and add this in for MultitaskClassifier as well @ajratner thoughts on (c)? |
The more I look at this, the more convinced I am that we don't need a new pair of methods here which duplicate a lot of the functionality of existing methods. I think we just need to add a batch_size kwarg to Classifier.score(), which it will pass down to predict(). And then inside predict() we can either call predict_proba() once or in batches. So any models overwriting predict_proba() don't need to worry about batches, and score just passes it down to predict. What do you think about that? |
As I've looked at it a little more, I see the issue: if they give us a dataloader with X and Y in score(), then we need to somehow split it before passing to predict(), since it expects only Xs. Here's what I suggest then: --score() accepts either (X, Y) or a DataLoader. If it's (X, Y), then first thing we make it into a DataLoader. For each batch, it calls predict, stores the results, and then once we have all of Y_p and Y, we calculate metrics once. |
@bhancock8 agreed in full!! @jdunnmon ping me when adjustments made and I'll do a more thorough look then! |
@bhancock8 @ajratner thanks for the thoughts! think that will work, i'll put in these changes (and update |
Thank you for putting it in! This will be good to have.
…On Mon 17 Sep 2018 at 07:42, Jared Dunnmon ***@***.***> wrote:
@bhancock8 <https://github.com/bhancock8> @ajratner
<https://github.com/ajratner> thanks for the thoughts! think that will
work, i'll put in these changes (and update MultitaskClassifier) as soon
as I can.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMD2zMZQh5EK47P2CgNSgYEMWOVvlaCbks5ubzZggaJpZM4WWjJC>
.
|
@jdunnmon @bhancock8 Done with my pass here! Take a look when you get a chance? Only remaining things that would be nice to have:
|
Oh also, my tests keep failing due to |
@bhancock8 @jdunnmon NVM, I'm pretty sure the formatting errors are coming from master. So should be fine to merge. @bhancock8 when you're up in a few hours, let us know if you can quickly review and approve the changes? |
- Tests for LabelModel.score
@bhancock8 , ready for your eyes. @ajratner and I went through today and made a bunch of changes to update the above and added a test for successful GPU usage. Alex's @ajratner I confirmed that the GPU test runs on my GPU machine and fails on my local mac due to no CUDA existing, so seems like it's doing what it should. Give it a spin tomorrow. If I've used this decorator right, Travis should ignore this test...we'll know soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, made a few more comments. I'm going to mark 'approve' so you're not stuck waiting for me on the merge, but do take a look at and address the few suggestions. Nice work!
When you do the merge, move the marker up to v0.2.0, baby!
metal/utils.py
Outdated
@@ -365,3 +365,13 @@ def slice_data(data, indices): | |||
return outputs[0] | |||
else: | |||
return outputs | |||
|
|||
|
|||
def mt_to_cuda(data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a better name here. I didn't now what "mt" meant. I mean, I assumed multitask, but what does it mean to convert a 'multitask' to cuda?
Can we also add a docstring here saying what the expected type of "data" is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this current function won't cover X
that comes in as a list, right? Will clean up now
One more thought: how can the formatting issues be the fault of master @ajratner when it's passing the tests just fine? I think it's something in our additions. Is there a more verbose setting you can use to have it print out what exactly it's upset about or would be changing? |
@bhancock8 I think it's because formatting is broken on master |
Passes GPU tests as well! |
Added cuda functionality in
Classifier
andEndModel
Modifies
Classifier
andEndModel
to give user option to use eitherDataLoader
ortuple
as inputRefactors to support the above + small bugfixes (import typos in
contrib
, etc.)Adds option for training progress bar for
EndModel
Updates multitask class structure to leverage the above
Update tests