Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOM error in support vector machine. Sparse Vectors are expanded to the full length of the feature space in SupportVectorMachineEvaluator.java #165

Open
kslote1 opened this issue Jul 31, 2019 · 0 comments

Comments

@kslote1
Copy link

kslote1 commented Jul 31, 2019

Hi, I am getting the following error

com.google.common.util.concurrent.ExecutionError: java.lang.OutOfMemoryError: Java heap space

at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
at org.jpmml.evaluator.CacheUtil.getValue(CacheUtil.java:51)
at org.jpmml.evaluator.ModelEvaluator.getValue(ModelEvaluator.java:1028)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.getVectorMap(SupportVectorMachineModelEvaluator.java:439)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.evaluateSupportVectorMachine(SupportVectorMachineModelEvaluator.java:299)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.evaluateClassification(SupportVectorMachineModelEvaluator.java:193)
at org.jpmml.evaluator.ModelEvaluator.evaluateInternal(ModelEvaluator.java:681)
at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:580)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$.getVoteDistribution(ContentClassifier.scala:143)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$$anonfun$eval$1.apply(ContentClassifier.scala:53)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$$anonfun$eval$1.apply(ContentClassifier.scala:51)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$.eval(ContentClassifier.scala:51)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier.eval(ContentClassifier.scala)
at com.mimecast.implementation.contentclassifier.ContentClassifierModel.predict(ContentClassifierModel.java:39)
at com.mimecast.implementation.contentclassifier.ContentClassifierModel.predict(ContentClassifierModel.java:17)
at com.mimecast.ml.models.versioning.LocalModelReferenceManager.initializeModel(LocalModelReferenceManager.java:73)
at com.mimecast.ml.models.versioning.ModelReferenceManager.initializeReference(ModelReferenceManager.java:31)
at com.mimecast.ml.models.versioning.LocalModelReferenceManager.<init>(LocalModelReferenceManager.java:35)
at com.mimecast.implementation.contentclassifier.ContentClassifierModelReferenceManager.<init>(ContentClassifierModelReferenceManager.java:15)
at com.mimecast.implementation.contentclassifier.ContentClassifierModelManager.initialize(ContentClassifierModelManager.java:51)
at com.mimecast.implementation.contentclassifier.ContentClassifierMemoryLeakTest.testLeak(ContentClassifierMemoryLeakTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: java.lang.OutOfMemoryError: Java heap space
at com.google.common.primitives.Doubles.toArray(Doubles.java:427)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.toArray(SupportVectorMachineModelEvaluator.java:499)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.parseVectorDictionary(SupportVectorMachineModelEvaluator.java:483)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.access$000(SupportVectorMachineModelEvaluator.java:91)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator$2.load(SupportVectorMachineModelEvaluator.java:509)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator$2.load(SupportVectorMachineModelEvaluator.java:505)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
at org.jpmml.evaluator.CacheUtil.getValue(CacheUtil.java:51)
at org.jpmml.evaluator.ModelEvaluator.getValue(ModelEvaluator.java:1028)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.getVectorMap(SupportVectorMachineModelEvaluator.java:439)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.evaluateSupportVectorMachine(SupportVectorMachineModelEvaluator.java:299)
at org.jpmml.evaluator.support_vector_machine.SupportVectorMachineModelEvaluator.evaluateClassification(SupportVectorMachineModelEvaluator.java:193)
at org.jpmml.evaluator.ModelEvaluator.evaluateInternal(ModelEvaluator.java:681)
at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:580)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$.getVoteDistribution(ContentClassifier.scala:143)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$$anonfun$eval$1.apply(ContentClassifier.scala:53)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$$anonfun$eval$1.apply(ContentClassifier.scala:51)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier$.eval(ContentClassifier.scala:51)
at com.mimecast.scala.ml.contentclassifier.ContentClassifier.eval(ContentClassifier.scala)
at com.mimecast.implementation.contentclassifier.ContentClassifierModel.predict(ContentClassifierModel.java:39)
at com.mimecast.implementation.contentclassifier.ContentClassifierModel.predict(ContentClassifierModel.java:17)
at com.mimecast.ml.models.versioning.LocalModelReferenceManager.initializeModel(LocalModelReferenceManager.java:73)
at com.mimecast.ml.models.versioning.ModelReferenceManager.initializeReference(ModelReferenceManager.java:31)
at com.mimecast.ml.models.versioning.LocalModelReferenceManager.(LocalModelReferenceManager.java:35)

The support vector machine was trained with sparse vectors and that is reflected in the pmml.
After doing some inspection it looks like SparseArrayUtil.asNumberList takes the support vectors which should be sparse and expands them into the full array. This is what is causing a memory leak for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant