Skip to content

autora.theorist.darts.fan_out

Fan_Out

Bases: Module

A neural network class that splits a given input vector into separate nodes. Each element of the original input vector is allocated a separate node in a computation graph.

Source code in temp_dir/darts/src/autora/theorist/darts/fan_out.py
 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
class Fan_Out(nn.Module):
    """
    A neural network class that splits a given input vector into separate nodes. Each element of
    the original input vector is allocated a separate node in a computation graph.
    """

    def __init__(self, num_inputs: int):
        """
        Initialize the Fan Out operation.

        Arguments:
                num_inputs (int): The number of distinct input nodes to generate
        """
        super(Fan_Out, self).__init__()

        self._num_inputs = num_inputs

        self.input_output = list()
        for i in range(num_inputs):
            linearConnection = nn.Linear(num_inputs, 1, bias=False)
            linearConnection.weight.data = torch.zeros(1, num_inputs)
            linearConnection.weight.data[0, i] = 1
            linearConnection.weight.requires_grad = False
            self.input_output.append(linearConnection)

    def forward(self, input: torch.Tensor) -> torch.Tensor:
        """
        Forward pass of the Fan Out operation.

        Arguments:
            input: input vector whose elements are split into separate input nodes
        """

        output = list()
        for i in range(self._num_inputs):
            output.append(self.input_output[i](input))

        return output

__init__(num_inputs)

Initialize the Fan Out operation.

Parameters:

Name Type Description Default
num_inputs int

The number of distinct input nodes to generate

required
Source code in temp_dir/darts/src/autora/theorist/darts/fan_out.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self, num_inputs: int):
    """
    Initialize the Fan Out operation.

    Arguments:
            num_inputs (int): The number of distinct input nodes to generate
    """
    super(Fan_Out, self).__init__()

    self._num_inputs = num_inputs

    self.input_output = list()
    for i in range(num_inputs):
        linearConnection = nn.Linear(num_inputs, 1, bias=False)
        linearConnection.weight.data = torch.zeros(1, num_inputs)
        linearConnection.weight.data[0, i] = 1
        linearConnection.weight.requires_grad = False
        self.input_output.append(linearConnection)

forward(input)

Forward pass of the Fan Out operation.

Parameters:

Name Type Description Default
input Tensor

input vector whose elements are split into separate input nodes

required
Source code in temp_dir/darts/src/autora/theorist/darts/fan_out.py
30
31
32
33
34
35
36
37
38
39
40
41
42
def forward(self, input: torch.Tensor) -> torch.Tensor:
    """
    Forward pass of the Fan Out operation.

    Arguments:
        input: input vector whose elements are split into separate input nodes
    """

    output = list()
    for i in range(self._num_inputs):
        output.append(self.input_output[i](input))

    return output