In the study of network synchronization, an outstanding question of both theoretical and practical significance is how to allocate a given set of heterogenous oscillators on a complex network in order for improving the synchronization performance. Whereas methods have been proposed to address this question in literature, the methods are based on accurate models describing the system dynamics, which, however, are normally unavailable in realistic situations. Here we show that this question can be addressed by the model-free technique of feed-forward neural network (FNN) in machine learning. Specifically, we measure the synchronization performance of a number of allocation schemes and use the measured data to train a machine. It is found that the trained machine is able to not only infer the synchronization performance of any new allocation scheme, but also find from a huge amount of candidates the optimal allocation scheme for synchronization.