pub struct DistMult {
pub entity_embeddings: Vec<Vec<f64>>,
pub relation_embeddings: Vec<Vec<f64>>,
pub dim: usize,
}Expand description
DistMult knowledge graph embedding model.
Score: Σ_k h_k · r_k · t_k (element-wise bilinear product).
Fields§
§entity_embeddings: Vec<Vec<f64>>Entity embedding table [n_entities, dim]
relation_embeddings: Vec<Vec<f64>>Relation (diagonal) embedding table [n_relations, dim]
dim: usizeEmbedding dimension
Implementations§
Source§impl DistMult
impl DistMult
Sourcepub fn new(n_entities: usize, n_relations: usize, dim: usize) -> Result<Self>
pub fn new(n_entities: usize, n_relations: usize, dim: usize) -> Result<Self>
Create a DistMult model with random initialisation.
Sourcepub fn score(&self, h: usize, r: usize, t: usize) -> Result<f64>
pub fn score(&self, h: usize, r: usize, t: usize) -> Result<f64>
Score triple (h, r, t): Σ h_k r_k t_k.
Sourcepub fn link_prediction_score(&self, h: usize, r: usize, t: usize) -> Result<f64>
pub fn link_prediction_score(&self, h: usize, r: usize, t: usize) -> Result<f64>
Link prediction score.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DistMult
impl RefUnwindSafe for DistMult
impl Send for DistMult
impl Sync for DistMult
impl Unpin for DistMult
impl UnsafeUnpin for DistMult
impl UnwindSafe for DistMult
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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