1mlpack_sparse_coding(1) User Commands mlpack_sparse_coding(1)
2
3
4
6 mlpack_sparse_coding - sparse coding
7
9 mlpack_sparse_coding [-k int] [-i string] [-m unknown] [-l double] [-L double] [-n int] [-w double] [-N bool] [-o double] [-s int] [-T string] [-t string] [-V bool] [-c string] [-d string] [-M unknown] [-h -v]
10
12 An implementation of Sparse Coding with Dictionary Learning, which
13 achieves sparsity via an l1-norm regularizer on the codes (LASSO) or an
14 (l1+l2)-norm regularizer on the codes (the Elastic Net). Given a dense
15 data matrix X with d dimensions and n points, sparse coding seeks to
16 find a dense dictionary matrix D with k atoms in d dimensions, and a
17 sparse coding matrix Z with n points in k dimensions.
18
19 The original data matrix X can then be reconstructed as Z * D. There‐
20 fore, this program finds a representation of each point in X as a
21 sparse linear combination of atoms in the dictionary D.
22
23 The sparse coding is found with an algorithm which alternates between a
24 dictionary step, which updates the dictionary D, and a sparse coding
25 step, which updates the sparse coding matrix.
26
27 Once a dictionary D is found, the sparse coding model may be used to
28 encode other matrices, and saved for future usage.
29
30 To run this program, either an input matrix or an already-saved sparse
31 coding model must be specified. An input matrix may be specified with
32 the ’--training_file (-t)' option, along with the number of atoms in
33 the dictionary (specified with the '--atoms (-k)' parameter). It is
34 also possible to specify an initial dictionary for the optimization,
35 with the ’--initial_dictionary_file (-i)' parameter. An input model may
36 be specified with the '--input_model_file (-m)' parameter.
37
38 As an example, to build a sparse coding model on the dataset 'data.csv'
39 using 200 atoms and an l1-regularization parameter of 0.1, saving the
40 model into ’model.bin', use
41
42 $ sparse_coding --training_file data.csv --atoms 200 --lambda1 0.1
43 --output_model_file model.bin
44
45 Then, this model could be used to encode a new matrix, 'otherdata.csv',
46 and save the output codes to 'codes.csv':
47
48 $ sparse_coding --input_model_file model.bin --test_file otherdata.csv
49 --codes_file codes.csv
50
52 --atoms (-k) [int]
53 Number of atoms in the dictionary. Default value 15.
54
55 --help (-h) [bool]
56 Default help info.
57
58 --info [string]
59 Get help on a specific module or option. Default value ''.
60
61 --initial_dictionary_file (-i) [string]
62 Optional initial dictionary matrix. Default value ''.
63
64 --input_model_file (-m) [unknown]
65 File containing input sparse coding model. Default value ''.
66
67 --lambda1 (-l) [double]
68 Sparse coding l1-norm regularization parameter. Default value
69 0.
70
71 --lambda2 (-L) [double]
72 Sparse coding l2-norm regularization parameter. Default value
73 0.
74
75 --max_iterations (-n) [int]
76 Maximum number of iterations for sparse coding (0 indicates no
77 limit). Default value 0.
78
79 --newton_tolerance (-w) [double]
80 Tolerance for convergence of Newton method. Default value
81 1e-06.
82
83 --normalize (-N) [bool]
84 If set, the input data matrix will be normalized before coding.
85
86 --objective_tolerance (-o) [double]
87 Tolerance for convergence of the objective function. Default
88 value 0.01.
89
90 --seed (-s) [int]
91 Random seed. If 0, 'std::time(NULL)' is used. Default value 0.
92
93 --test_file (-T) [string]
94 Optional matrix to be encoded by trained model. Default value
95 ''.
96
97 --training_file (-t) [string]
98 Matrix of training data (X). Default value ''.
99
100 --verbose (-v) [bool]
101 Display informational messages and the full list of parameters
102 and timers at the end of execution.
103
104 --version (-V) [bool]
105 Display the version of mlpack.
106
108 --codes_file (-c) [string]
109 Matrix to save the output sparse codes of the test matrix
110 (--test_file) to. Default value ''.
111
112 --dictionary_file (-d) [string]
113 Matrix to save the output dictionary to. Default value ''.
114
115 --output_model_file (-M) [unknown]
116 File to save trained sparse coding model to. Default value ''.
117
119 For further information, including relevant papers, citations, and the‐
120 ory, consult the documentation found at http://www.mlpack.org or
121 included with your distribution of mlpack.
122
123
124
125mlpack-3.0.4 21 February 2019 mlpack_sparse_coding(1)