gigasquid commented on a change in pull request #13993: [Clojure] Add resource
scope to clojure package
URL: https://github.com/apache/incubator-mxnet/pull/13993#discussion_r251202144
##########
File path:
contrib/clojure-package/examples/imclassification/src/imclassification/train_mnist.clj
##########
@@ -97,24 +76,39 @@
(println "Starting Training of MNIST ....")
(println "Running with context devices of" devs)
(let [_mod (m/module (get-symbol) {:contexts devs})]
- (m/fit _mod {:train-data train-data
- :eval-data test-data
- :num-epoch _num-epoch
- :fit-params (m/fit-params {:kvstore kvstore
- :optimizer optimizer
- :eval-metric eval-metric})})
+ (m/fit _mod {:train-data (mx-io/mnist-iter {:image (str data-dir
"train-images-idx3-ubyte")
+ :label (str data-dir
"train-labels-idx1-ubyte")
+ :label-name "softmax_label"
+ :input-shape [784]
+ :batch-size batch-size
+ :shuffle true
+ :flat true
+ :silent false
+ :seed 10
+ :num-parts num-workers
+ :part-index 0})
+ :eval-data (mx-io/mnist-iter {:image (str data-dir
"t10k-images-idx3-ubyte")
+ :label (str data-dir
"t10k-labels-idx1-ubyte")
+ :input-shape [784]
+ :batch-size batch-size
+ :flat true
+ :silent false
+ :num-parts num-workers
+ :part-index 0})
+ :num-epoch _num-epoch
+ :fit-params (m/fit-params {:kvstore kvstore
+ :optimizer optimizer
+ :eval-metric eval-metric})})
(println "Finish fit")
_mod
- )
-
- ))))
+ )))))
(defn -main [& args]
(let [[dev dev-num] args
devs (if (= dev ":gpu")
(mapv #(context/gpu %) (range (Integer/parseInt (or dev-num
"1"))))
(mapv #(context/cpu %) (range (Integer/parseInt (or dev-num
"1")))))]
- (start devs)))
+ (resource-scope/using (start devs))))
Review comment:
that's a good idea - thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services