我有一个带有架构的数据框,并希望将其转换为 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/