Package ai.djl.nn.core
Class Embedding.DefaultItem
java.lang.Object
ai.djl.nn.core.Embedding.DefaultItem
- All Implemented Interfaces:
AbstractEmbedding<T>,AbstractIndexedEmbedding<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode(byte[] byteArray) Decodes the given byte array into an object of input parameter type.Embeds an array of items.longEmbeds an item.byte[]Encodes an object of input type into a byte array.booleanReturns whether an item is in the embedding.unembed(long index) Returns the item corresponding to the given index.
-
Constructor Details
-
DefaultItem
-
-
Method Details
-
encode
Encodes an object of input type into a byte array. This is used in saving and loading theEmbeddingobjects.- Specified by:
encodein interfaceAbstractIndexedEmbedding<T>- 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.- Specified by:
decodein interfaceAbstractIndexedEmbedding<T>- 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
-
hasItem
Returns whether an item is in the embedding.- Specified by:
hasItemin interfaceAbstractEmbedding<T>- Parameters:
item- the item to test- Returns:
- true if the item is in the embedding
-
embed
Embeds an array of items.- Specified by:
embedin interfaceAbstractEmbedding<T>- Parameters:
manager- the manager for the new embeddingsitems- the items to embed- Returns:
- the embedding
NDArrayof Shape(items.length, embeddingSize)
-
embed
Embeds an item.- Specified by:
embedin interfaceAbstractIndexedEmbedding<T>- Parameters:
item- the item to embed- Returns:
- the index of the item in the embedding
-
unembed
Returns the item corresponding to the given index.- Specified by:
unembedin interfaceAbstractIndexedEmbedding<T>- Parameters:
index- the index- Returns:
- the item corresponding to the given index
-