From 204e7efe516a51b7e149b5c59aa57d99889ddcc7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 5 Aug 2019 06:16:02 +0000 Subject: [PATCH 1/3] Serialization fixed in build_deepwalk_corpus_iter() --- deepwalk/walks.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/deepwalk/walks.py b/deepwalk/walks.py index 3da9023..6244c91 100644 --- a/deepwalk/walks.py +++ b/deepwalk/walks.py @@ -1,3 +1,4 @@ +from __future__ import print_function, division import logging from io import open from os import path @@ -55,7 +56,7 @@ def _write_walks_to_disk(args): with open(f, 'w') as fout: for walk in graph.build_deepwalk_corpus_iter(G=G, num_paths=num_paths, path_length=path_length, alpha=alpha, rand=rand): - fout.write(u"{}\n".format(u" ".join(v for v in walk))) + print(" ".join(str(v) for v in walk), file=fout) logger.debug("Generated new file {}, it took {} seconds".format(f, time() - t_0)) return f @@ -82,8 +83,13 @@ def write_walks_to_disk(G, filebase, num_paths, path_length, alpha=0, rand=rando files.append(file_) with ProcessPoolExecutor(max_workers=num_workers) as executor: - for file_ in executor.map(_write_walks_to_disk, args_list): - files.append(file_) + file_ = None + try: + for file_ in executor.map(_write_walks_to_disk, args_list): + files.append(file_) + except TypeError as err: + logger.error('ERROR: {}, file_: {}, args_list: {}'.format(err, file_, args_list)) + raise return files From 3ba9e359c5f98b9bbc7d377fb173a9ba3d3a3612 Mon Sep 17 00:00:00 2001 From: Artem V L Date: Fri, 9 Aug 2019 16:10:23 +0200 Subject: [PATCH 2/3] Description of the fork objectives added --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index cf11fb7..4e3dbcb 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,8 @@ DeepWalk DeepWalk uses short random walks to learn representations for vertices in graphs. + This implementation extends the original `DeepWalk `_ v.1.0.3 with numerical walk items besides the ``str``, which is required by `HARP (AAAI 2018) `_ and overall provides efficient graph node embedding, where the nodes are specified by numerical ids. + Usage ----- From c490ed9eaefe41dfbb34f861a8d8201e34245103 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 29 Aug 2019 08:42:38 +0000 Subject: [PATCH 3/3] Batch execution script added --- run.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..f38b9f6 --- /dev/null +++ b/run.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# \description Execution on multiple networks +# +# \author Artem V L https://exascale.info + +DIMS=128 +NETS="blogcatalog dblp homo wiki youtube" +WORKERS=8 +RESTRACER=./exectime # time +LOGDIR=embeds/logs +mkdir -p $LOGDIR + +USAGE="$0 -h | [-d =${DIMS}] [-w =${WORKERS}] + -d,--dims - required number of dimensions in the embedding model + -w,--workers - maximal number of workers (parallel thread). Note: deepwalk training can be failed on non-small datasets with small number of workers + -h,--help - help, show this usage description + + Examples: + \$ $0 -d 128 -w 4 +" + +while [ $1 ]; do + case $1 in + -h|--help) + # Use defaults for the remained parameters + echo -e $USAGE # -e to interpret '\n\ + exit 0 + ;; + -d|--dims) + if [ "${2::1}" == "-" ]; then + echo "ERROR, invalid argument value of $1: $2" + exit 1 + fi + DIMS=$2 + echo "Set $1: $2" + shift 2 + ;; + -w|--workers) + if [ "${2::1}" == "-" ]; then + echo "ERROR, invalid argument value of $1: $2" + exit 1 + fi + WORKERS=$2 + echo "Set $1: $2" + shift 2 + ;; + *) + printf "Error: Invalid option specified: $1 $2 ...\n\n$USAGE" + exit 1 + ;; + esac +done + +for NET in $NETS; do + $RESTRACER python3 -m deepwalk --format mat --input graphs/${NET}.mat --number-walks 80 --representation-size ${DIMS} --walk-length 40 --window-size 10 --workers $WORKERS --output embeds/embs_${NET}_${DIMS}-n80-l40-s10.w2v > "$LOGDIR/${NET}_${DIMS}-n80-l40-s10.log" 2> "$LOGDIR/${NET}_${DIMS}-n80-l40-s10.err" # & +done +# python3 -m deepwalk --format mat --input example_graphs/blogcatalog.mat --number-walks 80 --representation-size 128 --walk-length 40 --window-size 10 --workers 1 --output example_graphs/blogcatalog.w2v