MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / MyModel

Class MyModel

models/custom.py:13–43  ·  view source on GitHub ↗

Example custom model -- a simple CNN + MLP. Replace this with your own architecture.

Source from the content-addressed store, hash-verified

11
12
13class MyModel(nn.Module):
14 """
15 Example custom model -- a simple CNN + MLP.
16 Replace this with your own architecture.
17 """
18
19 def __init__(self, in_channels: int = 3, num_classes: int = 1000):
20 super().__init__()
21 self.features = nn.Sequential(
22 nn.Conv2d(in_channels, 64, 7, stride=2, padding=3),
23 nn.BatchNorm2d(64),
24 nn.ReLU(inplace=True),
25 nn.MaxPool2d(3, stride=2, padding=1),
26 nn.Conv2d(64, 128, 3, padding=1),
27 nn.BatchNorm2d(128),
28 nn.ReLU(inplace=True),
29 nn.Conv2d(128, 256, 3, padding=1),
30 nn.BatchNorm2d(256),
31 nn.ReLU(inplace=True),
32 nn.AdaptiveAvgPool2d((1, 1)),
33 )
34 self.classifier = nn.Linear(256, num_classes)
35
36 n_params = sum(p.numel() for p in self.parameters())
37 print(f"MyModel: {n_params / 1e6:.1f}M parameters")
38
39 def forward(self, x: torch.Tensor) -> torch.Tensor:
40 x = self.features(x)
41 x = x.flatten(1)
42 x = self.classifier(x)
43 return x

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected