Comments (6)
Dear @intel-hm, rather than populating the init
, perhaps another simple way to connect picture and code could consist in something like this:
import torch
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# 1 input image channel, 6 output channels, 5x5 square convolution
# kernel
self.conv1 = nn.Conv2d(1, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
# an affine operation: y = Wx + b
self.fc1 = nn.Linear(16 * 5 * 5, 120) # 5*5 from image dimension
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)
def forward(self, input):
c1 = F.relu(self.conv1(input))
# Max pooling over a (2, 2) window
s2 = F.max_pool2d(c1, (2, 2))
c3 = F.relu(self.conv2(s2))
# If the size is a square, you can specify with a single number
s4 = F.max_pool2d(c3, 2)
# flatten all s4 dimensions except the batch dimension, before applying fc1
s4 = torch.flatten(s4, 1)
f5 = F.relu(self.fc1(s4))
f6 = F.relu(self.fc2(f5))
output = self.fc3(f6)
return output
net = Net()
net
Wdyt?
from tutorials.
from tutorials.
We could include the comments you added in your suggestion to the renaming I did within the forward
.
from tutorials.
from tutorials.
Hi @intel-hm, I've just created a PR, I added you as a co-author. I slightly modify the original one.
from tutorials.
from tutorials.
Related Issues (20)
- pipeline_tutorial failing due to dead torchtext link HOT 3
- [BUG] transformer_tutorial.html is failing
- [BUG] ddp_pipeline.html is outdated
- Contradiction in `save_for_backward`, what is permitted to be saved
- I think `optimizer.zero_grad()` should go before `loss.backward()` HOT 5
- Minor style bug: missing space
- [BUG] - intermediate_source/torch_export_tutorial.py fails against 2.3 RC binaries HOT 2
- [BUG] - Loss calculation problem in train-loop HOT 2
- Minor style bug: remove backticks in the section of code
- [BUG] Remove TorchText tutorial
- [BUG] - missing import in Reinforcement Learning (PPO) Tutorial
- Misleading example for per-sample gradient HOT 3
- Issues with se2seq tutorial (batch training)
- [BUG] - torchvision_tutorial.py fails with a RuntimeError
- 💡 [REQUEST] - Add a Timestamp to Every Tutorial
- Transformer tutorial multiplying with sqrt(d_model)
- [BUG] - issue::checkpoints are not saving the information and weights after few days. givinig different results. HOT 7
- A typo in the comments
- Better specify `torch.compile behaviour` on nested function/module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tutorials.