Views
No views yet
torchvision.models.efficientnet_b7EfficientNet_B7_Weights.DEFAULTcuda (if available) with a set manual seed of 37 for reproducibility.train and test directories.


1import torch
2import torchvision
3
4# I loaded the model architecture
5weights = torchvision.models.EfficientNet_B7_Weights.DEFAULT
6model = torchvision.models.efficientnet_b7(weights=weights)
7
8# I modified the classifier
9model.classifier = torch.nn.Sequential(
10 torch.nn.Dropout(p=0.2, inplace=True),
11 torch.nn.Linear(in_features=2560, out_features=3, bias=True),
12)
13
14# I loaded the saved weights
15model.load_state_dict(torch.load("EfficientNet_B7_20percent.pth", map_location="cpu"))
16model.eval()