vgg
vgg
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 1/6
2/27/2019 vgg slides
VGG Architecture
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 2/6
2/27/2019 vgg slides
In [2]: conv_arch = ((1, 64), (1, 128), (2, 256), (2, 512), (2, 512))
Now, we will implement VGG-11. This is a simple matter of executing a for loop over
conv_arch.
net = vgg(conv_arch)
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 3/6
2/27/2019 vgg slides
Next, we will construct a single-channel data example with a height and width of 224 to
observe the output shape of each layer.
In [4]: net.initialize()
X = nd.random.uniform(shape=(1, 1, 224, 224))
for blk in net:
X = blk(X)
print(blk.name, 'output shape:\t', X.shape)
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 4/6
2/27/2019 vgg slides
Model Training
Since VGG-11 is more complicated than AlexNet let's use a smaller network.,
In [5]: ratio = 4
small_conv_arch = [(pair[0], pair[1] // ratio) for pair in conv_arch]
net = vgg(small_conv_arch)
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 5/6
2/27/2019 vgg slides
Training Loop
training on gpu(0)
epoch 1, loss 0.9533, train acc 0.654, test acc 0.852, time 37.7 sec
epoch 2, loss 0.4086, train acc 0.850, test acc 0.886, time 35.8 sec
epoch 3, loss 0.3319, train acc 0.878, test acc 0.900, time 35.9 sec
epoch 4, loss 0.2915, train acc 0.894, test acc 0.904, time 35.9 sec
epoch 5, loss 0.2605, train acc 0.905, test acc 0.911, time 35.8 sec
http://127.0.0.1:8000/vgg.slides.html?print-pdf#/ 6/6