T - the type of object to embedpublic abstract static class Embedding.BaseBuilder<T,B extends Embedding.BaseBuilder<T,B>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected DataType |
dataType |
protected T |
defaultItem |
protected int |
embeddingSize |
protected java.lang.Class<T> |
embeddingType |
protected AbstractIndexedEmbedding<T> |
fallthrough |
protected boolean |
sparseGrad |
protected boolean |
useDefault |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseBuilder() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class<T> |
getEmbeddingType()
Returns the embedded type.
|
B |
optDataType(DataType dataType)
Sets the data type of the embedding arrays (default is Float32).
|
B |
optDefaultItem(T defaultItem)
Sets whether to use a default item's embedding for undefined items.
|
B |
optFallthrough(AbstractIndexedEmbedding<T> fallthrough)
Sets a custom handler for items not found in the embedding.
|
B |
optSparseGrad(boolean sparseGrad)
Sets the optional parameter whether to compute row sparse gradient in the backward
calculation.
|
B |
optUseDefault(boolean useDefault)
Sets whether to use a default embedding for undefined items (default true).
|
protected abstract B |
self()
Returns this {code Builder} object.
|
B |
setEmbeddingSize(int embeddingSize)
Sets the size of the embeddings.
|
protected abstract B |
setType(java.lang.Class<T> embeddingType)
Creates a new
Embedding.BaseBuilder with the specified embedding type. |
protected java.lang.Class<T> embeddingType
protected int embeddingSize
protected boolean useDefault
protected T defaultItem
protected AbstractIndexedEmbedding<T> fallthrough
protected boolean sparseGrad
protected DataType dataType
public java.lang.Class<T> getEmbeddingType()
protected abstract B setType(java.lang.Class<T> embeddingType)
Embedding.BaseBuilder with the specified embedding type.embeddingType - the embedding classEmbedding.BaseBuilder class with the specified embedding typepublic B setEmbeddingSize(int embeddingSize)
embeddingSize - the size of the 1D embedding arraypublic B optUseDefault(boolean useDefault)
useDefault - true to provide a default embedding and false to throw an IllegalArgumentException when the item can not be foundpublic B optDefaultItem(T defaultItem)
defaultItem - the item to use as a default.public B optFallthrough(AbstractIndexedEmbedding<T> fallthrough)
See the standard fallthrough handlers optUseDefault(boolean) and optDefaultItem(Object).
fallthrough - the embedding to handle default cases.public B optSparseGrad(boolean sparseGrad)
sparseGrad - whether to compute row sparse gradient in the backward calculationpublic B optDataType(DataType dataType)
dataType - the dataType to use for the embeddingprotected abstract B self()
BaseBuilder