Skip to content

Commit

Permalink
fix command line interface of visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
KiddoZhu committed Aug 19, 2019
1 parent 8f7680c commit becf2fe
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# cmake
/Makefile
/src/Makefile
/cmake-build-*/

# JetBrains
/.idea
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Requirements

Generally, GraphVite works on any Linux distribution with CUDA >= 9.2.

The library is compatible with Python 2.7 and 3.5/3.6/3.7.
The library is compatible with Python 2.7 and 3.6/3.7.

Installation
------------
Expand All @@ -88,14 +88,16 @@ Installation
GraphVite can be installed through conda with only one line.

```bash
conda install -c milagraph graphvite
conda install -c milagraph graphvite cudatoolkit=x.x
```

where `x.x` is your CUDA version, e.g. 9.2 or 10.0.

If you only need embedding training without evaluation, you can use the following
alternative with minimal dependencies.

```bash
conda install -c milagraph graphvite-mini
conda install -c milagraph graphvite-mini cudatoolkit=x.x
```

### From Source ###
Expand Down
1 change: 0 additions & 1 deletion conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cxx_compiler_version:

python:
- 2.7
- 3.5
- 3.6
- 3.7

Expand Down
12 changes: 8 additions & 4 deletions conda/graphvite-mini/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source:
requirements:
build:
# cmake
- cmake
- cmake >=3.12
- {{ compiler("cxx") }}
- glog
- gflags
Expand All @@ -22,9 +22,9 @@ requirements:
- cudatoolkit {{ cudatoolkit }}
- python {{ python }}
- pybind11
- numpy {{ numpy }}
- mkl >=2018
# setup
- numpy >=1.11
- pyyaml
- easydict
- six
Expand All @@ -41,12 +41,16 @@ requirements:
- future

build:
string: py{{ python|replace(".", "") }}cuda{{ cudatoolkit|replace(".", "") }}
string:
"py{{ python|replace('.', '') }}\
cuda{{ cudatoolkit|replace('.', '') }}\
h{{ environ.get('GIT_FULL_HASH')|string|truncate(7, True, '', 0) }}"

test:
imports:
- graphvite

about:
home: https://graphvite.io
license: Apache-2.0
license: Apache-2.0
summary: "A general and high-performance graph embedding system for various applications"
12 changes: 8 additions & 4 deletions conda/graphvite/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source:
requirements:
build:
# cmake
- cmake
- cmake >=3.12
- {{ compiler("cxx") }}
- glog
- gflags
Expand All @@ -22,9 +22,9 @@ requirements:
- cudatoolkit {{ cudatoolkit }}
- python {{ python }}
- pybind11
- numpy {{ numpy }}
- mkl >=2018
# setup
- numpy >=1.11
- pyyaml
- easydict
- six
Expand All @@ -47,12 +47,16 @@ requirements:
- nltk

build:
string: py{{ python|replace(".", "") }}cuda{{ cudatoolkit|replace(".", "") }}
string:
"py{{ python|replace('.', '') }}\
cuda{{ cudatoolkit|replace('.', '') }}\
h{{ environ.get('GIT_FULL_HASH')|string|truncate(7, True, '', 0) }}"

test:
imports:
- graphvite

about:
home: https://graphvite.io
license: Apache-2.0
license: Apache-2.0
summary: "A general and high-performance graph embedding system for various applications"
6 changes: 4 additions & 2 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ You can install GraphVite from ``conda`` with only one line.

.. code-block:: bash
conda install -c milagraph graphvite
conda install -c milagraph graphvite cudatoolkit=x.x
where ``x.x`` is your CUDA version, e.g. 9.2 or 10.0.

By default, this will install all dependencies, including ``PyTorch`` and
``matplotlib``. If you only need embedding training without evaluation, you can take
the following alternative with minimum dependencies.

