-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
28 lines (24 loc) · 751 Bytes
/
models.py
File metadata and controls
28 lines (24 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Models
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.models import resnet50, ResNet50_Weights
class baseline_pretrain(nn.Module):
"""
Baseline model for facial expression prediction
Finetunes a layer on top of resnet pretrain
Args:
hidden_size,
drop_prob
"""
def __init__(self, num_classes = 8):
super(baseline_pretrain, self).__init__()
self.model_ft= resnet50(pretrained = ResNet50_Weights)
num_ftrs = self.model_ft.fc.in_features
self.model_ft.fc = nn.Linear(num_ftrs, num_classes)
def forward(self, x):
# forward through linear layers
out = self.model_ft(x)
return out