1mlpack_sparse_coding(1) General Commands Manual mlpack_sparse_coding(1)
2
3
4
6 mlpack_sparse_coding - sparse coding
7
9 mlpack_sparse_coding [-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 n points and d dimensions, 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 D * Z. 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 the
33 dictionary (--atoms, or -k). It is also possible to specify an initial
34 dictionary for the optimization, with the --initial_dictionary (-i)
35 option. An input model may be specified with the --input_model_file
36 (-m) option. There are also other training options available.
37
38 As an example, to build a sparse coding model on the dataset in
39 data.csv using 200 atoms and an l1-regularization parameter of 0.1,
40 saving the model into model.xml, use
41
42 $ sparse_coding -t data.csv -k 200 -l 0.1 -M model.xml
43
44 Then, this model could be used to encode a new matrix, otherdata.csv,
45 and save the output codes to codes.csv:
46
47 $ sparse_coding -m model.xml -T otherdata.csv -c codes.csv
48
50 --atoms (-k) [int]
51 Number of atoms in the dictionary. Default value 0.
52
53 --help (-h)
54 Default help info.
55
56 --info [string]
57 Get help on a specific module or option. Default value ''.
58 --initial_dictionary (-i) [string] Filename for optional initial
59 dictionary. Default value ''. --input_model_file (-m) [string]
60 File containing input sparse coding model. Default value ''.
61
62 --lambda1 (-l) [double]
63 Sparse coding l1-norm regularization parameter. Default value
64 0.
65
66 --lambda2 (-L) [double]
67 Sparse coding l2-norm regularization parameter. Default value
68 0.
69
70 --max_iterations (-n) [int]
71 Maximum number of iterations for sparse coding (0 indicates no
72 limit). Default value 0. --newton_tolerance (-w) [double] Tol‐
73 erance for convergence of Newton method. Default value 1e-06.
74
75 --normalize (-N)
76 If set, the input data matrix will be normalized before coding.
77 --objective_tolerance (-o) [double] Tolerance for convergence of
78 the objective function. Default value 0.01.
79
80 --seed (-s) [int]
81 Random seed. If 0, 'std::time(NULL)' is used. Default value 0.
82 --training_file (-t) [string] Filename of the training data (X).
83 Default value ''.
84
85 --verbose (-v)
86 Display informational messages and the full list of parameters
87 and timers at the end of execution.
88
89 --version (-V)
90 Display the version of mlpack.
91
93 --codes_file (-c) [string]
94 Filename to save the output sparse codes to. Default value ''.
95 --dictionary_file (-d) [string] Filename to save the output dic‐
96 tionary to. Default value ''. --output_model_file (-M)
97 [string] File to save trained sparse coding model to. Default
98 value ''.
99
100 --test_file (-T) [string]
101 File containing data matrix to be encoded by trained model.
102 Default value ''.
103
106 For further information, including relevant papers, citations, and the‐
107 ory, For further information, including relevant papers, citations, and
108 theory, consult the documentation found at http://www.mlpack.org or
109 included with your consult the documentation found at
110 http://www.mlpack.org or included with your DISTRIBUTION OF MLPACK.
111 DISTRIBUTION OF MLPACK.
112
113
114
115 mlpack_sparse_coding(1)