NAME

Peta::NN::Layer::Embed - learned vectors for token indices

VERSION

version 0.2610090

SYNOPSIS

my $net = Peta::NN->new(input => 4, layers => [ [dense => 2] ]);     # as one of:
input  => { tokens => 6, vocab => 40 },
layers => [ [embed => 8], [dense => 16], 'relu', [dense => 3] ]

DESCRIPTION

Written as [embed => $dim], first in the layer list of a network whose input is { tokens => $count, vocab => $size }.

METHODS

A layer is made and driven by Peta::NN; these are what the network calls.

new

The layer, from what its entry in the layer list says.

type

The layer's kind, as a model file names it.

init

init($n_in, $rng, $backend): sets the layer up for its input size and returns its output size.

param_names

The names of the layer's parameter tensors.

forward

The layer's output for a batch.

backward

Takes the gradient of the output, leaves the gradients of the parameters with the layer, and returns the gradient of the input.

spec

The layer as it is written in a layer list.

param_cols

param_cols($name): numbers per row of a parameter tensor.

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.