Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rememberYou committed Jun 9, 2021
2 parents 5b75c7d + 9603fa5 commit c40c52b
Show file tree
Hide file tree
Showing 25 changed files with 767 additions and 455 deletions.
16 changes: 13 additions & 3 deletions examples/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from pyrdf2vec import RDF2VecTransformer
from pyrdf2vec.embedders import Word2Vec
from pyrdf2vec.graphs import KG
from pyrdf2vec.walkers import RandomWalker
from pyrdf2vec.samplers import WideSampler
from pyrdf2vec.walkers import HALKWalker

# Ensure the determinism of this script by initializing a pseudo-random number.
RANDOM_STATE = 22
Expand All @@ -32,8 +33,17 @@
Word2Vec(workers=1, epochs=10),
# Extract all walks with a maximum depth of 2 for each entity using two
# processes and use a random state to ensure that the same walks are
# generated for the entities.
walkers=[RandomWalker(2, None, n_jobs=2, random_state=RANDOM_STATE)],
# generated for the entities without hashing as MUTAG is a short KG.
walkers=[
HALKWalker(
2,
None,
n_jobs=2,
sampler=WideSampler(),
random_state=RANDOM_STATE,
md5_bytes=None,
)
],
verbose=1,
).fit_transform(
KG(
Expand Down
11 changes: 8 additions & 3 deletions examples/mutag.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from pyrdf2vec import RDF2VecTransformer
from pyrdf2vec.embedders import Word2Vec
from pyrdf2vec.graphs import KG
from pyrdf2vec.walkers import RandomWalker
from pyrdf2vec.samplers import WideSampler
from pyrdf2vec.walkers import HALKWalker

# Ensure the determinism of this script by initializing a pseudo-random number.
RANDOM_STATE = 22
Expand All @@ -31,8 +32,12 @@
Word2Vec(workers=1, epochs=10),
# Extract all walks with a maximum depth of 2 for each entity using two
# processes and use a random state to ensure that the same walks are
# generated for the entities.
walkers=[RandomWalker(2, None, n_jobs=1, random_state=RANDOM_STATE)],
# generated for the entities without hashing as MUTAG is a short KG.
walkers=[
HALKWalker(
2, None, n_jobs=2, random_state=RANDOM_STATE, md5_bytes=None
)
],
verbose=1,
).fit_transform(
KG(
Expand Down
137 changes: 10 additions & 127 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ scikit-learn = "^0.23.2"
tomlkit = "^0.7.0"
torch = "^1.7.1"
tqdm = "^4.48.2"
transformers = "^4.3.2"

[tool.poetry.dev-dependencies]
black = "^20.8b1"
Expand Down
2 changes: 2 additions & 0 deletions pyrdf2vec/samplers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .uniform import UniformSampler
from .frequency import ObjFreqSampler, ObjPredFreqSampler, PredFreqSampler
from .pagerank import PageRankSampler
from .wide import WideSampler

__all__ = [
"ObjFreqSampler",
Expand All @@ -13,4 +14,5 @@
"PredFreqSampler",
"Sampler",
"UniformSampler",
"WideSampler",
]

0 comments on commit c40c52b

Please sign in to comment.