1
$\begingroup$

How can I create a NetChain with UnitVectorLayer inside? In this way I receive this error:

NetChain[{LinearLayer[1, "Input" -> 5], UnitVectorLayer[8, "Input" -> 1]}]

NetChain::ninctyp2: Incompatible types for output of layer 1, LinearLayer[{1},...], and input to layer 2, UnitVectorLayer[8,...]; a length-1 vector is not compatible with a length-1 vector of integers between 1 and 8, respectively.

Or

NetChain [{LinearLayer[1, "Input" -> 5], ThreadingLayer[LogisticSigmoid[#] + 1 &], ThreadingLayer[Round[#] &], UnitVectorLayer[2, "Input" -> 1]}]

NetChain::tyfail2: Inferred inconsistent shapes for output of third layer (a length-1 vector of integers between 1 and 2 versus a vector).

Or

NetChain [{LinearLayer[1, "Input" -> 5], ThreadingLayer[LogisticSigmoid[#] + 1 &], ThreadingLayer[IntegerPart[#] &], UnitVectorLayer[2, "Input" -> 1]}]

ThreadingLayer::invscf: IntegerPart[#1]& could not be symbolically evaluated as a binary scalar function.

$\endgroup$

migrated from mathematica.meta.stackexchange.com Nov 9 '18 at 12:38

This question came from our discussion, support, and feature requests site for users of Wolfram Mathematica.

  • $\begingroup$ UnitVectorLayer works on a integers which LinearLayer returns reals. This seems like the crux of the issue... $\endgroup$ – Carl Lange Nov 9 '18 at 13:31
  • $\begingroup$ Solutions as NetChain [{LinearLayer[1, "Input" -> 5], ThreadingLayer[LogisticSigmoid[#] + 1 &], ThreadingLayer[Chop[#] &], UnitVectorLayer[2, "Input" -> 1]}] give errors like: NetChain::tyfail2: Inferred inconsistent shapes for output of third layer (a length-1 vector of integers between 1 and 2 versus a vector). $\endgroup$ – tonegas Nov 12 '18 at 8:18

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.