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