Skip to content

discriminator

Discriminator

Bases: nn.Module

A 3-layer MLP for domain classification.

Source code in pytorch_adapt\models\discriminator.py
 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
class Discriminator(nn.Module):
    """
    A 3-layer MLP for domain classification.
    """

    def __init__(self, in_size=2048, h=2048, out_size=1):
        """
        Arguments:
            in_size: size of the input
            h: hidden layer size
            out_size: size of the output
        """

        super().__init__()
        self.h = h
        self.net = nn.Sequential(
            nn.Linear(in_size, h),
            nn.ReLU(),
            nn.Linear(h, h),
            nn.ReLU(),
            nn.Linear(h, out_size),
        )
        self.out_size = out_size

    def forward(self, x):
        """"""
        return self.net(x).squeeze(1)

__init__(in_size=2048, h=2048, out_size=1)

Parameters:

Name Type Description Default
in_size

size of the input

2048
h

hidden layer size

2048
out_size

size of the output

1
Source code in pytorch_adapt\models\discriminator.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def __init__(self, in_size=2048, h=2048, out_size=1):
    """
    Arguments:
        in_size: size of the input
        h: hidden layer size
        out_size: size of the output
    """

    super().__init__()
    self.h = h
    self.net = nn.Sequential(
        nn.Linear(in_size, h),
        nn.ReLU(),
        nn.Linear(h, h),
        nn.ReLU(),
        nn.Linear(h, out_size),
    )
    self.out_size = out_size