So, I'm trying to make a net to translate a phrase. But I'm uncertain of the use of LinearLayer for a NetEncoder for Characters and getting some error in the training process. Here a toy example of the net with the first error

trainingdata = Dataset[{<|"Linha" -> 1, 
  "portugues" -> 
   "F: Myne resolve os problemas familiares que Lutz enfrentava.", 
  "ingles" -> 
   "F: Main somehow managed to help resolve Lutz's family issues."|>, \
<|"Linha" -> 2, 
  "portugues" -> 
   "F: Contudo, novas preocupações emergem em seu próprio lar.", 
  "ingles" -> 
   "F: However, she starts to have concerns in her own home."|>, \
<|"Linha" -> 3, 
  "portugues" -> 
   "M: Ainda está enjoada, mamãe? Está tudo bem com você?", 
  "ingles" -> 
   "M: Are you still not feeling well, Mom? Are you really okay?"|>, \
<|"Linha" -> 4, "portugues" -> "E: Myne...", 
  "ingles" -> "E: Main..."|>}]

ptenconder = NetEncoder[{"Characters"}];
ptdecoder = NetDecoder[{"Characters"}];

net = NetGraph[{LinearLayer[], LinearLayer[], LinearLayer[], 
   LinearLayer[], CatenateLayer[], 
   LinearLayer[]}, {NetPort["portugues"] -> {1, 2, 3, 4} -> 
     5 -> 6 -> NetPort["ingles"]}, "portugues" -> ptenconder, 
  "ingles" -> ptdecoder]

enter image description here Then

translator = NetTrain[net, trainingdata]

enter image description here

If I change LinearLayer[] to LinearLayer[100] the error changes and I got it:

enter image description here

  • $\begingroup$ Have you tried the tutorials? reference.wolfram.com/language/tutorial/… . They are super easy to follow and cover almost all of Mathematica's deep learning functionality. For your task, see Sequence Learning and NLP. $\endgroup$ – aooiiii May 17 at 10:29
  • $\begingroup$ I have tried, but the documentation isn't much clear about their choices. I've even had a look in the answer for this question mathematica.stackexchange.com/questions/143609/…, but even been more clear than the mathematica documentation wasn't enough for me to undertand how to do it. $\endgroup$ – bruno henrique May 17 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.