Closed arthur-thuy closed 10 months ago
Hello,
we should definitely explain this better, but the ideal case will always be MCCaching + replicate_in_memory=False
.
MCCaching works by caching the output of each layer so that it doesn't recompute during MCDropout.
When we use replicate_in_memory=False
, the MC Sampling loop is replaced with:
predictions = [model(input) for _ in range(Iterations)]
This means that we compute a lot of redundant features. When adding MCCaching
, we compute the high-level features (before Dropout layers) only once.
I will add a warning in the code directly I think. If there is a caching layer somewhere in the model we should warn that it is not optimized. What do you think?
Hello, thank you for the response. I agree that a warning in the code is most useful. In the documentation, a brief explanation of how the module works internally might indeed also encourage users to try it out.
Is your feature request related to a problem? Please describe. Not really a feature request but more of a discussion about the choice of
replicate_in_memory
in the ModelWrapper when using the new MCCachingModule.I noticed that the MCCachingModule documentation uses
replicate_in_memory=False
in the experiments. Before, I always usedTrue
in my code, which is also used in experiments/vgg_mcdropout_cifar10.py asTrue
is the default. As such, I compared runtimes on an NVIDIA RTX A5000.False
True
False
True
Findings:
False
, MCCaching is around 45%-50% faster than Regular. (This is lower than the 70% found for the GeForce 1060Ti)False
" is around 20%-30% faster than "Regular -True
"True
, MCCaching is around 5% slower than RegularDo you have an idea why MCCaching and
replicate_in_memory
have such interaction effects?Describe the solution you'd like In the documentation, it might be useful to discourage the combination of MCCaching and
replicate_in_memory=True
as this is 5% slower than the "Regular -True
" scenario.Describe alternatives you've considered /
Additional context /