question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi pretrained weights: Cleanups and Refactoring

See original GitHub issue

Candidates:

  • Reduce code duplication on model builders by refactoring. For example potentially push the weigh loading mechanism in the private builder methods currently inherited from torchvision.models. Also we could provide a pretrained deprecation method.
  • Review recipe links and ensure they are accurate for all Community Contributed models. Check if possible for some of them to remap their training process to our current ref scripts.
  • Decide how quantized models will link to their unquantized versions.
  • Naming conventions:
    • The name of the Weights base Enum class and the naming convention of the inheriting classes. Also make sure that all classes are aligned with the model builder names. How are we going to handle _ in names (for example on inception_v3 and the resnext models)?
    • The name of the WeightEntry data class.
    • The name of Weights.verify() method (because it does more than just verification).
    • The names of the enum values; also their styles (all capital?). Example: ImageNet1K_RefV1
    • Currently the _RefV1 of one model doesn’t have to be _RefV1 of another model. For example ResNet vs RegNets use different recipes with the same enum value. In other cases, we skip _RefV1 and go directly to _RefV2, for example the WideResNet50 weights. Is this a problem?
  • Decide the signature of models._api.get_weight() and make it public. Ensure it’s torchhub-friendly.

cc @datumbox @pmeier @bjuncek @NicolasHug

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
datumboxcommented, Oct 19, 2021

@NicolasHug Thanks for the thoughts. Another idea we discussed with @jdsgomes offline was the fact that the names of Enums are too long due to our naming conventions for some models. For example for fasterrcnn_resnet50_fpn() the enum is FasterRCNNResNet50FPNWeights which frankly is too long and too unreadable. One option would be to drop completly the “Weights” from the inheriting classes. For example: FasterRCNNResNet50FPN.

At any case, please everyone feel free to add candidates on the list. To unblock the multi-pretrained initiative we were lenient on the reviews concerning nitpicking, naming etc, so we should definitely do a more careful round before moving the code to main torchvision. 😃

1reaction
NicolasHugcommented, Oct 19, 2021

Thanks for opening this discussion @jdsgomes , I agree naming is important! (and hard)

In this case, everything is private right? If we don’t expect users to interact directly with these classes (i.e they won’t be inheriting from them), I feel like there isn’t too much risk in choosing an imperfect naming, because this will only really affect us (the devs).

I personally don’t mind Weights and WeightEntry, they’re not super obvious at first but it becomes clear when one sees the instanciation of e.g. the ResNet50Weights class. I think this will be the case for any naming we choose IMHO. My only note about the current naming is that WeightEntry could probably be WeightsEntry.

I think your suggestions above are good too. I’ll just add another one: WeightsEnum and Weights. e.g.:

class ResNet50Weights(WeightsEnum):
    ImageNet1K_RefV1 = Weights(...)
    ImageNet1K_RefV2 = Weights(...)
    ...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cleanup Quantized ShuffleNet #4854 - pytorch/vision - GitHub
Adds quantized weights for shufflenet_v2_x0_5 variant, so that the equivalent model builder ... Multi pretrained weights: Cleanups and Refactoring #4652.
Read more >
Changelog — MMDetection 2.18.0 documentation
Refactor dense heads to decouple onnx export logics from get_bboxes and speed up inference ... Fix download links of RegNet pretrained weights (#5655)....
Read more >
Multi-Criteria Code Refactoring Using Search-Based Software ...
In this article, we propose a multi-objective search-based approach for automating the recommendation of refactorings. The process aims at ...
Read more >
(PDF) Comparing Commit Messages and Source Code Metrics for ...
We used a multi-objective algorithm to generate refactoring solutions that ... fied from the survey (refactor, clean-up, rewrite, restructure, redesign, ...
Read more >
Files · 24b91ae0c4ed84987f645a1c216cac1df5d8db1f · maxmzkr ...
The multi-task loss simplifies and speeds up training. ... the next sections to download pre-computed object proposals and pre-trained ImageNet models ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found