-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel_rz.py
68 lines (51 loc) · 1.66 KB
/
model_rz.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
#
#Copyright (C) 2023 ISTI-CNR
#Licensed under the BSD 3-Clause Clear License (see license.txt)
#
import torch
import torch.nn as nn
import torch.nn.functional as F
from rezero import *
from regressor import *
#
#
#
class BlockQ(nn.Module):
def __init__(self, in_size, out_size, std = 1):
super(BlockQ, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(in_size, out_size, 3, stride = std, padding=1),
nn.ReLU())
def forward(self, input):
return self.conv(input)
#
#
#
class QNetRZ(nn.Module):
def __init__(self, in_size=1, out_size=1, params_size = None, bSigmoid = True):
super(QNetRZ, self).__init__()
self.conv = nn.Sequential(
BlockQ(in_size, 32),
Conv2DRZ(32),
nn.MaxPool2d(2),
BlockQ(32, 64),
Conv2DRZ(64),
nn.MaxPool2d(2),
BlockQ(64, 128),
Conv2DRZ(128),
nn.MaxPool2d(2),
BlockQ(128, 256),
Conv2DRZ(256),
nn.MaxPool2d(2),
BlockQ(256, 512),
Conv2DRZ(512),
nn.MaxPool2d(2)
)
self.regressor = Regressor(512, out_size, params_size, bSigmoid)
def forward(self, stim, lmax = None):
features = self.conv(stim)
q = self.regressor(features, lmax)
return q
if __name__ == '__main__':
model = QNetRZ()
print(model)