You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by cm...@apache.org on 2018/11/16 16:36:14 UTC
[incubator-mxnet] 01/02: explore flan function
This is an automated email from the ASF dual-hosted git repository.
cmeier pushed a commit to branch can-you-gan
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
commit 7cdfc04cf2f6aa90701c627e4b79167817dea81b
Author: gigasquid <cm...@gigasquidsoftware.com>
AuthorDate: Fri Nov 16 11:21:54 2018 -0500
explore flan function
---
.../examples/gan/src/gan/gan_mnist.clj | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/contrib/clojure-package/examples/gan/src/gan/gan_mnist.clj b/contrib/clojure-package/examples/gan/src/gan/gan_mnist.clj
index ea67800..c1e635e 100644
--- a/contrib/clojure-package/examples/gan/src/gan/gan_mnist.clj
+++ b/contrib/clojure-package/examples/gan/src/gan/gan_mnist.clj
@@ -45,7 +45,7 @@
(io/make-parents (str output-path "gout"))
(defn last-saved-model-number []
- (some->> "model"
+ (some->> "."
clojure.java.io/file
file-seq
(filter #(.isFile %))
@@ -361,7 +361,33 @@
(println "Running with context devices of" devs)
(train devs)))
+
+(defn explore-flans [epoch]
+
+ (let [mod-g (-> (m/load-checkpoint {:contexts [(context/default-context)]
+ :data-names ["rand"]
+ :label-names [""]
+ :prefix "model-g"
+ :epoch epoch
+ :load-optimizer-states true})
+ (m/bind {:data-shapes (mx-io/provide-data rand-noise-iter)})
+ (m/init-params {:initializer (init/normal 0.02)})
+ (m/init-optimizer {:optimizer (opt/adam {:learning-rate lr :wd 0.0 :beta1 beta1})}))
+ rbatch (mx-io/next rand-noise-iter)
+ out-g (-> mod-g
+ (m/forward rbatch)
+ (m/outputs))]
+ (println "Generating image from " epoch)
+ (viz/im-sav {:title (str "explore-" epoch "-" 0)
+ :output-path output-path
+ :x (ffirst out-g)
+ :flip false})
+ (-> (img/load-image (str "results/explore-" epoch "-" 0 ".jpg"))
+ (img/show))))
+
(comment
(train [(context/cpu)])
+ (explore-flans 192)
+
)