Refactor gradient descent module to support multiple input parameters and be more generic