Abdiaziz commited on
Commit
bdb546a
·
1 Parent(s): 56d9391

fixed model architecture error

Browse files
Files changed (1) hide show
  1. model.py +14 -15
model.py CHANGED
@@ -1,26 +1,25 @@
 
1
  import torch
2
  import torchvision
3
- from torchvision import models
4
- from torch import nn
5
 
6
- # create a script that will be used to hold the base arch- to load in effnet
 
7
 
8
- def create_vit_b_16():
9
  # get the weights
10
- vit_weights = models.ViT_B_16_Weights.DEFAULT
11
  # get the transforms
12
- vit_transforms = vit_weights.transforms()
13
  # get the model
14
- vit_b_16 = models.vit_b_16(weights = vit_weights)
15
 
16
  # freeze all base layers
17
- for param in vit_b_16.parameters():
18
- param.requires_grad = False
19
 
20
- # change the classifier head
21
- vit_b_16.heads = nn.Sequential(nn.Linear(in_features = 768,
22
- out_features = 3,
23
- bias = True)
24
- )
25
 
26
- return vit_b_16, vit_transforms
 
1
+ # create a fucntions that creates an effnet_b2 model and returns its transformation
2
  import torch
3
  import torchvision
 
 
4
 
5
+ from torch import nn
6
+ from torchvision import models
7
 
8
+ def create_effnet_b2():
9
  # get the weights
10
+ effnet_b2_weights = models.EfficientNet_B2_Weights.DEFAULT
11
  # get the transforms
12
+ effnet_b2_transforms = effnet_b2_weights.transforms()
13
  # get the model
14
+ effnet_b2 = models.efficientnet_b2(weights = effnet_b2_weights)
15
 
16
  # freeze all base layers
17
+ for params in effnet_b2.parameters():
18
+ params.requires_grad = False
19
 
20
+ # reset the classifier head
21
+ effnet_b2.classifier = nn.Sequential(nn.Dropout(p = 0.3, inplace = True),
22
+ nn.Linear(in_features = 1408, out_features = 3)
23
+ )
 
24
 
25
+ return effnet_b2, effnet_b2_transforms