项目作者: hiroyuki-kasai

项目描述 :
MATLAB library of gradient descent algorithms for sparse modeling: Version 1.0.3
高级语言: Matlab
项目地址: git://github.com/hiroyuki-kasai/SparseGDLibrary.git
创建时间: 2017-04-24T22:47:01Z
项目社区:https://github.com/hiroyuki-kasai/SparseGDLibrary

开源协议:MIT License

下载


SparseGDLibrary : Sparse Gradient Descent Library in MATLAB


Authors: Hiroyuki Kasai

Last page update: Oct. 15, 2018

Latest library version: 1.0.3 (see Release notes for more info)

Introduction

The SparseGDLibrary is a pure-Matlab library of a collection of unconstrained optimization algorithms for sparse modeling.

List of sparse gradient algorithms available in SparseGDLibrary

  • APG (Accelerated gradient descent, i.e., Nesterov AGD)
  • ISTA (Iterative shrinkage-thresholding algorithm)
  • FISTA (Fast iterative shrinkage-thresholding algorithm)
  • CD (Coodinate descent) for Lasso and Elastic Net
  • ADMM (The alternating direction method of multipliers) for Lasso

List of line-search algorithms available in SparseGDLibrary

Supported problems

Folders and files

  1. ./ - Top directory.
  2. ./README.md - This readme file.
  3. ./run_me_first.m - The scipt that you need to run first.
  4. ./demo.m - Demonstration script to check and understand this package easily.
  5. ./demo_lasso_cv.m - Demonstration script for lasso problem with cross validation.
  6. |plotter/ - Contains plotting tools to show convergence results and various plots.
  7. |tool/ - Some auxiliary tools for this project.
  8. |problem/ - Problem definition files to be solved.
  9. |sparse_gd_solver/ - Contains various gradient descent optimization algorithms.
  10. |sparse_gd_test/ - Some helpful test scripts to use this package.

First to do

Run run_me_first for path configurations.

  1. %% First run the setup script
  2. run_me_first;

Usage example 1 (Lasso problem))

Now, just execute demo for demonstration of this package.

  1. %% Execute the demonstration script
  2. demo;

The “demo.m“ file contains below.

  1. % set number of dimensions, cardinality and noise level.
  2. n = 1280;
  3. d = 100;
  4. k = 15;
  5. noise_level = 0.01;
  6. % generate dataset
  7. [A, b, x0, lambda] = generate_lasso_data(n, d, k, noise_level);
  8. % define problem
  9. problem = lasso_problem(A, b, lambda);
  10. % perform algorithms (FISTA and ADMM)
  11. options.w_init = zeros(n,1);
  12. [w_fista, info_fista] = fista(problem, options);
  13. [w_admm, info_admm] = admm_lasso(problem, options);
  14. % plot all
  15. % display iter vs. cost
  16. display_graph('iter','cost', {'FISTA', 'ADMM'}, {w_fista, w_admm}, {info_fista, info_admm});
  17. % display iter vs. l1-norm
  18. display_graph('iter','sol_optimality_gap', {'FISTA', 'ADMM'}, {w_fista, w_admm}, {info_fista, info_admm});
  • Output results




Usage example 1: more plots

The decrease of the l1-norm of the solution according to iterations is illustrated.

  1. display_graph('iter','l1-norm', {'FISTA', 'ADMM'}, {w_fista, w_admm}, {info_fista, info_admm}, 'linear');




The final coefficients in each position of the solution are displayed in comparisn with the ogirinal input sparse signal.

  1. display_graph('coeff_pos','coeff_amp', {'FISTA','ADMM','Original (x0)'}, {w_fista, w_admm, x0}, {w_fista, w_admm, x0}, 'linear', 'line-with-mark', 1);
  • Output results




Usage example 2 (Lasso problem) with cross-validation)

Execute demo_lasso_cv for the lasso problem with cross-validation.

  1. % Execute the demonstration script
  2. demo_lass_cv;

The “demo_lass_cv.m“ file contains below.

  1. function demo_lasso_cv()
  2. % set number of dimensions, cardinality and noise level.
  3. n = 1280;
  4. d = 100;
  5. k = 15;
  6. noise_level = 0.01;
  7. % generate dataset
  8. [A, b, ~, ~, lambda_max] = generate_lasso_data(n, d, k, noise_level);
  9. % set algorithms and solver (e.g., FISTA)
  10. algorithm = {'FISTA'};
  11. % initialize
  12. % define parameters for cross-validation
  13. num_cv = 10;
  14. lambda_unit = lambda_max/num_cv;
  15. lambda_array = 0+lambda_unit:lambda_unit:lambda_max;
  16. % prepare arrays for solutions
  17. W = zeros(n, num_cv);
  18. l1_norm = zeros(num_cv,1);
  19. aprox_err = zeros(num_cv,1);
  20. % set options
  21. options.w_init = zeros(n,1);
  22. % perform cross-validations
  23. for i=1:length(lambda_array)
  24. lambda = lambda_array(i);
  25. problem = lasso_problem(A, b, lambda);
  26. [W(:,i), infos] = fista(problem, options);
  27. l1_norm(i) = infos.reg(end);
  28. aprox_err(i) = infos.cost(end);
  29. end
  30. % plot all
  31. % display l1-norm vs. coefficient
  32. display_graph('l1-norm','coeffs', algorithm, l1_norm, {W}, 'linear');
  33. % display lambda vs. coefficient
  34. display_graph('lambda','coeffs', algorithm, lambda_array, {W}, 'linear');
  35. % display l1-norm vs. approximation error
  36. display_graph('l1-norm','aprox_err', algorithm, l1_norm, {aprox_err}, 'linear');
  37. end
  • Output results




License

The SparseGDLibrary is free and open source for academic/research purposes (non-commercial).

Problems or questions

If you have any problems or questions, please contact the author: Hiroyuki Kasai (email: kasai at is dot uec dot ac dot jp)

Release Notes

  • Version 1.0.3 (Oct. 13, 2018)
    • ISTA solver is added.
  • Version 1.0.2 (July 07, 2017)
    • Robust PCA problem and trace norm convex clustering problem, and those related solvers and test files are added.
  • Version 1.0.1 (April 27, 2017)
    • Group lasso problem is added.
  • Version 1.0.0 (April 24, 2017)
    • Initial version.