-
Notifications
You must be signed in to change notification settings - Fork 0
/
combined.py
28 lines (20 loc) · 897 Bytes
/
combined.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
import torch
from torch import nn
import neural_net, aleatoric
class Net(nn.Module):
def __init__(self, input_size, output_size, hidden_size, hidden_count):
super(Net, self).__init__()
#self.mu = neural_net.FFDropoutLayers(input_size, output_size, hidden_size, hidden_count)
#self.log_sigma2 = neural_net.FFDropoutLayers(input_size, 1, hidden_size, hidden_count)
self.output_size = output_size
self.backbone = neural_net.FFDropoutLayers(input_size, output_size*2, hidden_size, hidden_count)
def forward(self, x):
# return self.mu(x), self.log_sigma2(x)
output = self.backbone(x)
return output[:, :self.output_size], output[:, self.output_size:]
def predict(data, net, T=25, class_count=10):
predictions = []
for t in range(T):
predictions.append(aleatoric.predict(data, net))
return sum(predictions)/len(predictions)
Loss = aleatoric.Loss