We propose a novel machine learning application within stochastic portfolio theory (SPT), a descriptive framework for analyzing stock market structure and portfolio behaviour. By using neural networks as portfolio generating functions, we try to solve the inverse problem of SPT: Given an investment objective, is it possible to learn a generating function, which generates the optimal portfolio with the desired investment characteristics? In numerical examples, we show that our machine learning approach can recover the most well-known generating functions of SPT, and apply our method to other examples to regain the desired portfolio.