How to visualize CNN architecture?

  Kiến thức lập trình

Hello 🙂 I need somehow visualize the CNN model.
I’ve just learned about LeNet and AlexNet types of services but I can’t manage to do it properly. Could you please help? Here’s the model itself:

model = nn.Sequential()
model.add_module('conv1', nn.Conv2d(in_channels=3, out_channels=32, kernel_size=2, padding=1)) 
model.add_module('relu1', nn.ReLU()) 
model.add_module('pool1', nn.MaxPool2d(kernel_size=2))  
model.add_module('dropout1', nn.Dropout(p=0.4))

model.add_module('conv2', nn.Conv2d(in_channels=32, out_channels=64, kernel_size=2, padding=1))
model.add_module('relu2', nn.ReLU())        
model.add_module('pool2', nn.MaxPool2d(kernel_size=2))   
model.add_module('dropout2', nn.Dropout(p=0.4))

model.add_module('conv3', nn.Conv2d(in_channels=64, out_channels=128, kernel_size=2, padding=1))
model.add_module('relu3', nn.ReLU())        
model.add_module('pool3', nn.MaxPool2d(kernel_size=2))
model.add_module('dropout3', nn.Dropout(p=0.4))

model.add_module('conv4', nn.Conv2d(in_channels=128, out_channels=256, kernel_size=2, padding=1))
model.add_module('relu4', nn.ReLU()) 


model.add_module('conv5', nn.Conv2d(in_channels=256, out_channels=512, kernel_size=2, padding=1))
model.add_module('relu5', nn.ReLU())

model.add_module('pool4', nn.AvgPool2d(kernel_size=8)) 
model.add_module('flatten', nn.Flatten())  

model.add_module('fc', nn.Linear(512, 1))  
model.add_module('sigmoid', nn.Sigmoid())   
model

LEAVE A COMMENT