Reputation: 71
I'm currently trying to build a chatbot. when I try to save the model, this the warning that I get:
WARNING:absl:Found untraced functions such as lstm_cell_8_layer_call_fn, lstm_cell_8_layer_call_and_return_conditional_losses, lstm_cell_9_layer_call_fn, lstm_cell_9_layer_call_and_return_conditional_losses while saving (showing 4 of 4). These functions will not be directly callable after loading. INFO:tensorflow:Assets written to: mychatnotmodel_1/assets INFO:tensorflow:Assets written to: mychatnotmodel_1/assets WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7f0867991850> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with
tf.keras.models.load_model
. If renaming is not possible, pass the object in thecustom_objects
parameter of the load function. WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7f08679882d0> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading withtf.keras.models.load_model
. If renaming is not possible, pass the object in thecustom_objects
parameter of the load function
this is the last cell of my model:
from tensorflow import keras
from keras.layers import Input, LSTM, Dense
from keras.models import Model
#Dimensionality
dimensionality = 256
#The batch size and number of epochs
batch_size = 10
epochs = 50
#Encoder
encoder_inputs = Input(shape=(None, num_encoder_tokens))
encoder_lstm = LSTM(dimensionality, return_state=True)
encoder_outputs, state_hidden, state_cell =
encoder_lstm(encoder_inputs)
encoder_states = [state_hidden, state_cell]
#Decoder
decoder_inputs = Input(shape=(None, num_decoder_tokens))
decoder_lstm = LSTM(dimensionality, return_sequences=True,
return_state=True)
decoder_outputs, decoder_state_hidden, decoder_state_cell =
decoder_lstm(decoder_inputs, initial_state=encoder_states)
decoder_dense = Dense(num_decoder_tokens, activation='softmax')
decoder_outputs = decoder_dense(decoder_outputs)
#set the random seed#
import tensorflow as tf
tf.random.set_seed(42)
#Model
training_model = Model([encoder_inputs, decoder_inputs],
decoder_outputs)
#Compiling
training_model.compile(optimizer='rmsprop',
loss='categorical_crossentropy', metrics=['accuracy'],
sample_weight_mode='temporal')
#Training
training_model.fit([encoder_input_data, decoder_input_data],
decoder_target_data, batch_size = batch_size, epochs = epochs,
validation_split = 0.2)
training_model.save('mychatnotmodel_1')
what should I do to not see that error anymore? also, What does that error even mean ?
Upvotes: 1
Views: 1242
Reputation:
These are some information passed to you in the form of warnings that shows what conflicts can occur while loading back the model for use after save.
Please understand these warnings and do the required changes if needed.
You can test and verify about this by loading back the model and check if the model executes successfully.
You can also surpass these warnings to avoid seeing by running below code:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
Upvotes: 1