Search code examples
pythontensorflowkerasdeep-learninglstm

Input 'y' of 'Equal' Op has type bool that does not match type float32 of argument 'x'


I am working on spoken digit recognition project.

Model Definition :

input_layer = Input(shape = (max_length, 1))      //Takes input vectors
input_mask = Input(shape = (max_length))          //Takes boolean mask vectors (False for zero else true)
LSTM_layer = LSTM(25)(input_layer, mask = input_mask)
dense = Dense(50, 'relu')(LSTM_layer)
dense_1 = Dense(10, 'softmax')(dense)
model = Model(inputs = [input_layer, input_mask], outputs = dense_1)

Error Screenshot : enter image description here


Solution

  • I figured it out. Just specify the dtype in both input layers as below :

    input_layer = Input(shape = (max_length, 1), dtype='float32')
    input_mask = Input(shape = (max_length), dtype='bool')
    LSTM_layer = LSTM(25)(input_layer, mask = input_mask)
    dense = Dense(50, 'relu')(LSTM_layer)
    dense_1 = Dense(10, 'softmax')(dense)
    model = Model(inputs = [input_layer, input_mask], outputs = dense_1)