-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDFAD_model_base.py
More file actions
56 lines (41 loc) · 1.54 KB
/
DFAD_model_base.py
File metadata and controls
56 lines (41 loc) · 1.54 KB
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
import torch.nn as nn
import torch
class DFADModel(nn.Module):
def __init__(self):
super(DFADModel, self).__init__()
dropout_rate = 0.335
leaky_relu_slope = 0.01
self.layers = nn.Sequential(
nn.Linear(1536, 1536),
nn.BatchNorm1d(1536),
# nn.ReLU(),
nn.LeakyReLU(negative_slope=leaky_relu_slope),
# nn.Sigmoid(),
nn.Dropout(p=dropout_rate),
nn.Linear(1536, 1536),
nn.BatchNorm1d(1536),
# nn.ReLU(),
nn.LeakyReLU(negative_slope=leaky_relu_slope),
nn.Dropout(p=dropout_rate),
nn.Linear(1536, 1536),
nn.BatchNorm1d(1536),
# nn.ReLU(),
nn.LeakyReLU(negative_slope=leaky_relu_slope),
nn.Dropout(p=dropout_rate),
)
#
self.output_layer = nn.Linear(1536, 1)
#he initialization
for layer in self.layers:
if isinstance(layer, nn.Linear):
nn.init.kaiming_uniform_(layer.weight, mode='fan_in', nonlinearity='relu')
nn.init.kaiming_uniform_(self.output_layer.weight, mode='fan_in', nonlinearity='relu')
def forward(self, inputs, text_inputs):
# Example of concatenating inputs and text_inputs along the last dimension
x = torch.cat((inputs, text_inputs), dim=-1) # Adjust dim as needed
x = self.layers(x)
output = self.output_layer(x)
return output
if __name__ == '__main__':
model = DFADModel()
print(model)