Class Embedding.BaseBuilder<T,​B extends Embedding.BaseBuilder<T,​B>>

  • Type Parameters:
    T - the type of object to embed
    Direct Known Subclasses:
    TrainableWordEmbedding.Builder
    Enclosing class:
    Embedding<T>

    public abstract static class Embedding.BaseBuilder<T,​B extends Embedding.BaseBuilder<T,​B>>
    extends java.lang.Object
    The Builder to construct a Embedding type of Block.
    • Field Detail

      • embeddingType

        protected java.lang.Class<T> embeddingType
      • numEmbeddings

        protected int numEmbeddings
      • embeddingSize

        protected int embeddingSize
      • useDefault

        protected boolean useDefault
      • defaultItem

        protected T defaultItem
    • Constructor Detail

      • BaseBuilder

        protected BaseBuilder()
    • Method Detail

      • getEmbeddingType

        public java.lang.Class<T> getEmbeddingType()
        Returns the embedded type.
        Returns:
        the embedded type
      • setType

        protected abstract B setType​(java.lang.Class<T> embeddingType)
        Creates a new Embedding.BaseBuilder with the specified embedding type.
        Parameters:
        embeddingType - the embedding class
        Returns:
        a new Embedding.BaseBuilder class with the specified embedding type
      • setEmbeddingSize

        public B setEmbeddingSize​(int embeddingSize)
        Sets the size of the embeddings.
        Parameters:
        embeddingSize - the size of the 1D embedding array
        Returns:
        this Builder
      • optNumEmbeddings

        public B optNumEmbeddings​(int numEmbeddings)
        Sets the size of the dictionary of embeddings.
        Parameters:
        numEmbeddings - the size of the dictionary of embeddings
        Returns:
        this Builder
      • optUseDefault

        public B optUseDefault​(boolean useDefault)
        Sets whether to use a default embedding for undefined items (default true).
        Parameters:
        useDefault - true to provide a default embedding and false to throw an IllegalArgumentException when the item can not be found
        Returns:
        this Builder
      • optDefaultItem

        public B optDefaultItem​(T defaultItem)
        Sets whether to use a default item's embedding for undefined items.
        Parameters:
        defaultItem - the item to use as a default.
        Returns:
        this Builder
      • optSparseFormat

        public B optSparseFormat​(SparseFormat sparseFormat)
        Sets the optional parameter whether to compute row sparse gradient in the backward calculation. If set to True, the grad’s storage type is row_sparse.
        Parameters:
        sparseFormat - whether to compute row sparse gradient in the backward calculation
        Returns:
        this Builder
      • self

        protected abstract B self()
        Returns this {code Builder} object.
        Returns:
        this BaseBuilder