Learning of Discrete Graphical Models with Neural Networks