Skip to content

Tree like structure #33

@snapo

Description

@snapo

Is there a way instead of using random , that we use a tree like structure that is always a multiple powers of 2?

Sample

    def forward(self, x):
        # Input layer (8 inputs)
        x = x.view(-1, 8)
        
        # First layer (4 gates)
        l1 = torch.stack([
            self.gates[0](x[:,0], x[:,1]),
            self.gates[1](x[:,2], x[:,3]),
            self.gates[2](x[:,4], x[:,5]),
            self.gates[3](x[:,6], x[:,7]),
        ], dim=1)
        
        # Second layer (2 gates)
        l2 = torch.stack([
            self.gates[4](l1[:,0], l1[:,1]),
            self.gates[5](l1[:,2], l1[:,3]),
        ], dim=1)
        
        # Final output gate
        out = self.gates[6](l2[:,0], l2[:,1])
        return torch.sigmoid(out)  # For binary classification

akin to this image:

Image

where blue are the inputs, black are the diff logic gates, orange is the output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions