rosejn/cortex

API Question: Class Mapping and execute/run return value

Open

#182 geöffnet am 13. Juni 2017

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Clojure (109 Forks)batch import
easierenhancementhelp wanted

Repository-Metriken

Stars
 (1.269 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Supposing I train a network with:

(classification/perform-experiment
  (initial-description image-size image-size num-classes)
                                 train-ds
                                 test-ds
                                 observation->image
                                 class-mapping
                                 {})

And do a guess on a new observation (after loading the nippy file), with

(def nippy
  (util/read-nippy-file "trained-network.nippy"))
(execute/run nippy (into-array (image-file->observation "cat.png")))

The return of execute/run is a number, and the result needs to be converted to the class again to find out the real guess. Here, if I get 0, I need to execute an extra function like:

(defn index->class-name[n]
  (nth ["cat" "dog"] n))

to get the expected value "cat" from the returned result of : 0.

But I thought that was the reason for the parameter class-mapping passed to initial-description during the training step ?

  (def class-mapping
    {:class-name->index (zipmap ["cat" "dog"] (range))
     :index->class-name (zipmap (range) ["cat" "dog"])})

Shouldn't the network in the nippy file serialize the class-mapping and be able to return the decoded value ?

Contributor Guide