EmbeddingBag

class EmbeddingBag(trainableWeights: TrainableTensor, reduction: EmbeddingBag.Companion.Reduction) : TrainableLayer<EmbeddingBag>

A trainable embedding table with size vocabSize x embeddingSize

Parameters

numEmbeddings

the size of the vocabulary/number of embedding vectors

embeddingSize

the size of each embedding vector

reduction

the reduction mode used to reduce each bag

This layer is equivalent to Embedding followed by a reduction (e.g. sum) across each bag of embeddings along the 0th axis.

Constructors

EmbeddingBag
Link copied to clipboard
fun EmbeddingBag(numEmbeddings: Int, embeddingSize: Int, reduction: EmbeddingBag.Companion.Reduction, random: Random, initializer: (Shape, Random) -> FloatTensor = Initializer.gaussian())
EmbeddingBag
Link copied to clipboard
fun EmbeddingBag(trainableWeights: TrainableTensor, reduction: EmbeddingBag.Companion.Reduction)

Types

Companion
Link copied to clipboard
object Companion

Functions

cpu
Link copied to clipboard
open override fun cpu(): EmbeddingBag
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
extractTangent
Link copied to clipboard
open override fun extractTangent(output: DTensor, extractor: (DTensor, DTensor) -> DTensor): TrainableComponent.Companion.Tangent
getSingleInput
Link copied to clipboard
open fun getSingleInput(inputs: Array<out DTensor>): DTensor

Helper to check that the layer was called with a single input. Returns that input if successful, else errors.

gpu
Link copied to clipboard
open override fun gpu(): EmbeddingBag
hashCode
Link copied to clipboard
open override fun hashCode(): Int
invoke
Link copied to clipboard
open operator override fun invoke(vararg inputs: DTensor): DTensor
operator fun invoke(indices: IntTensor, bagOffsets: IntTensor): DTensor
load
Link copied to clipboard
open override fun load(from: ByteBuffer): EmbeddingBag
store
Link copied to clipboard
open override fun store(into: ByteBuffer): ByteBuffer
to
Link copied to clipboard
open fun to(device: Device): OnDevice
trainingStep
Link copied to clipboard
open override fun trainingStep(optim: Optimizer<*>, tangent: Trainable.Tangent): EmbeddingBag
withTrainables
Link copied to clipboard
open override fun withTrainables(trainables: List<Trainable<*>>): EmbeddingBag
wrap
Link copied to clipboard
open override fun wrap(wrapper: Wrapper): EmbeddingBag

The wrap function should return the same static type it is declared on.

Properties

reduction
Link copied to clipboard
val reduction: EmbeddingBag.Companion.Reduction
trainables
Link copied to clipboard
open override val trainables: List<TrainableTensor>
trainableWeights
Link copied to clipboard
val trainableWeights: TrainableTensor