Coverage for /scratch/builds/bob/bob.med.tb/miniconda/conda-bld/bob.med.tb_1637571489937/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.8/site-packages/bob/med/tb/models/logistic_regression.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

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 LogisticRegression(nn.Module): 

9 """ 

10 Radiological signs to Tuberculosis module 

11 

12 """ 

13 def __init__(self, input_size): 

14 super().__init__() 

15 self.linear = torch.nn.Linear(input_size, 1) 

16 

17 def forward(self, x): 

18 """ 

19 

20 Parameters 

21 ---------- 

22 

23 x : list 

24 list of tensors. 

25 

26 Returns 

27 ------- 

28 

29 tensor : :py:class:`torch.Tensor` 

30 

31 """ 

32 output = self.linear(x) 

33 

34 return output 

35 

36def build_logistic_regression(input_size): 

37 """ 

38 Build logistic regression module 

39 

40 Returns 

41 ------- 

42 

43 module : :py:class:`torch.nn.Module` 

44 

45 """ 

46 

47 model = LogisticRegression(input_size) 

48 model.name = "logistic_regression" 

49 return model