Hello, How can i enable the dropout during the validation and Test time
Any suggestion
You can use a callback:
model = YOLO("yolo11n-cls.pt")
def enable_dropout(validator):
from torch import nn
import inspect
model = inspect.currentframe().f_back.f_back.f_locals["model"]
for m in model.model.model.modules():
if isinstance(m, nn.Dropout):
m.p = 0.5
m.train()
print("Enabled Dropout")
model.add_callback("on_val_start", enable_dropout)
results = model.val(data="imagenet10")
1 Like