Efficient design of real- and complex-valued neural networks