Building neural networks using layer functions