Commit dd974f0e by Jan Wijffels

working version

parent ab8cc617
^.*\.Rproj$
^\.Rproj\.user$
.Rproj.user
.Rhistory
.RData
.Ruserdata
src/*.o
src/*.so
src/*.dll
Package: deepwalker Package: deepwalker
Type: Package Type: Package
Title: Learn Graph Embeddings with Deep Learning Title: Learn Graph Embeddings
Version: 0.1 Version: 0.1
Maintainer: Jan Wijffels <jwijffels@bnosac.be> Maintainer: Jan Wijffels <jwijffels@bnosac.be>
Authors@R: c(person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = 'jwijffels@bnosac.be'), Authors@R: c(person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = 'jwijffels@bnosac.be'),
...@@ -9,10 +9,11 @@ Authors@R: c(person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = 'j ...@@ -9,10 +9,11 @@ Authors@R: c(person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = 'j
Description: Embeddings on graphs can be use to improve link prediction, node classification and node clustering. Description: Embeddings on graphs can be use to improve link prediction, node classification and node clustering.
The following algorithms which calculate the embedding for nodes in a graph are provided: The following algorithms which calculate the embedding for nodes in a graph are provided:
deepwalker, verse and node2vec. deepwalker, verse and node2vec.
License: MIT License: MIT + file LICENSE
URL: https://github.com/bnosac/deepwalker URL: https://github.com/bnosac/deepwalker
Encoding: UTF-8 Encoding: UTF-8
Depends: R (>= 2.10) Depends: R (>= 2.10)
Suggests: igraph, igraphdata, Matrix
Imports: Rcpp (>= 0.11.5) Imports: Rcpp (>= 0.11.5)
LinkingTo: Rcpp LinkingTo: Rcpp
SystemRequirements: C++11 SystemRequirements: C++11
......
# Generated by roxygen2: do not edit by hand
export(deepwalker_verse)
importFrom(Rcpp,evalCpp)
useDynLib(deepwalker)
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
embeddings_verse <- function(dgrmatrix_p, dgrmatrix_j, n_epochs = 100000L) {
.Call('_deepwalker_embeddings_verse', PACKAGE = 'deepwalker', dgrmatrix_p, dgrmatrix_j, n_epochs)
}
#' @title Versatile Graph Embeddings from Similarity Measures
#' @description This function calculates node embeddings in a graph by using
#' VERSE (Versatile Graph Embeddings from Similarity Measures)
#' @param x an object of class dgRMatrix
#' @return TODO
#' @export
#' @examples
#' library(igraphdata)
#' library(igraph)
#' library(Matrix)
#'
#' data(karate, package = "igraphdata")
#' x <- as_adj(karate)
#' x <- as(x, "RsparseMatrix")
#'
#' embeddings <- deepwalker_verse(x)
deepwalker_verse <- function(x){
emb <- embeddings_verse(x@p, x@j, n_epochs = 10)
emb
}
\ No newline at end of file
#' @importFrom Rcpp evalCpp
#' @useDynLib deepwalker
NULL
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deepwalker_verse.R
\name{deepwalker_verse}
\alias{deepwalker_verse}
\title{Versatile Graph Embeddings from Similarity Measures}
\usage{
deepwalker_verse(x)
}
\arguments{
\item{x}{an object of class dgRMatrix}
}
\value{
TODO
}
\description{
This function calculates node embeddings in a graph by using
VERSE (Versatile Graph Embeddings from Similarity Measures)
}
\examples{
library(igraphdata)
library(igraph)
library(Matrix)
data(karate, package = "igraphdata")
x <- as_adj(karate)
x <- as(x, "RsparseMatrix")
embeddings <- deepwalker_verse(x)
}
...@@ -5,21 +5,22 @@ ...@@ -5,21 +5,22 @@
using namespace Rcpp; using namespace Rcpp;
// deepwalker_verse // embeddings_verse
SEXP deepwalker_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrmatrix_j); SEXP embeddings_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrmatrix_j, int n_epochs);
RcppExport SEXP _deepwalker_deepwalker_verse(SEXP dgrmatrix_pSEXP, SEXP dgrmatrix_jSEXP) { RcppExport SEXP _deepwalker_embeddings_verse(SEXP dgrmatrix_pSEXP, SEXP dgrmatrix_jSEXP, SEXP n_epochsSEXP) {
BEGIN_RCPP BEGIN_RCPP
Rcpp::RObject rcpp_result_gen; Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type dgrmatrix_p(dgrmatrix_pSEXP); Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type dgrmatrix_p(dgrmatrix_pSEXP);
Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type dgrmatrix_j(dgrmatrix_jSEXP); Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type dgrmatrix_j(dgrmatrix_jSEXP);
rcpp_result_gen = Rcpp::wrap(deepwalker_verse(dgrmatrix_p, dgrmatrix_j)); Rcpp::traits::input_parameter< int >::type n_epochs(n_epochsSEXP);
rcpp_result_gen = Rcpp::wrap(embeddings_verse(dgrmatrix_p, dgrmatrix_j, n_epochs));
return rcpp_result_gen; return rcpp_result_gen;
END_RCPP END_RCPP
} }
static const R_CallMethodDef CallEntries[] = { static const R_CallMethodDef CallEntries[] = {
{"_deepwalker_deepwalker_verse", (DL_FUNC) &_deepwalker_deepwalker_verse, 2}, {"_deepwalker_embeddings_verse", (DL_FUNC) &_deepwalker_embeddings_verse, 3},
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
......
...@@ -203,12 +203,13 @@ void Train() { ...@@ -203,12 +203,13 @@ void Train() {
// [[Rcpp::export]] // [[Rcpp::export]]
SEXP deepwalker_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrmatrix_j) { SEXP embeddings_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrmatrix_j,
int n_epochs = 100000) {
step = 0; step = 0;
silent = false; silent = false;
n_threads = 1; n_threads = 1;
global_lr = 0.0025f; global_lr = 0.0025f;
n_epochs = 100000; //n_epochs = ;
n_hidden = 128; n_hidden = 128;
n_samples = 3; n_samples = 3;
ppralpha = 0.85f; ppralpha = 0.85f;
...@@ -269,17 +270,25 @@ SEXP deepwalker_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrma ...@@ -269,17 +270,25 @@ SEXP deepwalker_verse(Rcpp::IntegerVector dgrmatrix_p, Rcpp::IntegerVector dgrma
for (int i = 0; i < (int)(nv+1); i++) for (int i = 0; i < (int)(nv+1); i++)
_offsets[i] = offsets[i]; _offsets[i] = offsets[i];
/*
Rcpp::NumericVector embeddings(nv * n_hidden); Rcpp::NumericVector embeddings(nv * n_hidden);
for (int i = 0; i < (int)(nv * n_hidden); i++){ for (int i = 0; i < (int)(nv * n_hidden); i++){
embeddings[i] = w0[i]; embeddings[i] = w0[i];
} }
*/
Rcpp::NumericMatrix embeddings(nv, n_hidden);
for (int i = 0; i < nv; i++){
for (int j = 0; j < n_hidden; j++){
embeddings(i, j) = w0[i*nv + j];
}
}
// Return // Return
Rcpp::List go = Rcpp::List::create(Rcpp::Named("vertices") = nv, Rcpp::List go = Rcpp::List::create(Rcpp::Named("vertices") = nv,
Rcpp::Named("vertices_embeddings") = embeddings, Rcpp::Named("edges") = ne,
Rcpp::Named("edges_nr") = ne, Rcpp::Named("dimension") = n_hidden,
Rcpp::Named("edges") = _edges, Rcpp::Named("embedding") = embeddings,
Rcpp::Named("offsets") = _offsets Rcpp::Named("edges_data") = _edges,
); Rcpp::Named("offsets_data") = _offsets);
return go; return go;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment