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

Avoid a 2nd forward pass during validation step #857

Open
bw4sz opened this issue Dec 17, 2024 · 0 comments
Open

Avoid a 2nd forward pass during validation step #857

bw4sz opened this issue Dec 17, 2024 · 0 comments
Labels
API This tag is used for small improvements to the readability and usability of the python API. Feature Request New feature or request Performance Question on model performance and accuracy

Comments

@bw4sz
Copy link
Collaborator

bw4sz commented Dec 17, 2024

Deepforest primary connects to Torchvision models. Torchvision models have a 'train' and 'eval' mode, which are uncomfortably named, because it also effects what is outputted. In train mode, the loss is returned, in eval mode, the predictions are returned.

https://discuss.pytorch.org/t/how-to-get-losses-and-predictions-at-the-same-time/167223

from https://pytorch.org/vision/main/models/generated/torchvision.models.detection.retinanet_resnet50_fpn.html#torchvision.models.detection.retinanet_resnet50_fpn

image

The line of code is here.

preds = self.model.forward(images)

  1. its a performance hit to run the network twice.
  2. When we start to add more architectures we don't want to enforce this structure
  3. Its got a terrible name and we always need to make sure we wrap in no_grad to make sure it doesn't update weights or batch_norms.
@bw4sz bw4sz added Feature Request New feature or request Performance Question on model performance and accuracy API This tag is used for small improvements to the readability and usability of the python API. labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API This tag is used for small improvements to the readability and usability of the python API. Feature Request New feature or request Performance Question on model performance and accuracy
Projects
None yet
Development

No branches or pull requests

1 participant