tensorflow - 将 Pyspark Dataframe 写入 TFrecords 文件

标签 tensorflow apache-spark pyspark databricks

我有一个带有架构的数据框,并希望将其转换为 tfRecords

root
 |-- col1: string (nullable = true)
 |-- col2: array (nullable = true)
 |    |-- element: string (containsNull = true)
 |-- col3: array (nullable = true)
 |    |-- element: string (containsNull = true)
 |-- col4: array (nullable = true)
 |    |-- element: float (containsNull = true)
 |-- col5: array (nullable = true)
 |    |-- element: float (containsNull = true)
 |-- col6: array (nullable = true)
 |    |-- element: integer (containsNull = true)
 |-- col7: array (nullable = true)
 |    |-- element: string (containsNull = true)
 |-- col8: array (nullable = true)
 |    |-- element: string (containsNull = true)
 |-- col9: array (nullable = true)
 |    |-- element: string (containsNull = true) 

我正在使用 Spark Tensorflow 连接器

df.write.mode("overwrite").format("tfrecords").option("recordType", "Example").save("targetpath.tf")

将数据保存到 tfrecords 时遇到错误

java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps

我也在databricks社区版中尝试过类似的方法,也遇到了类似的错误

有人可以帮忙吗?

最佳答案

最可能的原因(从 Maven Central information 判断)是您在使用 Scala 2.12 的 Databricks 运行时上使用为 Scala 2.11 编译的连接器。

您需要使用 DBR 6.4 进行该转换,或者 compile connector for Scala 2.12并使用。

关于tensorflow - 将 Pyspark Dataframe 写入 TFrecords 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70683969/

相关文章:

tensorflow - 无法导入名称 'ops' python

python - ValueError : Cannot feed value of shape (64, ) 对于张量 'x:0' ,其形状为 '(?, 128, 128, 1)'

apache-spark - Amazon EMR 上的 Livy Server 在连接到 ResourceManager 时挂起

scala - 通过 Spark Scala 从 ElasticSearch 读取嵌套数据

java.lang.ClassNotFoundException : org. openx.data.jsonserde.JsonSerDe 错误

python - PySpark LogisticRegressionWithLBFGS 导入错误

tensorflow - 将保存的 tensorflow 模型转换为 tensorflow Lite 的正确方法是什么

tensorflow - Keras VGG16 preprocess_input 模式

java - 如何替换 RDD 的元素

amazon-web-services - 从本地连接到客户端 cassandra