brooksandrew / kaggle_yelp

Exploration of Convolutional Neural Networks using DeepLearning4J and Scala for Kaggle competition on Yelp Photo Classification
13 stars 7 forks source link

Exception in thread "main" java.util.NoSuchElementException: key not found: 402012 #1

Open KriteshGarg opened 8 years ago

KriteshGarg commented 8 years ago

I am getting this excption in : at scala.collection.MapLike$class.default(MapLike.scala:228) at scala.collection.AbstractMap.default(Map.scala:59) at scala.collection.MapLike$class.apply(MapLike.scala:141) at scala.collection.AbstractMap.apply(Map.scala:59) at modeling.processing.images$$anonfun$getImageIds$1.apply(images.scala:37) at modeling.processing.images$$anonfun$getImageIds$1.apply(images.scala:37) at scala.collection.immutable.List.map(List.scala:273) at modeling.processing.images$.getImageIds(images.scala:37) at modeling.runPipeline$.main(main.scala:22) at modeling.runPipeline.main(main.scala) 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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

I am new to scala and want to use convolution nn. Looks like the issue is cause of the image.scala

def getImageIds(photoDir: String, bizMap: Map[Int, String] = Map(-1 -> "-1"), bizIds: List[String] = List("-1")): List[String] = { val d = new File(photoDir) // new File("data/images/") // too many photos? val imgsPath = d.listFiles().map(x => x.toString).toList

if (bizMap == Map(-1 -> "-1") || bizIds == List(-1)) {
  imgsPath 
} else {
  val imgsMap = imgsPath.map(x => patt_get_jpg_name.findAllIn(x).mkString.toInt -> x).toMap
  val imgsPathSub = getImgIdsForBizId(bizMap, bizIds)
  imgsPathSub.map(x => imgsMap(x))
}

}

Please help

yl-coder commented 8 years ago

Try changing it to this mgsPathSub.filter(x => imgsMap.contains(x)).map(x => imgsMap(x))