'Equal' Op 的输入 'y' 的类型 bool 与参数 'x' 的 float32 类型不匹配 [英] Input 'y' of 'Equal' Op has type bool that does not match type float32 of argument 'x'

查看:33
本文介绍了'Equal' Op 的输入 'y' 的类型 bool 与参数 'x' 的 float32 类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事语音数字识别项目.

I am working on spoken digit recognition project.

模型定义:

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)

错误截图:

推荐答案

我想通了.只需在两个输入层中指定 dtype 如下:

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)

这篇关于'Equal' Op 的输入 'y' 的类型 bool 与参数 'x' 的 float32 类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