TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type float64 of argument 'a

显示,TypeError: Input ‘b’ of ‘MatMul’ Op has type float32 that does not match type float64 of argument 'a,这是由于两个相乘矩阵类型不匹配,调试一下发现x矩阵为tf.float64,W矩阵为tf.float32,改类型用tf.cast()函数,修改如下:

y = tf.matmul(tf.cast(x,tf.float32),W)

猜你喜欢

转载自blog.csdn.net/sysleo/article/details/83413526