Skip to contents

deepwk and deepw are the SAME method: truncated uniform random walks fed to skip-gram, Perozzi, Al-Rfou & Skiena (2014). Two module names for one method is exactly the duplicate this campaign is trying not to create, so this function forwards to Deepw rather than repeating it – a second copy would agree with the first at 1e-9 forever and tell nobody anything.

Usage

Deepwk(
  G,
  walk_len = 10,
  dim = 8,
  n_walks = 4,
  window = 3,
  epochs = 1,
  lr = 0.05,
  neg = 2,
  seed = 42
)

Arguments

G

An n x n adjacency matrix.

walk_len

Length of each walk.

dim

Embedding dimension.

n_walks

Walks started from each node.

window

Skip-gram context window.

epochs

Passes over the corpus.

lr

SGD step size.

neg

Negative samples per positive pair.

seed

Seed of the deterministic stream.

Value

Whatever Deepw returns.

References

Perozzi, Al-Rfou & Skiena (2014), DeepWalk, KDD 2014:701-710.

Examples

G <- matrix(c(0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0), 4, 4, byrow = TRUE)
Deepwk(G, dim = 4, walk_len = 5, n_walks = 2)
#> $estimate
#> [1] 0.003179637
#> 
#> $embedding
#>             [,1]        [,2]        [,3]        [,4]
#> [1,]  0.03001782  0.06103993  0.03431656 -0.04528434
#> [2,] -0.12270361 -0.07729287  0.06482800 -0.12935236
#> [3,]  0.01029798 -0.09519040 -0.06580563  0.05562667
#> [4,]  0.03453990 -0.06140595 -0.10860119 -0.10971831
#> 
#> $walks
#> $walks[[1]]
#> [1] 1 4 1 2 1
#> 
#> $walks[[2]]
#> [1] 2 1 4 1 4
#> 
#> $walks[[3]]
#> [1] 3 2 3 2 1
#> 
#> $walks[[4]]
#> [1] 4 3 4 3 2
#> 
#> $walks[[5]]
#> [1] 1 2 1 2 3
#> 
#> $walks[[6]]
#> [1] 2 3 2 3 4
#> 
#> $walks[[7]]
#> [1] 3 2 1 4 3
#> 
#> $walks[[8]]
#> [1] 4 3 4 3 4
#> 
#> 
#> $n_walks_total
#> [1] 8
#> 
#> $degree
#> [1] 2 2 2 2
#> 
#> $n
#> [1] 4
#> 
#> $dim
#> [1] 4
#> 
#> $method
#> [1] "DeepWalk node embeddings"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"