I am attempting to Round up the output Vector of a Neural Network layer to prepare it for the next layer Ex. Layer output {.1.,2.2,3.3} and I need it to be a Vector of Integers for the next layer.

I have tried this, Round@@LinearLayer[3]. But it does not work.

Any suggestions would be appreciated.

Thank You



1 Answer 1


ElementwiseLayer[Ceiling] rounds up, ElementwiseLayer[Round] rounds to the nearest integer. This layer also accepts arbitrary compositions of a subset of Mathematica functions (see documentation for more details).

  • $\begingroup$ Hello, When I run this: a = ElementwiseLayer[Round] a[{1.3, 4.6}] MMA12 still gives reals {2., 5.} Am I missing some setting? $\endgroup$ Jan 7, 2020 at 12:48
  • $\begingroup$ It's just how Mathematica's nerual functionality works internally: almost everything is floating point. For example, OrderingLayer should in theory return integers, just like Ordering does, but in fact its output is floating point. This is usually not a problem for further layers, though. $\endgroup$
    – aooiiii
    Jan 7, 2020 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.