Functions to work with VSA memories.

Description

A VSA memory is a collection (list) of VSA vectors, which are usually named. These functions create and modify VSA memories, and compare VSA vectors against the vectors in a memory.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
vsamem(..., labels = NULL, type = c("list", "matrix", "db"), call = match.call(expand.dots = FALSE))
addmem(..., labels = NULL, call = match.call(expand.dots = FALSE))
getmem(mem, i)
delmem(mem, items)
dotmem(mem, x, ..., cos=FALSE)
cosmem(mem, x, ...)
cleanup(mem, x, ..., cos=TRUE, threshold=NA)
bestmatch(mem, x, ..., cos=TRUE, n=1, num=FALSE)
memsize(mem)
memlabels(mem)
conformable(x=NULL, list, stop.on.error=TRUE)

Arguments

...

For vsamem() and addmem(): a collection of conformable VSA vectors (i.e., of same type and length) to be stored in a VSA memory, or VSA memory objects containing such conformable VSA vectors. For other calls, various arguments that can control behavior (e.g., that specify implementation used to find bestmatches, such as GPU code, etc.)

call

The actual dot args, from which labels can be deduced if not otherwise supplied.

mem

A VSA memory object

labels

A character vector containing names of the items to use

type

Type of memory to create

items

A character vector containing names of the items to delete from the memory

i

A character vector or a numeric containing a single name or index of the item to retrive from the memory

x

A VSA vector

list

A list of VSA vectors (can be a VSA memory object)

cos

TRUE or FALSE indicating whether or not to use a cosine similarity measure (which is scaled). The alternative is the unscaled dot-product similarity measure.

threshold

A scalar value

n

An integer

num

TRUE or FALSE. If TRUE, return numeric indices of the vectors in memory. If FALSE return names of the vectors in memory.

stop.on.error

Should the function stop with an error if it finds a problem, or return FALSE

Details

The functions vsamem(), addmem(), and delmem() return the created or modified VSA memory as their value. VSA memories come in two flavors: list and matrix.

Value

The functions vsamem(), addmem(), and delmem() return a vsamem object.

The functions dotmem() and cosmem() return a simval object.

The function cleanup() returns a VSA vector that is the closest match in mem that exceeds the threshold, or if no match exceeds the threshold, returns x.

The function conformable() returns TRUE if x and all objects in list are of the same VSA type and have the same length. Otherwise it return FALSE or stops with an error depending on the value of stop.on.error.

The function bestmatch() returns a numeric containing up to the specified number of best matches. If num=FALSE, the numeric values are the similarity scores, and the names are the names of the objects from the mem. If num=TRUE, the numeric values are indices of the positions of the best matches in mem, and an attribute scores is attached to it.

Author(s)

Tony Plate tplate@acm.org

See Also

vsa

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
options(vsatype="realhrr")
options(vsanorm=TRUE)
options(vsalen=1024)
set.seed(0)

circle <- newVec()
square <- newVec()
triangle <- newVec()
star <- newVec()
small <- newVec()
large <- newVec()

large_circle <- addnorm(circle, large)
large_square <- addnorm(square, large)
large_triangle <- addnorm(triangle, large)
large_star <- addnorm(star, large)
small_circle <- addnorm(circle, small)
small_square <- addnorm(square, small)
small_triangle <- addnorm(triangle, small)
small_star <- addnorm(star, small)

sizeMem <- vsamem(small, large)
shapeMem <- vsamem(circle, square, triangle, star, large_circle, large_square, large_triangle,
large_star, small_circle, small_square, small_triangle, small_star)
bestmatch(shapeMem, large_circle, n=3)
bestmatch(sizeMem, large_circle, n=3)

allMem <- addmem(sizeMem, shapeMem)
bestmatch(allMem, large_circle, n=3)