This is the fsvd Reference Manual, version 0.0.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 08 18:06:31 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
fsvd
Simon Funk’s quasi SVD
Gabor Melis
MIT
This is a Common Lisp implementation of Simon
Funk’s quasi svd as described at http://sifter.org/~simon/journal/20061211.html
0.0.3
package.lisp
(file).
fsvd.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
fsvd/fsvd.lisp
package.lisp
(file).
fsvd
(system).
approximation-rmse
(function).
dense-column-index
(generic function).
dense-row-index
(generic function).
do-matrix
(macro).
do-matrix-macro-name
(generic function).
height-of
(generic function).
limiting-supervisor
(class).
load-svd
(function).
make-sv
(function).
make-svd
(function).
make-svd-approximator
(function).
map-matrix
(generic function).
max-n-iterations
(reader method).
(setf max-n-iterations)
(writer method).
max-n-svs
(reader method).
(setf max-n-svs)
(writer method).
save-svd
(function).
size-of
(generic function).
supervise-svd
(generic function).
sv
(structure).
sv-left
(reader).
(setf sv-left)
(writer).
sv-right
(reader).
(setf sv-right)
(writer).
svd
(function).
svd
(type).
svd-in-progress
(reader method).
(setf svd-in-progress)
(writer method).
svd-value
(function).
width-of
(generic function).
2d-single-float-array
(type).
add-sv-to-approximation
(macro).
append-to-svd
(function).
approximation-me
(function).
compact-sv
(function).
copy-sv
(function).
create-sv
(function).
declarationp
(function).
do-array-matrix
(macro).
expand-sv
(function).
make-v
(function).
read-float-array
(function).
single-float-vector
(type).
split-body
(function).
sv-p
(function).
svd-1
(function).
sync->fd
(function).
sync<-fd
(function).
trace-stream
(reader method).
(setf trace-stream)
(writer method).
train/epoch
(macro).
write-float
(function).
write-float-array
(function).
Packages are listed by definition order.
fsvd
This is a Common Lisp implementation of Simon
Funk’s quasi svd as described at
http://sifter.org/~simon/journal/20061211.html. There is nothing quasi
about it when there are no missing elements in the original matrix and
the normalization factor is zero, but that requires a small learning
rate. Loss of orthogonality between singular vectors results from
using too large learning rates.
common-lisp
.
approximation-rmse
(function).
dense-column-index
(generic function).
dense-row-index
(generic function).
do-matrix
(macro).
do-matrix-macro-name
(generic function).
height-of
(generic function).
limiting-supervisor
(class).
load-svd
(function).
make-sv
(function).
make-svd
(function).
make-svd-approximator
(function).
map-matrix
(generic function).
max-n-iterations
(generic reader).
(setf max-n-iterations)
(generic writer).
max-n-svs
(generic reader).
(setf max-n-svs)
(generic writer).
save-svd
(function).
size-of
(generic function).
supervise-svd
(generic function).
sv
(structure).
sv-left
(reader).
(setf sv-left)
(writer).
sv-right
(reader).
(setf sv-right)
(writer).
svd
(function).
svd
(type).
svd-in-progress
(generic reader).
(setf svd-in-progress)
(generic writer).
svd-value
(function).
width-of
(generic function).
2d-single-float-array
(type).
add-sv-to-approximation
(macro).
append-to-svd
(function).
approximation-me
(function).
compact-sv
(function).
copy-sv
(function).
create-sv
(function).
declarationp
(function).
do-array-matrix
(macro).
expand-sv
(function).
make-v
(function).
read-float-array
(function).
single-float-vector
(type).
split-body
(function).
sv-p
(function).
svd-1
(function).
sync->fd
(function).
sync<-fd
(function).
trace-stream
(generic reader).
(setf trace-stream)
(generic writer).
train/epoch
(macro).
write-float
(function).
write-float-array
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
A simple, inefficient implementation of the macro interface to iterate over MATRIX.
Return the SVD loaded from FILENAME.
Return a function of (ROW COLUMN) parameters that approximates MATRIX by SVD. The BASE-VALUE for SVD-VALUE is produced by BASE-APPROXIMATOR for the given coordinates, while CLIP is simply passed on. The returned function automatically translates to dense coordinates to query the SVD.
Write the content of SVD to FILENAME in a reasonably compact form.
Approximate the single-float MATRIX with a quasi singular value
decomposition. Each SV of an SVD consists of a left and a right
vector. The sum of the outer products of the left and right vectors of
its consituent SVs is the approximation provided by an SVD. This SVD
is quasi because while the rank of the approximation is N, the
singular values are not explicit.
The sparse matrix interface must be supported on MATRIX.
BASE-APPROXIMATOR is a function of row and column. Its values are
effectively subtracted from those of MATRIX. Don’t forget to supply
the same BASE-APPROXIMATOR to MAKE-SVD-APPROXIMATOR and
SVD-VALUE.
CLIP is a symbol that is fbound to a function that takes a single
single-float and returns it clamped into some valid range or leaves it
alone.
To make training fast, a new trainer function is compiled for each SVD
call using CLIP and DO-MATRIX-MACRO-NAME for MATRIX.
LEARNING-RATE controls the how much weights are drawn towards to
optimum at each step. By default the LEARNING-RATE is scaled by 1/MAE*
where MAE* is the MAE mean avarage error. To avoid normalization and
to have finer grained control one can return learning rate from the
supervisor.
The Tikhonov NORMALIZATION-FACTOR penalizes large weights.
After each iteration on a SV and also before adding a new SV SUPERVISE-SVD is invoked on SUPERVISOR. The return value being NIL indicates that the supervisor wants to stop. See SUPERVISE-SVD for details.
Return the value of the matrix represented by SVD at ROW and COLUMN. Start the summation from BASE-VALUE and CLIP the current sum to some valid range if any after every pass.
Number those columns that are not empty from 0. Return NIL for empty columns.
Number those rows that are not empty from 0. Return NIL for empty rows.
Return the name of the macro that provides a
hopefully efficient way to iterate over MATRIX. See DO-MATRIX for an
example.
Return the number of rows of MATRIX. If DENSEP return the number of non-empty rows.
Call FUNCTION for each non-empty cell of MATRIX.
FUNCTION is of four parameters: ROW, COLUMN, VALUE and DENSE-INDEX
where DENSE-INDEX is akin to a row major index except it doesn’t skip
over empty cells. DENSE-INDEX is always less than the SIZE-OF the
MATRIX.
fsvd
.
limiting-supervisor
)) ¶automatically generated reader method
fsvd
.
limiting-supervisor
)) ¶automatically generated writer method
fsvd
.
limiting-supervisor
)) ¶automatically generated reader method
fsvd
.
limiting-supervisor
)) ¶automatically generated writer method
Return the number known cells in MATRIX. This is an upper limit for the dense indices produced by MAP-MATRIX.
This is invoked from SVD on its SUPERVISOR
argument. If ITERATION is NIL then a new SV is about to be added and
upon rejecting that and returning NIL the decomposition is finished.
When ITERATION is not NIL, it is a non-negative integer that is the
index of the current iteration on the last SV of SVD. MATRIX,
BASE-APPROXIMATOR, CLIP are passed through verbatim from the SVD call.
APPROXIMATION is a single-float vector that parallels MATRIX with
dense indices (see MAP-MATRIX). APPROXIMATION is updated when about to
start on a new SV.
Its second return value is a list conforming to (&KEY LEARNING-RATE SV) that can be used to change the learning rate dynamically and to initialize or change the compact representation of the current SV.
fsvd
.
function
) svd iteration &rest args) ¶symbol
) svd iteration &rest args) ¶limiting-supervisor
) svd iteration &key base-approximator clip matrix approximation) ¶fsvd
.
limiting-supervisor
)) ¶automatically generated reader method
fsvd
.
limiting-supervisor
)) ¶automatically generated writer method
Return the number of columns of MATRIX. If DENSEP return the number of non-empty columns.
SV is a pair of vectors. They are not of unit lenght. The singular value is implicitly defined as the product of their euclidean norms.
Construct an instance, keep it around and while the
SVD is in progress inspect/save SVD-IN-PROGRESS, or set MAX-N-SVS as
you see how the learning is going.
fsvd
.
(fsvd:make-svd)
:max-n-iterations
:max-n-svs
*trace-output*
:trace-stream
Take SV that uses sparse indices of MATRIX and turn it into one that uses dense indices.
Take SV that uses dense indices of MATRIX and turn it into one that uses normal indices.
Return the declarations and the rest of the body as separate lists.
fsvd
.
limiting-supervisor
)) ¶automatically generated reader method
fsvd
.
limiting-supervisor
)) ¶automatically generated writer method
Jump to: | (
A C D E F G H L M R S T W |
---|
Jump to: | (
A C D E F G H L M R S T W |
---|
Jump to: | L M R S T |
---|
Jump to: | L M R S T |
---|
Jump to: | 2
C F L P S T |
---|
Jump to: | 2
C F L P S T |
---|