MatrixAI / Keras-Visualisation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keras Visualisation

We want to write a demo for the visualising convolutional neural networks using Keras.

Note that we have a simple convnet model in the paper. They add a deconvnet attached to each layer.

I want to eventually see if that's possible in the resnet.

Because the GPU version may not work until we have a proper tensorflow!?

We can use the resnet50 model from Keras applications, but the resnet101 has to be reimplemented.

Because that is in Formbay.

Remember you created a resnet module. But we cannot actually use resnet anyway. You want that to be eventually reimplemented actually so you can just use it.

https://files.daylen.com/visualizing-residual-networks.pdf

So apparently they used standard convnets defined in 2012. That would be things like VGGNet and AlexNet.

The 2012 Alex Krizhevsky network they are talking about is called AlexNet which was created in 2012.

So VGGNet is roughly equivalent right?

Keras doesn't have Alexnet.

VGGNet used 3x3 filters instead of 11x11 filters. The author's

[https://www.researchgate.net/publication/321829624/figure/fig2/AS:571845657481217@1513350037610/VGG16-architecture-16.ppm](Image of VGG16)

Note that that there are 2 Conv Layers, then Max Pooling. That reduces the size of the "feature map".

That shows the abstract layers that occur.

Note that the top means 3 fully connected layers at the end. This is now changed in resnet50. Which only has 1 fully connected layer.

https://github.com/keras-team/keras-applications/blob/master/keras_applications/resnet50.py#L258

The last dense thing is meant to eventually connect to the number of classes there are!

Here VGG 16: https://github.com/keras-team/keras-applications/blob/master/keras_applications/vgg16.py

Has 3 dense layers, with the last one being the number of classes.

You reduce spatially what matters, but you increase depth. The depth then captures more of the classes that can occur. At the end, your spatial dimensions reduce down to 1x1, but is spread into a 4096 depth. Before finally squeezing down to 1000. This requirement is part of classification.

The standard in input shape has been 224,224,3. This is the same image size used in a lot of research!

This is based on: https://github.com/jalused/Deconvnet-keras/blob/master/Deconvnet-keras.py

Layer Names:

input_1
block1_conv1
block1_conv2
block1_pool
block2_conv1
block2_conv2
block2_pool
block3_conv1
block3_conv2
block3_conv3
block3_pool
block4_conv1
block4_conv2
block4_conv3
block4_pool
block5_conv1
block5_conv2
block5_conv3
block5_pool
flatten
fc1
fc2
predictions

Also see the summary.txt generated by model.summary(). It shows that there are 138,357,544 parameters (weights) that is trainable. But in this case they are all trained.

https://github.com/jalused/Deconvnet-keras/blob/master/Deconvnet-keras.py

It is the 46th kernel. So we are showing each KERNEL's "generated image", from from a given layer.

Deconvolutional visualisation eventually led to generative neural networks like: https://distill.pub/2016/deconv-checkerboard/

About


Languages

Language:Python 80.0%Language:Nix 20.0%