Intrinsic and extrinsic deep learning on manifolds