File Exchange

image thumbnail

Semantic Segmentation Using FCN-AlexNet

version (2.27 MB) by Kei Otsuka
How to create, train and evaluate FCN-AlexNet for semantic segmentation


Updated 09 Feb 2018

View License

This demo shows how to create, train and evaluate AlexNet based Fully Convolutional Network for semantic segmentation. MATLAB and Computer Vision System Toolbox provides fcnLayers function to create FCN, but this is VGG-16 based FCN. If you would like to use lower the computational cost of network, FCN-AlexNet might be one of the options.
AlexNetをベースとしたFCNによるSemantic Segmentationのデモです。AlexNetベースのFCNを定義し、学習、ネットワークを評価するところまでをご紹介します。Computer Vision System ToolboxではfcnLayersと呼ばれる関数が提供されており、容易にFCNを定義することができますが、こちらはVGG-16をベースとしたネットワークになっています。 計算コストの関係でもう少しコンパクトなネットワークを試したい場合や、性能比較の基準としてVGG-16以外のネットワークをベースとしたFCNを試したい場合にお試しください。

Comments and Ratings (7)

Kei Otsuka


Created network by using fcnLayers is preinitialized using layers and weights from the VGG-16 network.
If you want to create FCN that is preinitialized using layers and weights from another network such as AlexNet,
you need to create network manually. This example shows how to do that.

In terms of SegNet, you can use segnetLayers function to create SegNet that uses layers and weights from VGG-16 or VGG-19 network. This would help you to understand the architecture of SegNet and then you can replace Layers to create AlexNet based SegNet.

As Has

As Has (view profile)

thanks so much, i really need it ,if you don't mind i have 2 questions :-
if i want to implement AlexNet for U-net and Segnet what i have to do
why you don't use the function ( fcnLayers) with matlab

Thanks a lot for your help. My mail :

Kei Otsuka

I have pretrained FCN-Alexnet that can be shared with you, but filesize is more than 200MB and I can not upload it to File Exchange due to the limitation. May I have your email address? I may be able to share pretrained network through another file transfer system.

could you provide any link for pretraining weights for FCN-AlexNet as for segnetVGG16CamVid:
pretrainedURL = '';

Kei Otsuka

Thanks for the note. The error message indicates that you are using CPU for training. I will try to find out where the issue is, but can you use GPU for training? Since it takes about a few hours for training even on GPU environment, I think that training deep neural network on CPU environment might be unreasonable in many cases.

Thank you for your great effort .
An error message appears when starting the network training as follow:
Training on single CPU.
Initializing image normalization.
| Epoch | Iteration | Time Elapsed | Mini-batch | Mini-batch | Base Learning |
| | | (hh:mm:ss) | Accuracy | Loss | Rate |
Error using trainNetwork (line 154)
Padding exceeds array bounds.

Error in fcnAlexNetExample (line 273)
[net, info] =

Caused by:
Error using builtin
Padding exceeds array bounds.

Thanks in advance


update html files

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor