【问题标题】:TypeError: Can't convert 'text': data type not understoodTypeError:无法转换“文本”:无法理解数据类型
【发布时间】:2018-11-28 14:13:07
【问题描述】:

我正在尝试为一个段落做一个嵌入过程,这个过程被谷歌称为“通用句子编码”。这需要为深度学习分类过程完成。这给了我以下错误:

DAN U-S-E 模型(谷歌):

module_url = "https://tfhub.dev/google/universal-sentence-encoder/2"

embed = hub.Module(module_url)

with tf.Session() as session:
  session.run([tf.global_variables_initializer(), tf.tables_initializer()])
  message_embeddings = session.run(embed(train_clean_sentences))

错误: ~\AppData\Local\Continuum\anaconda3\lib\site- packages\tensorflow_hub\tensor_info.py in_convert_to_compatible_tensor(value,target, error_prefix)
117 张量 = tf.convert_to_tensor_or_indexed_slices(值,target.dtype)
118 除了 TypeError 作为 e:
--> 119 引发 TypeError("%s: %s" % (error_prefix, e))
120 如果 _is_sparse(张量)!= _is_sparse(目标):
121如果_is_sparse(张量):

TypeError:无法转换“文本”:无法理解数据类型

我不确定错误是什么,感谢任何帮助!

【问题讨论】:

    标签: python encoding word-embedding sentence python-embedding


    【解决方案1】:

    在上面的代码中(在问题中),“train_clean_sentences”输入是 pandas.series 数据类型,因为它是 pandas 数据框列。一旦我将 pandas.series 数据类型转换为列表,嵌入代码就可以工作。

    train_clean_sentences = df['Cleansed_X'].tolist()
    

    【讨论】:

      猜你喜欢
      • 2020-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-07
      • 2021-04-17
      • 2021-04-13
      • 2013-09-13
      • 2019-01-29
      相关资源
      最近更新 更多