.. code-block:: bash
conda install -c milagraph graphvite-mini
conda install -c milagraph graphvite-mini cudatoolkit=x.x
Install from source
-------------------
Expand Down
2 changes: 1 addition & 1 deletion include/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class pyKnowledgeGraphSolver : public py::class_<graphvite::KnowledgeGraphSolver
py::arg("model") = "RotatE", py::arg("num_epoch") = 2000, py::arg("resume") = false, py::arg("margin") = 24,
py::arg("l3_regularization") = 2e-3, py::arg("sample_batch_size") = 2000, py::arg("positive_reuse") = 1,
py::arg("adversarial_temperature") = 2, py::arg("log_frequency") = 100,
"train(model='RotatE', num_epoch=2000, resume=False, margin=24, l3_regulariation=2e-3, "
"train(model='RotatE', num_epoch=2000, resume=False, margin=24, l3_regularization=2e-3, "
"sample_batch_size=2000, positive_reuse=1, adversarial_temperature=2, log_frequency=100)"
R"(
Train knowledge graph embeddings.
Expand Down
2 changes: 1 addition & 1 deletion include/core/optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Optimizer {
template<class Float>
__device__ inline Float rmsprop_update(Float parameter, Float gradient, Float &moment1, Float weight = 1) const {
Float regularized = weight * (gradient + weight_decay * parameter);
moment1 = alpha * moment1 + (1 - momentum) * regularized * regularized;
moment1 = alpha * moment1 + (1 - alpha) * regularized * regularized;
return lr * regularized / sqrt(moment1 + epsilon);
}

Expand Down
7 changes: 6 additions & 1 deletion python/graphvite/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

logger = logging.getLogger(__name__)


class ApplicationMixin(object):
"""
General interface of graph applications.
Expand Down Expand Up @@ -149,10 +150,14 @@ def gpu_map(self, func, settings):
for i, setting in enumerate(settings):
new_settings.append(setting + (gpus[i % len(gpus)],))
settings = new_settings

try:
multiprocessing.set_start_method("spawn")
start_method = multiprocessing.get_start_method()
# if there are other running processes, this could cause leakage of semaphores
multiprocessing.set_start_method("spawn", force=True)
pool = multiprocessing.Pool(len(gpus))
results = pool.map(func, settings, chunksize=1)
multiprocessing.set_start_method(start_method, force=True)
except AttributeError:
logger.info("Spawn mode is not supported by multiprocessing. Switch to serial execution.")
results = list(map(func, settings))
Expand Down
1 change: 1 addition & 0 deletions python/graphvite/application/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import torch
from torch import nn


class NodeClassifier(nn.Module):
"""
Node classification network for graphs
Expand Down
2 changes: 1 addition & 1 deletion python/graphvite/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def load_data(file_name):
gv.init_logging(logging.WARNING)

app = gap.VisualizationApplication(args.dim, [0])
app.load(vectors, perplexity=args.perplexity)
app.load(vectors=vectors, perplexity=args.perplexity)
app.build()
app.train()
app.visualization(Y=labels, save_file=args.save)
Expand Down
1 change: 1 addition & 0 deletions python/graphvite/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

logger = logging.getLogger(__name__)


class Dataset(object):
"""
Graph dataset.
Expand Down
1 change: 1 addition & 0 deletions python/graphvite/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from . import lib
lib.name2dtype = {n: t for t, n in lib.dtype2name.items()}


def signature(name, *args):
strings = [name]
for arg in args:
Expand Down
1 change: 1 addition & 0 deletions python/graphvite/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

module = sys.modules[__name__]


class Optimizer(object):
"""
Optimizer(type=auto, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions python/graphvite/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

logger = logging.getLogger(__name__)


def recursive_default(obj, default):
if isinstance(default, dict):
new_obj = {}
Expand Down Expand Up @@ -121,4 +122,5 @@ def wrapper(*args, **kwargs):

return wrapper


monitor = Monitor()

0 comments on commit becf2fe

Please sign in to comment.