Documentation
¶
Overview ¶
CharLM implements a character-level language model that uses a recurrent neural network as its backbone. A fully connected softmax layer (a.k.a decoder) is placed on top of each recurrent hidden state to predict the next character.
Index ¶
Constants ¶
const ( DefaultSequenceSeparator = "[SEP]" DefaultUnknownToken = "[UNK]" )
Variables ¶
This section is empty.
Functions ¶
func CalculatePerplexity ¶
CalculatePerplexity returns the perplexity for the text calculated as Exp(CrossEntropyLoss). The output of the language model is directly compared to the expected targets extracted from the input itself.
func Initialize ¶
func Initialize(m *Model, rndGen *rand.LockedRand)
Types ¶
type Config ¶
type Config struct { VocabularySize int EmbeddingSize int HiddenSize int OutputSize int // use the projection layer when the output size is > 0 SequenceSeparator string // empty string is replaced with DefaultSequenceSeparator UnknownToken string // empty string is replaced with DefaultUnknownToken }
TODO: add dropout
type Generator ¶
type Generator struct { GeneratorConfig // contains filtered or unexported fields }
func NewGenerator ¶
func NewGenerator(model *Model, config GeneratorConfig) *Generator
func (*Generator) GenerateText ¶
GenerateText returns a new sequences of text generated by the learned language model, and its log probability. The output text has a maximum length defined in the generator configuration. The text is incrementally constructed character by character, using all previously sampled characters as input to predict the next one.
type GeneratorConfig ¶
type Model ¶
type Processor ¶
type Trainer ¶
type Trainer struct { TrainingConfig // contains filtered or unexported fields }
func NewTrainer ¶
func NewTrainer(config TrainingConfig, corpus corpora.TextCorpusIterator, model *Model) *Trainer
type TrainingConfig ¶
type TrainingConfig struct { Seed uint64 BatchSize int BackStep int GradientClipping float64 SerializationInterval int UpdateMethod gd.MethodConfig ModelPath string }
TODO: add dropout