How to train a deep neural network with 2 inputs

112 views (last 30 days)
Hello, I just started to learn deep learning using Matlab. I had a problem with this two input model. Did I create the right model in Matlab? How to train the model (how to define the two input)?
Python:
class Deep_unfold_NN(torch.nn.Module ):
def __init__(self,x_size, y_size):
super(Deep_unfold_NN, self).__init__()
self.s1 = torch.nn.Sequential(torch.nn.Linear(x_size, x_size))
self.aux = torch.nn.Sequential(torch.nn.Linear(y_size, x_size) )
def forward(self,x,y,L):
for index in range(L):
x=self.s1(x)+self.aux(y)
return x
Matlab using deepNetworkDesigner ( L in the python code above is 4):
After the model is created, I exported it in Matlab and save the layers as layers1
input={Input_1_train,Input_2_train};
net_deepmimo = trainNetwork(input,Output,layers1,options);
The error information is :
Network: Invalid input layers. If the network has a sequence input layer, then it must not have any other input layers.
How should I build this model in Matlab?
Thank you very much.

Answers (1)

Srivardhan Gadila
Srivardhan Gadila on 23 Aug 2020
As per my knowledge and above information, I think that you can use imageInputLayer instead of sequenceInputLayer. To define and train a deep learning network with multiple inputs, specify the network architecture using a layerGraph object and train using the trainNetwork function by specifying the multiple inputs using a combinedDatastore or transformedDatastore object. Also you have to use the following syntax of trainNetwork
If you are unable to train using trainNetwork then you can create a custom training loop using automatic differentiation. To learn more, see Define Custom Training Loops.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!