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.
0 个评论
回答(1 个)
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.
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Custom Training Loops 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!