pub struct KnowledgeGraphEmbedding { /* private fields */ }Expand description
Knowledge Graph Embedding layer
Implementations§
Source§impl KnowledgeGraphEmbedding
impl KnowledgeGraphEmbedding
Sourcepub fn new(
entity_types: Vec<NodeType>,
relation_types: Vec<String>,
num_entities: HashMap<NodeType, usize>,
embedding_dim: usize,
) -> Result<Self, TorshError>
pub fn new( entity_types: Vec<NodeType>, relation_types: Vec<String>, num_entities: HashMap<NodeType, usize>, embedding_dim: usize, ) -> Result<Self, TorshError>
Create new knowledge graph embeddings
Sourcepub fn get_entity_embedding(
&self,
entity_type: &NodeType,
entity_id: usize,
) -> Result<Option<Tensor>, TorshError>
pub fn get_entity_embedding( &self, entity_type: &NodeType, entity_id: usize, ) -> Result<Option<Tensor>, TorshError>
Get entity embedding
Sourcepub fn triple_score(
&self,
head_type: &NodeType,
head_id: usize,
relation: &String,
tail_type: &NodeType,
tail_id: usize,
) -> Result<Option<f64>, TorshError>
pub fn triple_score( &self, head_type: &NodeType, head_id: usize, relation: &String, tail_type: &NodeType, tail_id: usize, ) -> Result<Option<f64>, TorshError>
Compute triple score (head, relation, tail)
Sourcepub fn parameters(&self) -> Vec<Tensor>
pub fn parameters(&self) -> Vec<Tensor>
Get all parameters
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KnowledgeGraphEmbedding
impl RefUnwindSafe for KnowledgeGraphEmbedding
impl Send for KnowledgeGraphEmbedding
impl Sync for KnowledgeGraphEmbedding
impl Unpin for KnowledgeGraphEmbedding
impl UnsafeUnpin for KnowledgeGraphEmbedding
impl UnwindSafe for KnowledgeGraphEmbedding
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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