Stochastic gradient and stochastic gradient MCMC methods for Bayesian learning and non-convex optimization: centralized and decentralized settings