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

public interface AbstractIndexedEmbedding<T> extends AbstractEmbedding<T>
An AbstractEmbedding where each embedded item can be assigned an integer index.
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(byte[] byteArray)
    Decodes the given byte array into an object of input parameter type.
    long
    embed(T item)
    Embeds an item.
    byte[]
    encode(T input)
    Encodes an object of input type into a byte array.
    unembed(long index)
    Returns the item corresponding to the given index.

    Methods inherited from interface ai.djl.nn.core.AbstractEmbedding

    embed, hasItem
  • Method Details

    • encode

      byte[] encode(T input) throws IOException
      Encodes an object of input type into a byte array. This is used in saving and loading the Embedding objects.
      Parameters:
      input - the input object to be encoded
      Returns:
      the encoded byte array.
      Throws:
      IOException - if there is an error while encoding
    • decode

      T decode(byte[] byteArray) throws IOException
      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

      long embed(T item)
      Embeds an item.
      Parameters:
      item - the item to embed
      Returns:
      the index of the item in the embedding
    • unembed

      Optional<T> unembed(long index)
      Returns the item corresponding to the given index.
      Parameters:
      index - the index
      Returns:
      the item corresponding to the given index