import org.apache.spark.mllib.feature.{Word2Vec, Word2VecModel}
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
model save:
Link: http://spark.apache.org/docs/2.3.4/api/scala/index.html#org.apache.spark.mllib.feature.Word2VecModel
var model = Word2VecModel.load(spark.sparkContext, config.model_path)
model read:
Link: http://spark.apache.org/docs/2.3.4/api/scala/index.html#org.apache.spark.mllib.feature.Word2VecModel$
var model = Word2VecModel.load(spark.sparkContext, config.model_path)
Read Error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.google.common.base.Stopwatch.<init>()V from class org.apache.hadoop.mapred.FileInputFormat
at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:312)
at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:200)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:251)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:251)
at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:251)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:251)
at org.apache.spark.rdd.RDD$$anonfun$take$1.apply(RDD.scala:1337)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
at org.apache.spark.rdd.RDD.take(RDD.scala:1331)
at org.apache.spark.rdd.RDD$$anonfun$first$1.apply(RDD.scala:1372)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
at org.apache.spark.rdd.RDD.first(RDD.scala:1371)
at org.apache.spark.mllib.util.Loader$.loadMetadata(modelSaveLoad.scala:129)
at org.apache.spark.mllib.feature.Word2VecModel$.load(Word2Vec.scala:699)
at job.ml.embeddingModel.graphEmbedding$.run(graphEmbedding.scala:40)
at job.ml.embeddingModel.graphEmbedding$.main(graphEmbedding.scala:24)
at job.ml.embeddingModel.graphEmbedding.main(graphEmbedding.scala)
POM file add
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
Run OK again!
Read More:
- How to Fix Word Opening Error: the resource dll cannot be loaded
- [Solved] A needed class was not found. This could be due to an error in your runpath. Missing class: scala/co
- How to Solve Spark Writes Hudi Error
- IDEA Create Scala Project Error: scalac: Error: Error compiling the sbt component ‘compiler-interface-2.10.0-52.0‘
- [Solved] error Component name “index“ should always be multi-word vue/multi-word-component-names
- How to Solve AOP error in Spring
- How to Solve spark Writes Files to odps Error
- Maven compiles Scala and reports an error stackoverflowerror
- How to Solve Hmaster hangs up issue due to namenode switching in Ha mode
- Error:scalac: Scala compiler JARs not found [How to Solve]
- [Solved] scala Error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exe
- How to Solve Tabbarview error in Column 2021
- How to Solve elasticSearch8.1.2 Install Error in Win10
- How to Solve webpack -v View Error in vsode
- How to Solve “parcel segmentation fault” Error in Linux
- How to Solve dtd Error in MybatisGenerator.xml file
- How to Solve Vector Variable Error in sub thread
- Vue: How to Solve Error uncaught (in promise) cancel
- How to Solve VMware Workstation Error: This virtual machine appears to be in use.
- [Solved] Ureport2 export word error: unable to access this website