Package ai.djl.nn.core
Interface AbstractIndexedEmbedding<T>
- Type Parameters:
T
- the type of the item that should be embedded
- All Superinterfaces:
AbstractEmbedding<T>
- All Known Implementing Classes:
ConstantEmbedding
,Embedding
,Embedding.DefaultEmbedding
,Embedding.DefaultItem
,TrainableWordEmbedding
An
AbstractEmbedding
where each embedded item can be assigned an integer index.-
Method Summary
Methods inherited from interface ai.djl.nn.core.AbstractEmbedding
embed, hasItem
-
Method Details
-
encode
Encodes an object of input type into a byte array. This is used in saving and loading theEmbedding
objects.- Parameters:
input
- the input object to be encoded- Returns:
- the encoded byte array.
- Throws:
IOException
- if there is an error while encoding
-
decode
Decodes the given byte array into an object of input parameter type.- Parameters:
byteArray
- the byte array to be decoded- Returns:
- the decode object of input parameter type
- Throws:
IOException
- if there was an error while decoding
-
embed
Embeds an item.- Parameters:
item
- the item to embed- Returns:
- the index of the item in the embedding
-
unembed
Returns the item corresponding to the given index.- Parameters:
index
- the index- Returns:
- the item corresponding to the given index
-