You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233
  1. import torch
  2. from torch import nn
  3. class SymbolNet(nn.Module):
  4. def __init__(self, num_classes=4, image_size=(28, 28, 1)):
  5. super(SymbolNet, self).__init__()
  6. self.conv1 = nn.Sequential(
  7. nn.Conv2d(1, 32, 5, stride=1),
  8. nn.ReLU(),
  9. nn.MaxPool2d(kernel_size=2, stride=2),
  10. nn.BatchNorm2d(32, momentum=0.99, eps=0.001),
  11. )
  12. self.conv2 = nn.Sequential(
  13. nn.Conv2d(32, 64, 5, padding=2, stride=1),
  14. nn.ReLU(),
  15. nn.MaxPool2d(kernel_size=2, stride=2),
  16. nn.BatchNorm2d(64, momentum=0.99, eps=0.001),
  17. )
  18. num_features = 64 * (image_size[0] // 4 - 1) * (image_size[1] // 4 - 1)
  19. self.fc1 = nn.Sequential(nn.Linear(num_features, 120), nn.ReLU())
  20. self.fc2 = nn.Sequential(nn.Linear(120, 84), nn.ReLU())
  21. self.fc3 = nn.Sequential(nn.Linear(84, num_classes))
  22. def forward(self, x):
  23. x = self.conv1(x)
  24. x = self.conv2(x)
  25. x = torch.flatten(x, 1)
  26. x = self.fc1(x)
  27. x = self.fc2(x)
  28. x = self.fc3(x)
  29. return x

An efficient Python toolkit for Abductive Learning (ABL), a novel paradigm that integrates machine learning and logical reasoning in a unified framework.