前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Tensorflow中遇到的错误

Tensorflow中遇到的错误

作者头像
听城
发布2018-04-27 14:25:41
2.3K0
发布2018-04-27 14:25:41
举报
文章被收录于专栏:杂七杂八杂七杂八

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

代码语言:javascript
复制
loss = tf.reduce_mean(
  tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels,
                 num_sampled, vocabulary_size))

解决方案,修改 embed, train_labels参数位置

Expected int32, got list containing Tensors of type '_Message' instead.

错误原因:

tensorflow版本的问题: tensorflow1.0及以后api定义:(数字在后,tensors在前) tf.stack(tensors, axis=axis) For example:

代码语言:javascript
复制
t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 0) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 1) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]

# tensor t3 with shape [2, 3]
# tensor t4 with shape [2, 3]
tf.shape(tf.concat([t3, t4], 0)) ==> [4, 3]
tf.shape(tf.concat([t3, t4], 1)) ==> [2, 6]

tensorflow之前版本(0.x版本:数字在前,tensors在后), 解决方法

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.12.28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type int32 of argument 'a'.
  • Expected int32, got list containing Tensors of type '_Message' instead.
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档