rosejn/cortex

API Question: Class Mapping and execute/run return value

Open

#182 建立於 2017年6月13日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)Clojure (1,269 star) (109 fork)batch import
easierenhancementhelp wanted

描述

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 ?

貢獻者指南