We propose an optimal control approach in order to identify the nonlinearity in the monodomain model, from given data. This data-driven approach gives an answer to the problem of selecting the model when studying phenomena related to cardiac electrophysiology. Instead of determining coefficients of a prescribed model (like the FitzHugh-Nagumo model for instance) from empirical observations, we design the model itself, in the form of an artificial neural network. The relevance of this approach relies on the capacity approximations of neural networks. We formulate this inverse problem as an optimal control problem, and provide mathematical analysis and derivation of optimality conditions. One of the difficulties comes from the lack of smoothness of activation functions which are classically used for training neural networks. Numerical simulations demonstrate the feasibility of the strategy proposed in this work.