SLCWAInstances

class SLCWAInstances(*, mapped_triples: Tensor, num_entities: int | None = None, num_relations: int | None = None, negative_sampler: str | NegativeSampler | type[NegativeSampler] | None = None, negative_sampler_kwargs: Mapping[str, Any] | None = None)[source]

Bases: Instances[tuple[Tensor, Tensor, Tensor | None], SLCWABatch]

Training instances for the sLCWA.

Initialize the sLCWA instances.

Parameters:
  • mapped_triples (MappedTriples) – shape: (num_triples, 3) the ID-based triples, passed to the negative sampler

  • num_entities (int | None) – >0 the number of entities, passed to the negative sampler

  • num_relations (int | None) – >0 the number of relations, passed to the negative sampler

  • negative_sampler (HintOrType[NegativeSampler]) – the negative sampler, or a hint thereof

  • negative_sampler_kwargs (OptionalKwargs) – additional keyword-based arguments passed to the negative sampler

Methods Summary

collate(samples)

Collate samples.

from_triples(mapped_triples, *, ...)

Create instances from mapped triples.

get_collator()

Get a collator.

Methods Documentation

static collate(samples: Iterable[tuple[Tensor, Tensor, Tensor | None]]) SLCWABatch[source]

Collate samples.

Parameters:

samples (Iterable[tuple[Tensor, Tensor, Tensor | None]])

Return type:

SLCWABatch

classmethod from_triples(mapped_triples: Tensor, *, num_entities: int, num_relations: int, **kwargs) Instances[source]

Create instances from mapped triples.

Parameters:
  • mapped_triples (Tensor) – shape: (num_triples, 3) The ID-based triples.

  • num_entities (int) – >0 The number of entities.

  • num_relations (int) – >0 The number of relations.

  • kwargs – additional keyword-based parameters.

Returns:

The instances.

Return type:

Instances

# noqa:DAR202 # noqa:DAR401

get_collator() Callable[[list[tuple[Tensor, Tensor, Tensor | None]]], SLCWABatch] | None[source]

Get a collator.

Return type:

Callable[[list[tuple[Tensor, Tensor, Tensor | None]]], SLCWABatch] | None