How to train a deep neural network with 2 inputs
68 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
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.
You can refer to the following resources for more information: How can I train multi-input deep network without DataStore, Multi-Input CNN for image classification, Input Arguments & ds of trainNetwork and Multiple-Input and Multiple-Output Networks, Input Datastore for Training, Validation, and Inference
0 Comments
See Also
Categories
Find more on Custom Training Loops 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!