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

Add mixin class and inherit it in torchplate.experiment.Experiment #2

Open
rosikand opened this issue Sep 4, 2022 · 1 comment
Open

Comments

@rosikand
Copy link
Owner

rosikand commented Sep 4, 2022

Add a bunch of experiment utility functions in a mixin class to be inherited in torchplate.experiment.Experiment (and therefore also inherited in subclasses of torchplate.experiment.Experiment). Example methods to include:

  • test_model_accuracy for classification experiments
@rosikand
Copy link
Owner Author

Bumping this to include a simple test loop for a classification model next update. Should be of the form:

    def test(self, model, testloader, weights):
        # if weights is not None..., load weights 
        acc = tp_metrics.Accuracy()
        tqdm_loader = tqdm(testloader)
        for batch in tqdm_loader:
            x, y = batch
            logits = model(x)
            acc.update(logits, y)
            tqdm_loader.set_description(f'Accuracy: {acc.get()}')
        
        final_acc = acc.get()
        print(f'Accuracy: {final_acc}')
        acc.reset()

        return final_acc

can even include a separate version that uses self. attributes.

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

No branches or pull requests

1 participant