KGTripletLoader
¶
KGTripletLoader(
head_index: array,
rel_type: array,
tail_index: array,
batch_size: int = 1,
shuffle: bool = False,
drop_last: bool = False,
)
Iterates over mini-batches of (head_index, rel_type, tail_index)
triplets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
head_index
|
array
|
The head indices, shape |
required |
rel_type
|
array
|
The relation types, shape |
required |
tail_index
|
array
|
The tail indices, shape |
required |
batch_size
|
int
|
Number of triplets per batch. Default: |
1
|
shuffle
|
bool
|
Whether to shuffle the triplets at every epoch (with
|
False
|
drop_last
|
bool
|
Whether to drop the last incomplete batch. Default: |
False
|
Example:
loader = model.loader(
head_index, rel_type, tail_index, batch_size=1000, shuffle=True
)
for head, rel, tail in loader:
...
Source code in mlx_graphs/nn/models/kge.py
from mlx_graphs.nn import KGTripletLoader · mlx_graphs/nn/models/kge.py