rasa.utils.tensorflow.models
RasaModel Objects
Completely override all public methods of keras Model.
Cannot be used as tf.keras.Model
__init__
Initialize the RasaModel.
Arguments:
random_seed
- set the random seed to get reproducible results
batch_loss
Calculates the loss for the given batch.
Arguments:
batch_in
- The batch.
Returns:
The loss of the given batch.
prepare_for_predict
Prepares tf graph fpr prediction.
This method should contain necessary tf calculations
and set self variables that are used in batch_predict
.
For example, pre calculation of self.all_labels_embed
.
batch_predict
Predicts the output of the given batch.
Arguments:
batch_in
- The batch.
Returns:
The output to predict.
fit
Fit model data.
train_on_batch
Train on batch.
load
Loads a model from the given weights.
Arguments:
model_file_name
- Path to file containing model weights.model_data_example
- Example data point to construct the model architecture.finetune_mode
- Indicates whether to load the model for further finetuning.*args
- Any other non key-worded arguments.**kwargs
- Any other key-worded arguments.
Returns:
Loaded model with weights appropriately set.
batch_to_model_data_format
Convert input batch tensors into batch data format.
Batch contains any number of batch data. The order is equal to the key-value pairs in session data. As sparse data were converted into indices, data, shape before, this methods converts them into sparse tensors. Dense data is kept.
linearly_increasing_batch_size
Linearly increase batch size with every epoch.
The idea comes from https://arxiv.org/abs/1711.00489.
TransformerRasaModel Objects
batch_loss
Calculates the loss for the given batch.
Arguments:
batch_in
- The batch.
Returns:
The loss of the given batch.
batch_predict
Predicts the output of the given batch.
Arguments:
batch_in
- The batch.
Returns:
The output to predict.