I am writing a chatbot in python with the help of the Keras library and the Seq2Seq model. I train the model first and then save that into a .h5 file and load from that file to use the trained model. However, when I try loading my model from my .h5 file I get the error: "ValueError: The name "input_2" is used 2 times in the model. All layer names should be unique." for reference the code I'm using to load the model is(with training_model.h5 as the save file)
latent_dim = 256
decoder_inputs = training_model.input[1]
decoder_state_input_hidden = Input(shape=(latent_dim,))
decoder_state_input_cell = Input(shape=(latent_dim,))
decoder_states_inputs = [decoder_state_input_hidden, decoder_state_input_cell]
decoder_lstm = training_model.layers[3]
decoder_outputs, state_hidden, state_cell = decoder_lstm(decoder_inputs, initial_state=decoder_states_inputs)
decoder_states = [state_hidden, state_cell]
decoder_dense = training_model.layers[4]
decoder_outputs = decoder_dense(decoder_outputs)
decoder_model = Model([decoder_inputs] + decoder_states_inputs, [decoder_outputs] + decoder_states)
it doesn't seem like any layer names are being repeated to me. Could someone please help me figure out what the issue is.
stack trace:
Traceback (most recent call last):
File "chatbot.py", line 169, in <module>
decoder_model = Model([decoder_inputs] + decoder_states_inputs, [decoder_outputs] + decoder_states)
File "C:\_MyPrograms\anaconda\envs\Alicia\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\_MyPrograms\anaconda\envs\Alicia\lib\site-packages\keras\engine\network.py", line 94, in __init__
self._init_graph_network(*args, **kwargs)
File "C:\_MyPrograms\anaconda\envs\Alicia\lib\site-packages\keras\engine\network.py", line 241, in _init_graph_network
self.inputs, self.outputs)
File "C:\_MyPrograms\anaconda\envs\Alicia\lib\site-packages\keras\engine\network.py", line 1523, in _map_graph_network
' times in the model. '
ValueError: The name "input_2" is used 2 times in the model. All layer names should be unique.
Thanks in Advance.