Skip to content

Commit

Permalink
fix some doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
KiddoZhu committed Sep 17, 2019
1 parent 7bf1532 commit e45d0a0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
39 changes: 23 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
if (WIN32)
cmake_minimum_required(VERSION 3.8)
if (WIN32 OR APPLE)
set(SKIP_TOOLCHAIN TRUE)
endif()

if (SKIP_TOOLCHAIN)
# skip toolchain so that code insight can work properly
cmake_minimum_required(VERSION 3.0)
project(graphvite LANGUAGES CXX)
else ()
cmake_minimum_required(VERSION 3.12)
project(graphvite LANGUAGES CXX CUDA)
endif ()
include_directories(include)
add_subdirectory(src)
return()
endif()

cmake_minimum_required(VERSION 3.12)
project(graphvite LANGUAGES CXX CUDA)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(FindCUDA)

if (WIN32)
find_package(Glog)
find_package(GFlags)
else ()
find_package(Glog)
find_package(GFlags)
find_package(PythonLibsNew REQUIRED)
find_package(pybind11 REQUIRED)
endif ()
find_package(Glog)
find_package(GFlags)
find_package(PythonLibsNew REQUIRED)
find_package(pybind11 REQUIRED)

# CUDA_ROOT & CUDA_ARCH
get_filename_component(CUDA_ROOT ${CMAKE_CUDA_COMPILER} DIRECTORY)
get_filename_component(CUDA_ROOT ${CUDA_ROOT} DIRECTORY)
if (NOT ALL_ARCH)
cuda_select_nvcc_arch_flags(CUDA_ARCH Auto)
else()
cuda_select_nvcc_arch_flags(CUDA_ARCH 5.2 6.0 7.0)
cuda_select_nvcc_arch_flags(CUDA_ARCH 3.5 5.0 6.0 7.0)
endif()
string(REPLACE ";" " " CUDA_ARCH "${CUDA_ARCH}")

Expand Down Expand Up @@ -57,7 +60,9 @@ if (NOT GLOG_FOUND)
include_directories(${PROJECT_BINARY_DIR}/glog/include)
link_directories(${PROJECT_BINARY_DIR}/glog/.libs)
else()
get_filename_component(GLOG_LIBRARY_DIR ${GLOG_LIBRARY} DIRECTORY)
include_directories(${GLOG_INCLUDE_DIR})
link_directories(${GLOG_LIBRARY_DIR})
endif ()

# gflags
Expand All @@ -77,7 +82,9 @@ if (NOT GFLAGS_FOUND)
include_directories(${PROJECT_BINARY_DIR}/gflags/include)
link_directories(${PROJECT_BINARY_DIR}/gflags/lib)
else()
get_filename_component(GFLAGS_LIBRARY_DIR ${GFLAGS_LIBRARY} DIRECTORY)
include_directories(${GFLAGS_INCLUDE_DIR})
link_directories(${GFLAGS_LIBRARY_DIR})
endif()

# faiss
Expand Down
2 changes: 1 addition & 1 deletion config/word_graph/line_wikipedia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:
type: SGD
lr: 0.025
weight_decay: 0.005
num_partition: 0
num_partition: auto
num_negative: 1
batch_size: 100000
episode_size: 1000
Expand Down
8 changes: 4 additions & 4 deletions include/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class pyKNNGraph : public py::class_<graphvite::KNNGraph<Index>, graphvite::Grap
vectors (2D array_like): vector list
num_neighbor (int, optional): number of neighbors for each node
perplexity (int, optional): perplexity for the neighborhood of each node
normalization (bool, optional): normalize the input vectors or not
vector_normalization (bool, optional): normalize the input vectors or not
delimiters (str, optional): string of delimiter characters
comment (str, optional): prefix of comment strings
)");
Expand Down Expand Up @@ -563,10 +563,10 @@ class pyKnowledgeGraphSolver : public py::class_<graphvite::KnowledgeGraphSolver
)");

def("train", &KnowledgeGraphSolver::train, py::no_gil(),
py::arg("model") = "RotatE", py::arg("num_epoch") = 2000, py::arg("resume") = false, py::arg("margin") = 24,
py::arg("model") = "RotatE", py::arg("num_epoch") = 2000, py::arg("resume") = false, py::arg("margin") = 12,
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_regularization=2e-3, "
"train(model='RotatE', num_epoch=2000, resume=False, margin=12, l3_regularization=2e-3, "
"sample_batch_size=2000, positive_reuse=1, adversarial_temperature=2, log_frequency=100)"
R"(
Train knowledge graph embeddings.
Expand Down Expand Up @@ -681,7 +681,7 @@ class pyVisualizationSolver : public py::class_<graphvite::VisualizationSolver<d
resume (bool, optional): resume training from learned embeddings or not
sample_batch_size (int, optional): batch size of samples in samplers
positive_reuse (int, optional): times of reusing positive samples
negative_sample_epoxnent (float, optional): exponent of degrees in negative sampling
negative_sample_exponent (float, optional): exponent of degrees in negative sampling
negative_weight (float, optional): weight for each negative sample
log_frequency (int, optional): log every log_frequency batches
)");
Expand Down
8 changes: 4 additions & 4 deletions python/graphvite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

from . import util

package_path = os.path.dirname(os.path.realpath(__file__))
package_path = os.path.dirname(__file__)
candidate_paths = [
os.path.join(package_path, "lib"),
os.path.join(package_path, "../../lib"),
os.path.join(package_path, "../../build/lib")
os.path.realpath(os.path.join(package_path, "lib")),
os.path.realpath(os.path.join(package_path, "../../lib")),
os.path.realpath(os.path.join(package_path, "../../build/lib"))
]
lib_file = imp.find_module("libgraphvite", candidate_paths)[1]
lib_path = os.path.dirname(lib_file)
Expand Down
1 change: 0 additions & 1 deletion python/graphvite/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def baseline_main(args):
file = os.path.join(path, file)
match = True
for keyword in args.keywords:
# print("(^|_)%s(_|$)" % keyword)
result = re.search("[/\_.]%s[/\_.]" % keyword, file)
if not result:
match = False
Expand Down

0 comments on commit e45d0a0

Please sign in to comment.