Learn R Programming

SSDL

The SSDL package implements the Sketched Stochastic Dictionary Learning (SSDL) algorithm. The goal of this algorithm is to extract a set of the most repetitive patterns (a.k.a dictionary) from a large-scale dataset. SSDL method operates on a compressed data version referred to as a data sketch. The chickn package is used to carry out the data compression. SSDL operates with Filebacked Big Matrices (FBM) of bigstatsr package to store and to access to matrix-like data that cannot be loaded in memory. The package provides the dictionary initialization routines based on the TV norm criterion and on the Compressive Orthogonal Matching Pursuit method.

Installation

You can install the released version of SSDL from Gitlab with:

devtools::install_gitlab(repo = "Olga.Permiakova/ssdl")

Example

This is a basic example which shows how to learn a dictionary using SSDL package:

library(SSDL)
library(chickn)
# Convert data matrix into a Filebacked Big Matrix
X = matrix(abs(rnorm(n = 1000)), ncol = 100, nrow = 10)
X_fbm = bigstatsr::as_FBM(X, backingfile = file.path(tempdir(), 'X_fbm'))$save()
# Compute the data sketch
## Generate frequency matrix
m = 256 # number of the frequency vectors
out_freq = chickn::GenerateFrequencies(Data = X_fbm, m = m, N0 = ncol(X_fbm),
                                       ncores = 1, niter= 5, nblocks = 2, sigma_start = 0.001)
W = out_freq$W # the obtained frequency matrix
## Compute the data sketch
SK= chickn::Sketch(X_fbm, W)
# Initialize a dictionary 
D0 = X_fbm[,sample(ncol(X_fbm),20)]
# Apply SSDL
result = SSDL::CDL(SK_Data = SK, Data = X_fbm, Frequencies = W, K = 20,
                   D =D0, pos.dic = TRUE, maxEpoch = 4, batch_size = 20,
                   lambda = 0, learn_rate = 0.2, alpha = 0.9, gamma = 0.1, ncores = 2,
                   DIR_tmp = tempdir())
# Obtained dictionary                   
D = result$D
#

Copy Link

Version

Install

install.packages('SSDL')

Monthly Downloads

38

Version

1.1

License

GPL (>= 2)

Maintainer

Olga Permiakova

Last Published

March 10th, 2021

Functions in SSDL (1.1)

Gradient_D_cpp_parallel

Gradient_D_cpp_parallel
Gradient_D_cpp

Gradient D
ObjFun_COMP_cpp

COMP objective function
Sparse_prod

Sparse matrix product
TV_initialization

TV norm dictionary initialization
Sparse_prod_row

Sparse product by rows
Sparse_prod_parallel

Sparse matrix product
Rowsums_cpp

Rowsums_cpp
gradient

Supporting function for the gradient computation.
make_copy

function makes copy of the selected signal
step

Additional function for the TV norm initialization procedure.
CDL

Compressive Dictionary Learning
COMP_initialization

COMP dictionary initialization
G_fun_cpp

G_fun_cpp
SSDL

SSDL-package
Gradient_COMP_cpp

COMP Gradient
Rowsums_cpp_parallel

Rowsums_cpp_parallel