As we know the decoder takes the encoder hidden states as the initial state ...
encoder_output , state_h, state_c = LSTM(cellsize, return_state=True)(embedded_encoder_input)
encoder_states = [state_h, state_c]
decoder_lstm = LSTM(cellsize, return_state=True, return_sequences=True)
decoder_outputs, state_dh, state_dc = decoder_lstm(embedded_decoder_inputs, initial_state=encoder_states)
Assume I want to replace the initial state of the decoder to be encoder_output and features from me from other resources
encoder_states = [encoder_output , my_state]
But I face the following error:
ValueError: The initial state or constants of an RNN layer cannot be specified with a mix of Keras tensors and non-Keras tensors (a "Keras tensor" is a tensor that was returned by a Keras layer, or by
Input
)
Although I print state_h & stat_c & encoder_output & my_state, all have the same type and shape, example:
state_h: Tensor("lstm_57/while/Exit_2:0", shape=(?, 128), dtype=float32) my_state: Tensor("Reshape_17:0", shape=(?, 128), dtype=float32)
What am I understanding that it will not accept inputs not produced from the previous layer, and as Keras tensor?
Update
After convert tensor to Keras tensor, The new error:
ValueError: Input tensors to a Model must come from
keras.layers.Input
. Received: Tensor("Reshape_18:0", shape=(?, 128), dtype=float32) (missing previous layer metadata).
my_state
from? – nurictf
or is it passed from somewhere else, do you generate it, is it an input? Depending on it's source you would need the appropriate wrapper for Keras. – nuric