athena.models.lm.nn_lm

NN language model interface

Module Contents

Classes

NNLM

Standard implementation of a RNNLM. Model mainly consists of embeding layer,

class athena.models.lm.nn_lm.NNLM

Bases: athena.models.base.BaseModel

Standard implementation of a RNNLM. Model mainly consists of embeding layer, rnn layers(with dropout), and the full connection layer, which are all incuded in self.model_for_rnn

abstract forward(inputs, inputs_length, training: bool = None)

do NN LM forward computation, for both train and decode.

call(samples, training: bool = None)

call model

save_model(path)

for saving model and current weight, path is h5 file name, like ‘my_model.h5’ usage: new_model = tf.keras.models.load_model(path)

get_loss(logits, samples, training=None)

get loss

get_ppl(loss)

loss is returned by self.get_loss(), and it is a tensor with none shape float value