-
Notifications
You must be signed in to change notification settings - Fork 150
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
Metrics example #610
Comments
Yes yes, you can, we currently don't have a tutorial for this rn, but I can help you through the steps, it should be straight forward. If everything works at the end you can make a PR with a tutorial =) Similarly to fastai, the only necessary step is to inherit from class MyMetric(Metric):
def accumulate(self, records, preds) -> None:
"""Accumulate stats for a single batch"""
def finalize(self) -> Dict[str, float]:
"""Called at the end of the validation loop"""
|
Thanks for the help. I'll get working on it, and look forward to the PR. For my second question: how do I go about plotting losses? I tried to use faster_rcnn.interp.plot_top_losses(...) but I keep getting the error, on any of the loss:
|
I believe your model might be in eval mode, can you explicitly put into training |
For the finalize function: I am calculating top-k accuracy, using the classification labels. I want to create a function like this one:
In this case, is it correct to assume that I would need to accumulate the labels from each record in a batch, put these in a torch tensor, then just run the above? |
That would work, but I think a better way would be to calculate the accuracy per batch and then average everything out on |
Thank you. Explicitly setting model.train() fixed the issue.
Would you have a sample I can borrow from? |
I was thinking of something like this: class MyMetric(Metric):
def __init__(self):
super().__init__
self._accs = []
def accumulate(self, records, preds):
accuracy = calculate_accuracy(records, preds)
self._accs.append(accuracy)
def finalize(self) -> Dict[str, float]:
final_accuracy = np.mean(self._accs)
return {'accuracy': final_accuracy} |
Yes, thank you. I'll get working on it. |
📓 New <Tutorial/Example>
Is this a request for a tutorial or for an example?
Example
What is the task?
I would like to write custom metrics for my task. Is there an example of how to define metrics for input to the training loop? In fastai, we have the ability to define our metric, and pass that in to the training. Can this be done here as well?
Second question: how do I plot training and validation losses? or accuracy/metric plots?
Is this example for a specific model?
No
Is this example for a specific dataset?
No
Don't remove
Main issue for examples: #39
The text was updated successfully, but these errors were encountered: