MATLAB: Multi-InputLayers of deep learning or Separate the output of ImageInputLayer

cnndeep learning

Hello, guys! I am learning something on deep learning in MATLAB. Here I built a plain Network with eight layers and two branches. I am wandering if I could change the output of the InputImageLayer, say, deliver the original minibatch to the first branch and subregions of the minibatch to the second branch. Am I supposed to define a CustomLayer? Any useful suggestions will be appreciated.
It’s necessary for me to some extent, since the subregions should be treated in a different module.
Certainly, muli-InputLayers can also work since I can put the original and cropped images into different branches respectively.
Reward is possible if necessary.
Kai, Yue

Best Answer

Eventually I have found a feasible solution by myself. It is promising, since user can apply this trick to figure out the problem that multi-input layers are not allowed currently. (Although this will also be fixed in the later version of MATLAB.)
The solution is adding several FilterLayers, defined by custom, to choose the desired output from the ImageInputLayer. Multi-input problem can be solved as well by this means. In detail, I defined a custom ImageDatastore to transform the images in a special way, say, add characteristic values to them. Therefore, different input images can be recognized in the FilterLayers when characteristic values are detected. Interestingly, the transformation is reversible; hence, original images can be recovered in the FilterLayers.
For more details, feel free to contact me.
KAI, YUE.sln.png