Add variable as input parameter in deep learning model

G
garreysingh · Apr 15, 2021 · 1.9K views
Question
I am working on CNN model which increases pixel value of input image by x times. Here, the value of x is different for each pixel, which can be managed by CNN. I also want the value of x to be decided differently based on another variable. However, CNN model only takes image as input. How can I add another additional variable with image as input for CNN model?
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Aug 24, 2026
You can refer to Multiple-Input and Multiple-Output Networks to create a network with multiple inputs.
The following is an example:
 
%% Define muliple input network.
layers1 = [
    imageInputLayer([28 28 3],'Name','input')  
    convolution2dLayer(3,3,'Padding','same','Name','conv_1')
    multiplicationLayer(2,'Name','mul')
    regressionLayer('Name','regression')];

lgraph = layerGraph(layers1);

layers2 = [imageInputLayer([28 28 3],'Name','x')];

lgraph = addLayers(lgraph,layers2);
% Connect layers.
lgraph = connectLayers(lgraph,'x','mul/in2');
% Analyze network.
analyzeNetwork(lgraph)
You can refer to  List of Deep Learning Layers for the available layers and Deep Learning Custom Layers to create a custom layer for your problem.
 
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!