How to train a deep neural network with 2 inputs

63 次查看(过去 30 天)
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.

回答(1 个)

Srivardhan Gadila
Srivardhan Gadila 2020-8-23
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.

类别

Help CenterFile Exchange 中查找有关 Custom Training Loops 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by