eaplatanios / tensorflow_scala

TensorFlow API for the Scala Programming Language
http://platanios.org/tensorflow_scala/
Apache License 2.0
937 stars 95 forks source link

Fix FeedMap conversion from empty map. #7

Closed sbrunk closed 7 years ago

sbrunk commented 7 years ago

Calling evaluate() on an Output without a feed argument causes a java.lang.UnsupportedOperationException: empty.reduceLeft

The direct fix would be to replace reduce by a fold, like this:

FeedMap(feeds.toSeq.map(f => ev.feed(f._1, f._2)).fold(Map.empty)(_ ++ _))

I think using just flatMap is simpler but should still be equivalent.

eaplatanios commented 7 years ago

Good catch! Thanks! :)