首页 > 技术文章 > Keras (Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("embedding_1/random_uniform:0", shape=(20000, 100), dtype=float32)')

wlc297984368 2017-09-10 19:34 原文

这个问题出现根本原因是keras以及tensorflow的版本(服务器与本地)不一致

通过

Python

      import keras,tensorflow

      keras.__version__ 

      tensorflow.__version__

查看版本 然后通过 pip uninstall XXXX pip install install XXX版本号指定安装版本使得服务器与本机版本一致

本以为这个操作就可以解决问题结果依然还是Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("embedding_1/random_uniform:0", shape=(20000, 100), dtype=float32)'

原来还有python版本的问题

在服务器用的Python2.7训练的模型,在window上面Python2.7不支持TensorFlow

因此在服务器上重新建立虚拟环境配置python3的环境重新训练模型最终加载训练好的模型成功

 

推荐阅读