This thesis proposes two algorithms for data generation and density estimation. The algorithms use gradient flow formulation and neural-network-based discretization of the gradient flow. In our first algorithm, we uniquely propose using maximum mean discrepancy(MMD) as an energy functional to measure the dissimilarity between distributions. In our second algorithm, we propose the neural network-based algorithm that uses the second-order backward differentiation formula(BDF2) scheme to discretize in the time dimension. Meanwhile, the importance of understanding and leveraging the underlying geometric structures in datasets has been increasingly recognized. The other topic of this thesis is utilizing intrinsic geometric information to enhance learning. We propose two algorithms to extract intrinsic geometric information from the data. The first algorithm is constructing a graph for points in the dataset and applying the graph neural network to conduct the learning tasks like regression and classification. The second algorithm is manipulating kernels in Gaussian processes and using the properties of the diffusion process to redefine metrics in the dataset and, hence, extract geometric information. Then MCMC method can be applied to obtain the samples of parameters.