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

my_torch_model.py 596 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
  1. import torch.nn as nn
  2. import torch.nn.functional as F
  3. class Net(nn.Module):
  4. def __init__(self):
  5. super(Net, self).__init__()
  6. self.conv1 = nn.Conv2d(1, 20, 5, 1)
  7. self.conv2 = nn.Conv2d(20, 50, 5, 1)
  8. self.fc1 = nn.Linear(4*4*50, 500)
  9. self.fc2 = nn.Linear(500, 10)
  10. def forward(self, x):
  11. x = F.relu(self.conv1(x))
  12. x = F.max_pool2d(x, 2, 2)
  13. x = F.relu(self.conv2(x))
  14. x = F.max_pool2d(x, 2, 2)
  15. x = x.view(-1, 4*4*50)
  16. x = F.relu(self.fc1(x))
  17. x = self.fc2(x)
  18. return F.log_softmax(x, dim=1)
Tip!

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

Comments

Loading...