Inferring networks from time series: a neural approach