[incubator-mxnet] 02/05: wip
This is an automated email from the ASF dual-hosted git repository. cmeier pushed a commit to branch clojure-release-script in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git commit 92b73514ad522517790b74cd5d444a5ea1eb6a8c Author: gigasquid AuthorDate: Fri Oct 25 16:08:55 2019 -0400 wip --- .../examples/imclassification/project.clj | 4 +- .../clojure-package/src/dev/package_release.clj| 224 + 2 files changed, 227 insertions(+), 1 deletion(-) diff --git a/contrib/clojure-package/examples/imclassification/project.clj b/contrib/clojure-package/examples/imclassification/project.clj index 702a33d..08e7ae3 100644 --- a/contrib/clojure-package/examples/imclassification/project.clj +++ b/contrib/clojure-package/examples/imclassification/project.clj @@ -21,4 +21,6 @@ :dependencies [[org.clojure/clojure "1.9.0"] [org.apache.mxnet.contrib.clojure/clojure-mxnet "1.6.0-SNAPSHOT"]] :pedantic? :skip - :main imclassification.train-mnist) + :main imclassification.train-mnist + :repositories [["download-staging" {:url "https://repository.apache.org/content/repositories/staging; :snapshots true +:update :always}]]) diff --git a/contrib/clojure-package/src/dev/package_release.clj b/contrib/clojure-package/src/dev/package_release.clj new file mode 100644 index 000..cc3c946 --- /dev/null +++ b/contrib/clojure-package/src/dev/package_release.clj @@ -0,0 +1,224 @@ +(ns dev.package-release + (:require [clojure.java.io :as io] +[clojure.edn :as edn] +[clojure.java.shell :refer [sh]] +[clojure.spec.alpha :as s] +[clojure.string :as string] +[dev.generator])) + +(s/def ::build-type #{:osx-cpu :linux-gpu :linux-cpu}) +(s/def ::release-number string?) +(s/def ::apache-gpg-key string?) +(s/def ::release-args (s/keys :req-un [::build-type ::release-number + ::apache-gpg-key])) + +(def scala-jar-name + {:linux-cpu "org.apache.mxnet/mxnet-full_2.11-linux-x86_64-cpu" + :linux-gpu "org.apache.mxnet/mxnet-full_2.11-linux-x86_64-gpu" + :osx-cpu "org.apache.mxnet/mxnet-full_2.11-osx-x86_64-cpu"}) + +(defn backup-project-file + "Backs up a copy of the original project file" + [] + (do +(sh "cp" "project.clj" "project.clj.bak") +(sh "cp" "examples/imclassification/project.clj" "examples/imclassification/project.clj.bak"))) + +(defn make-new-project-file + "Creates a new project file for the relase by + changing the build type and the version along + with the release number and the signer's public key + which can be an email" + [{:keys [build-type release-number apache-gpg-key]}] + + (let [project-data (read-string (slurp "project.clj")) +project-header (take 3 project-data) +project-rest-map (->> project-data + (drop 3) + (apply hash-map)) +new-header `[~'defproject + ~(symbol (str "org.apache.mxnet.contrib.clojure/clojure-mxnet" + "-" (name build-type))) + ~release-number] +new-dependencies (->> (:dependencies project-rest-map) + (remove #(string/includes? % "org.apache.mxnet")) + (into [[(symbol (scala-jar-name build-type)) release-number]])) +new-project-rest-map (-> project-rest-map + (assoc :dependencies new-dependencies) + (assoc-in [:deploy-repositories 0 1 :signing :gpg-key] + apache-gpg-key))] + +(as-> (into [] new-project-rest-map) p + (into new-header (mapcat identity p)) + (apply list p) + (with-out-str (clojure.pprint/pprint p)) + (str dev.generator/license p) + (spit "project.clj" p + +(defn run-commands + "Run shell commands and report exit and out" + ([commands text] + (commands text nil)) + ([commands text dir] + (do + (println "= " text " =") + (println "Please wait ") + (flush)) + (let [{:keys [out exit err]} (apply sh (if dir +(into commands [:dir dir]) +commands))] + (do + (println out) + (flush) + (when-not (zero? exit) + (println "Errors:") + (println err) + (flush)) + (zero? exit) + +(defn reset-project-files + "Resets the projects files back to the original saved version" + [] + (do +(sh "cp" "project.clj" "new-project-clj") +(sh "cp" "project.clj.bak" "project.clj") +(sh "cp" "examples/imclassification/project.clj.bak" "examples/imclassification/project.clj"))) + +(defn run-tests-and-install + "With the project file in place, use lein to +
[incubator-mxnet] 02/05: wip
This is an automated email from the ASF dual-hosted git repository. cmeier pushed a commit to branch clojure-release-script in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git commit 92b73514ad522517790b74cd5d444a5ea1eb6a8c Author: gigasquid AuthorDate: Fri Oct 25 16:08:55 2019 -0400 wip --- .../examples/imclassification/project.clj | 4 +- .../clojure-package/src/dev/package_release.clj| 224 + 2 files changed, 227 insertions(+), 1 deletion(-) diff --git a/contrib/clojure-package/examples/imclassification/project.clj b/contrib/clojure-package/examples/imclassification/project.clj index 702a33d..08e7ae3 100644 --- a/contrib/clojure-package/examples/imclassification/project.clj +++ b/contrib/clojure-package/examples/imclassification/project.clj @@ -21,4 +21,6 @@ :dependencies [[org.clojure/clojure "1.9.0"] [org.apache.mxnet.contrib.clojure/clojure-mxnet "1.6.0-SNAPSHOT"]] :pedantic? :skip - :main imclassification.train-mnist) + :main imclassification.train-mnist + :repositories [["download-staging" {:url "https://repository.apache.org/content/repositories/staging; :snapshots true +:update :always}]]) diff --git a/contrib/clojure-package/src/dev/package_release.clj b/contrib/clojure-package/src/dev/package_release.clj new file mode 100644 index 000..cc3c946 --- /dev/null +++ b/contrib/clojure-package/src/dev/package_release.clj @@ -0,0 +1,224 @@ +(ns dev.package-release + (:require [clojure.java.io :as io] +[clojure.edn :as edn] +[clojure.java.shell :refer [sh]] +[clojure.spec.alpha :as s] +[clojure.string :as string] +[dev.generator])) + +(s/def ::build-type #{:osx-cpu :linux-gpu :linux-cpu}) +(s/def ::release-number string?) +(s/def ::apache-gpg-key string?) +(s/def ::release-args (s/keys :req-un [::build-type ::release-number + ::apache-gpg-key])) + +(def scala-jar-name + {:linux-cpu "org.apache.mxnet/mxnet-full_2.11-linux-x86_64-cpu" + :linux-gpu "org.apache.mxnet/mxnet-full_2.11-linux-x86_64-gpu" + :osx-cpu "org.apache.mxnet/mxnet-full_2.11-osx-x86_64-cpu"}) + +(defn backup-project-file + "Backs up a copy of the original project file" + [] + (do +(sh "cp" "project.clj" "project.clj.bak") +(sh "cp" "examples/imclassification/project.clj" "examples/imclassification/project.clj.bak"))) + +(defn make-new-project-file + "Creates a new project file for the relase by + changing the build type and the version along + with the release number and the signer's public key + which can be an email" + [{:keys [build-type release-number apache-gpg-key]}] + + (let [project-data (read-string (slurp "project.clj")) +project-header (take 3 project-data) +project-rest-map (->> project-data + (drop 3) + (apply hash-map)) +new-header `[~'defproject + ~(symbol (str "org.apache.mxnet.contrib.clojure/clojure-mxnet" + "-" (name build-type))) + ~release-number] +new-dependencies (->> (:dependencies project-rest-map) + (remove #(string/includes? % "org.apache.mxnet")) + (into [[(symbol (scala-jar-name build-type)) release-number]])) +new-project-rest-map (-> project-rest-map + (assoc :dependencies new-dependencies) + (assoc-in [:deploy-repositories 0 1 :signing :gpg-key] + apache-gpg-key))] + +(as-> (into [] new-project-rest-map) p + (into new-header (mapcat identity p)) + (apply list p) + (with-out-str (clojure.pprint/pprint p)) + (str dev.generator/license p) + (spit "project.clj" p + +(defn run-commands + "Run shell commands and report exit and out" + ([commands text] + (commands text nil)) + ([commands text dir] + (do + (println "= " text " =") + (println "Please wait ") + (flush)) + (let [{:keys [out exit err]} (apply sh (if dir +(into commands [:dir dir]) +commands))] + (do + (println out) + (flush) + (when-not (zero? exit) + (println "Errors:") + (println err) + (flush)) + (zero? exit) + +(defn reset-project-files + "Resets the projects files back to the original saved version" + [] + (do +(sh "cp" "project.clj" "new-project-clj") +(sh "cp" "project.clj.bak" "project.clj") +(sh "cp" "examples/imclassification/project.clj.bak" "examples/imclassification/project.clj"))) + +(defn run-tests-and-install + "With the project file in place, use lein to +
[incubator-mxnet] 02/05: wip working
This is an automated email from the ASF dual-hosted git repository. cmeier pushed a commit to branch clojure-autoencoder in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git commit f64dd20a19131a1e85493603e7ec3e6f8ec930d7 Author: gigasquid AuthorDate: Sun Jul 7 17:02:00 2019 -0400 wip working --- contrib/clojure-package/examples/gan/src/gan/auto_encoder.clj | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/clojure-package/examples/gan/src/gan/auto_encoder.clj b/contrib/clojure-package/examples/gan/src/gan/auto_encoder.clj index 93b..ee1a9a6 100644 --- a/contrib/clojure-package/examples/gan/src/gan/auto_encoder.clj +++ b/contrib/clojure-package/examples/gan/src/gan/auto_encoder.clj @@ -75,11 +75,18 @@ (mx-io/provide-data train-data) (mx-io/provide-label train-data) + (mx-io/reset train-data) (def my-batch (mx-io/next train-data)) (def images (mx-io/batch-data my-batch)) - (ndarray/shape (first images)) + (ndarray/shape (ndarray/reshape (first images) [100 1 28 28])) (viz/im-sav {:title "first" :output-path "results/" :x (first images)}) + (viz/im-sav {:title "cm-first" :output-path "results/" :x (ndarray/reshape (first images) [100 1 28 28])}) + + (def preds (m/predict-batch my-mod {:data images} )) + (ndarray/shape (ndarray/reshape (first preds) [100 1 28 28])) +(viz/im-sav {:title "cm-preds" :output-path "results/" :x (ndarray/reshape (first preds) [100 1 28 28])}) + (def my-metric (eval-metric/mse)) @@ -119,6 +126,7 @@ ;;;high level score (returs the eval values) (let [score (m/score mod {:eval-data test-data :eval-metric (eval-metric/accuracy)})] (println "High level predict score is " score))) +