Skip to content

Make the forward function, which performs processing of x, more concise #10

@kounkou

Description

@kounkou

Description

I am currently reading the code and noticed we could improve the code to be more concise.
My proposal is to go from :

def forward(self, x):
        x = x.repeat(1, self._options["num_cnns"], 1)
        if self._options["num_fc"] <= 2:
            outs = self.linears(x)
        else:
            outs = self.linears(x)
            for i in range(len(self.linears_bg)):
                outs = self.linears_bg[i](outs)
            outs = self.last_linear(outs)
        out = self.final(outs)

to :

def forward(self, x):
    x = x.repeat(1, self._options["num_cnns"], 1)
    outs = self.linears(x)

    if self._options["num_fc"] > 2:
        for layer in self.linears_bg:
            outs = layer(outs)
        outs = self.last_linear(outs)
    
    return self.final(outs)

Testing

Currently, I just made sure the train can still proceed, since the update affects the networks only.
Well let me know if pull requests are welcome...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions