-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecogn_models.py
executable file
·69 lines (62 loc) · 2.42 KB
/
recogn_models.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import torch.nn as nn
import torch
from torchvision import models
from net.st_gcn import Model as GCN
class AlexNet(nn.Module):
def __init__(self, model_type):
super(AlexNet, self).__init__()
self.model_type = model_type
if model_type == 'pre':
model = models.alexnet(pretrained=True)
self.features = model.features
fc = nn.Linear(256, 4096)
fc.bias = model.classifier[1].bias
fc.weight = model.classifier[1].weight
self.classifier = nn.Sequential(
#nn.Dropout(),
fc)
#nn.ReLU(inplace=True))
if model_type == 'new':
self.features = nn.Sequential(
nn.Conv2d(3, 64, 11, 4, 2),
nn.ReLU(inplace = True),
nn.MaxPool2d(3, 2, 0),
nn.Conv2d(64, 192, 5, 1, 2),
nn.ReLU(inplace=True),
nn.MaxPool2d(3, 2, 0),
nn.Conv2d(192, 384, 3, 1, 1),
nn.ReLU(inplace = True),
nn.Conv2d(384, 256, 3, 1, 1),
nn.ReLU(inplace=True))
#nn.MaxPool2d(3, 2, 0))
self.classifier = nn.Sequential(
nn.Dropout(),
nn.Linear(1024, 4096),
nn.ReLU(inplace=True))
def forward(self, x):
x = self.features(x)
#print(x.shape)
x = x.view(x.size(0), -1)
#print(x.shape)
out = self.classifier(x)
return out
class O3N(nn.Module):
def __init__(self, model_type, output_size):
super(O3N, self).__init__()
#self.alexnet = AlexNet(model_type)
#self.classifier = nn.Sequential(
#nn.Dropout(),
#nn.Linear(4096, 128),
#nn.ReLU(inplace=True),
#nn.Dropout(),
#nn.Linear(128, output_size))
#nn.ReLU(inplace=True))
self.gcn = GCN(3, output_size, {'layout': 'ntu-rgb+d', 'strategy': 'spatial'}, True)
self.video_num = output_size
def forward(self, input):
#shape = input.shape
#input = input.view(*shape[0:3], shape[3] * shape[4])
#X = self.alexnet(input)
#X = self.classifier(X)
X = self.gcn(input)
return X