Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

backbone.py 963 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
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
  1. import torch
  2. import torch.nn as nn
  3. import torch.nn.functional as F
  4. class Backbone(nn.Module):
  5. def __init__(self,embedding_size):
  6. super(Backbone,self).__init__()
  7. self.conv1 = nn.Conv2d(1,64,3,padding=1)
  8. self.bn1 = nn.BatchNorm2d(64)
  9. self.conv2 = nn.Conv2d(64,128,3,padding=1)
  10. self.bn2 = nn.BatchNorm2d(128)
  11. self.conv3 = nn.Conv2d(128,128,3,padding=1)
  12. self.bn3 = nn.BatchNorm2d(128)
  13. self.fc = nn.Linear(1152,embedding_size)
  14. def forward(self,x):
  15. # layer 1
  16. x = self.bn1(F.relu(self.conv1(x)))
  17. x = F.max_pool2d(x,2,2)
  18. # layer 2
  19. x = self.bn2(F.relu(self.conv2(x)))
  20. x = F.max_pool2d(x,2,2)
  21. # layer 3
  22. x = self.bn3(F.relu(self.conv3(x)))
  23. x = F.max_pool2d(x,2,2)
  24. # fc layer
  25. x = torch.flatten(x,1)
  26. x = self.fc(x)
  27. return x
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...