pub struct RotatEScoring {
pub entity_re: Array2<f64>,
pub entity_im: Array2<f64>,
pub relation_phase: Array2<f64>,
pub n_entities: usize,
pub n_relations: usize,
pub dim: usize,
}Expand description
RotatE scoring model (Sun et al. 2019).
Entity embeddings are complex-valued: each entity e has a real part
entity_re[e] and an imaginary part entity_im[e], both of shape
(n_entities, dim/2) (so the full complex embedding has dim real
parameters per entity).
Relation embeddings are phase angles θ_r ∈ (−π, π] of shape
(n_relations, dim/2). The unit-modulus rotation vector is
r_e = cos(θ_r) + i sin(θ_r).
Score function (negated L2 in complex space):
score(h, r, t) = − ‖ h_re ⊙ cos(θ_r) − h_im ⊙ sin(θ_r) − t_re
+ i ( h_re ⊙ sin(θ_r) + h_im ⊙ cos(θ_r) − t_im ) ‖Higher scores (less negative) imply a more plausible triple.
Fields§
§entity_re: Array2<f64>Real part of entity embeddings (n_entities, dim).
entity_im: Array2<f64>Imaginary part of entity embeddings (n_entities, dim).
relation_phase: Array2<f64>Relation phase angles (n_relations, dim).
n_entities: usizeNumber of entities.
n_relations: usizeNumber of relation types.
dim: usizeHalf-embedding dimension (complex degree of freedom per entity/relation).
Implementations§
Source§impl RotatEScoring
impl RotatEScoring
Sourcepub fn new(n_entities: usize, n_relations: usize, dim: usize) -> Self
pub fn new(n_entities: usize, n_relations: usize, dim: usize) -> Self
Create a new RotatE model with random initialisation.
Entity embeddings are Xavier-initialised; relation phases are uniform
in (−π, π].
§Arguments
n_entities– Number of distinct entities.n_relations– Number of distinct relation types.dim– Complex embedding half-dimension (full parameter count per entity is2 * dim).
Trait Implementations§
Source§impl Clone for RotatEScoring
impl Clone for RotatEScoring
Source§fn clone(&self) -> RotatEScoring
fn clone(&self) -> RotatEScoring
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RotatEScoring
impl Debug for RotatEScoring
Auto Trait Implementations§
impl Freeze for RotatEScoring
impl RefUnwindSafe for RotatEScoring
impl Send for RotatEScoring
impl Sync for RotatEScoring
impl Unpin for RotatEScoring
impl UnsafeUnpin for RotatEScoring
impl UnwindSafe for RotatEScoring
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more