【问题标题】:How to clean \xc2\xa0 using tf.strings.regex_replace?如何使用 tf.strings.regex_replace 清理 \xc2\xa0?
【发布时间】:2021-04-18 03:33:28
【问题描述】:

我尝试了以下方法但不起作用:

tf.strings.regex_replace(_string, "\xc2\xa0", ' ')

或

tf.strings.regex_replace(_string, "\%xc2\%xa0", ' ')

但两者都不起作用。 python 字符串替换方法应该可以工作,但作为 tf.data.Dataset 管道的一部分,它可能是模型层的一部分,我将不得不使用 tf.string.replace(...)。我也可以在 tf 管道之外进行字符串处理,但这不是优雅/强大的解决方案。

【问题讨论】:

    标签: tensorflow2.0 tensorflow-datasets regexp-replace


    【解决方案1】:

    这行得通 tf.strings.regex_replace(_string, '[\xc2\xa0]', ' ')

    【讨论】:

      猜你喜欢
      • 2018-02-03
      • 2015-12-01
      • 2016-02-25
      • 1970-01-01
      • 2022-06-15
      • 1970-01-01
      • 2010-10-03
      • 2011-05-20
      • 2011-10-27
      相关资源
      最近更新 更多