1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import torch
5import torch.nn as nn
6import torch.nn.functional as F
7
8class SignsToTB(nn.Module):
9 """
10 Radiological signs to Tuberculosis module
11
12 """
13 def __init__(self, input_size, hidden_size):
14 super().__init__()
15 self.input_size = input_size
16 self.hidden_size = hidden_size
17 self.fc1 = torch.nn.Linear(self.input_size, self.hidden_size)
18 self.relu = torch.nn.ReLU()
19 self.fc2 = torch.nn.Linear(self.hidden_size, 1)
20
21 def forward(self, x):
22 """
23
24 Parameters
25 ----------
26
27 x : list
28 list of tensors.
29
30 Returns
31 -------
32
33 tensor : :py:class:`torch.Tensor`
34
35 """
36 hidden = self.fc1(x)
37 relu = self.relu(hidden)
38
39 output = self.fc2(relu)
40
41 return output
42
43def build_signs_to_tb(input_size, hidden_size):
44 """
45 Build SignsToTB shallow model
46
47 Returns
48 -------
49
50 module : :py:class:`torch.nn.Module`
51
52 """
53
54 model = SignsToTB(input_size, hidden_size)
55 model.name = "signs_to_tb"
56 return model