tensorflow-debug笔记

1、Python Tensorflow线性模型不支持将字符串转换为float

tensorflow.python.framework.errors_impl.UnimplementedError: Cast string to float is not supported

2、找不到对应的checkpoint

errors_impl.NotFoundError: Key input_layer/distinct_id_embedding/embedding_weights not found in checkpoint

原因:由于tf运算图没有重置的原因,有人实验过证明第二次导入时候其中的变量名发生变化
解决:删除模型保存目录,重新生成

3、张量shape不一致

ValueError: Shapes (?, 1) and (?,) are incompatible

原因:计算过程中对两个shape分别为(?, 1) 和 (?,) 直接运算,shape不匹配报错
解决:reshape,将其中一个reshape成相同的shape
例如将(?, 1) reshape成 (?,) y = tf.reshape(y, shape=[-1,])

4、SparseTensor转Tensor

ValueError: The corresponding Tensor of numerical column must be a Tensor. SparseTensor is not supported. key: pic_emb

解决:tf.sparse.to_dense(
sp_input, default_value=None, validate_indices=True, name=None
)

5、VocabularyListCategoricalColumn报错

ValueError: Items of feature_columns must be a _DenseColumn. You can wrap a categorical column with an embedding_column or indicator_column. Given: VocabularyListCategoricalColumn(key=‘u_area_state’, vocabulary_list=(‘中国’, ‘俄罗斯’), dtype=tf.string, default_value=-1, num_oov_buckets=0)

原因:tf1.x 和 tf2.x的不同
解决:
area_state = fc.categorical_column_with_vocabulary_list(key=‘u_area_state’,
vocabulary_list=(“中国”, “俄罗斯”))

6、

TypeError: Could not build a TypeSpec for None with type NoneType

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值