I want to make a DNN that it can learn from text feature(1534-dims) and old audio features(256*4(four old frames)-dims) to predict audio feature(256-dims) at current frame.
So it has two inputs,one is text feature(1534-dims),the other is old audio features(1024 dims).And one output is current audio feature(256-dims).
First I want net can learn how to reduce dimensions from 1534-dims to 128-dims,so I define encodeNet
and decodeNet
.
encodeNet = NetChain[{512, Ramp, 128}, "Input" -> 1534(*text feature*)];
decodeNet = NetChain[{512, Ramp, 512, Ramp, 256},
"Input" -> 128(*low rank representation of text feature*)];
Second I want to combine this reduced dimensions 128-dims and old audio features 1024-dims,then use it to predict the current audio features.
net = NetGraph[{encodeNet, decodeNet, CatenateLayer[], 512, Ramp, 512,Ramp, 256},
{NetPort["Input1"] -> 1 -> 2 -> NetPort["Output1"],
NetPort["Input2"] -> 3, 1 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> NetPort["Output2"]},
"Input1" -> 1534, "Input2" -> 256*4, "Output1" -> 256, "Output2" -> 256]
So the data into output1
is same as the data into output2
.
input1 = N@RandomInteger[1, {100, 1534}];
input2 = RandomReal[1, {100, 256*4}];
output = RandomReal[1, {100, 256}];
data = <|"Input1" -> input1, "Input2" -> input2, "Output1" -> output,"Output2" -> output|>;
Then train the net.
net = NetTrain[net, data, MaxTrainingRounds -> 100];
So how does mathematica compute loss with multi-losses? is it loss=loss1+loss2
?
And is there better net than can deal with this problem? I want to use EmbeddingLayer
to replace encodeNet
, but have no idea.
And can it have one ouput port and how to use it?