Modify NASNet
See original GitHub issueDear @Cadene, Thank you for your fantastic repository. I want to modify NASNet (i.e., apply some minor modifications on NASNet by remove Dropout, add sigmoid layer at the end of net and etc.). I have implemented below code:
import torch
from torch.autograd import Variable
import torch.nn.functional as F
import torch.nn as nn
from nasnet import nasnetalarge
num_classes = 10
# *** Define Modified NASNet Class:
class ModifiedNASNet(nn.Module):
def __init__(self, num_classes):
super(ModifiedNASNet, self).__init__()
original_model = nasnetalarge(num_classes=1000, pretrained='imagenet')
# Everything except the last classifier:
self.features = nn.Sequential(*list(original_model.children())[:-4])
# Set number of features:
num_feats = 4032
# Plug our linear layer:
self.classifier = nn.Sequential(nn.Linear(num_feats, num_classes))
def forward(self, x):
f = self.features(x)
out = F.relu(f, inplace=True)
out = F.avg_pool2d(out, kernel_size=11, stride=1, padding=0, ceil_mode=False, count_include_pad=True)
out = out.view(out.size(0), -1) # Flatten
out = self.classifier(out)
out = F.sigmoid(out)
return out
# *** test above class:
model = ModifiedNASNet(num_classes).cuda()
# print(model)
x = Variable(torch.randn(1, 3, 331, 331), volatile=True).cuda()
out = model(x)
print(out)
However, the following error has occurred:
TypeError: forward() missing 1 required positional argument: 'x_stem_0'
Would you please kindly help me to address this problem?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
How to customize the first Reduction cells in NASnet-A ...
How to customize the first Reduction cells in NASnet-A according to variable input image size? In the 2018 Zoph et al paper, the...
Read more >NASNet
NASNet is a type of convolutional neural network discovered through neural architecture search. The building blocks consist of normal and reduction cells.
Read more >Review: NASNet — Neural Architecture Search Network ...
In this story, NASNet, by Google Brain, is reviewed. Authors propose to search for an architectural building block on a small dataset and ......
Read more >From AlexNet to NASNet: A Brief History and Introduction of ...
From AlexNet to NASNet: A Brief History and Introduction of Convolutional ... go through 2 convolution layers without changing image' size
Read more >Deep Learning ToolboxTM Model for NASNet-Large Network
Deep Learning ToolboxTM Model for NASNet-Large Network ... Pretrained NasNet-Large network model for image classification ... Adjust size of the image
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the nn.Sequential container, a module’s output is taken as the next module’s input. But
self.cell_stem1
takes input from both previous modules,self.conv0
andself.cell_stem_1
. Try something like this:Hello @ClimbsRocks. It has been a long time since I used this library… @Cadene ?