kurman commented on a change in pull request #11205: Clojure Contrib Package
URL: https://github.com/apache/incubator-mxnet/pull/11205#discussion_r197868359
 
 

 ##########
 File path: 
contrib/clojure-package/examples/cnn-text-classification/src/cnn_text_classification/classifier.clj
 ##########
 @@ -0,0 +1,112 @@
+;;
+;; Licensed to the Apache Software Foundation (ASF) under one or more
+;; contributor license agreements.  See the NOTICE file distributed with
+;; this work for additional information regarding copyright ownership.
+;; The ASF licenses this file to You under the Apache License, Version 2.0
+;; (the "License"); you may not use this file except in compliance with
+;; the License.  You may obtain a copy of the License at
+;;
+;;    http://www.apache.org/licenses/LICENSE-2.0
+;;
+;; Unless required by applicable law or agreed to in writing, software
+;; distributed under the License is distributed on an "AS IS" BASIS,
+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;; See the License for the specific language governing permissions and
+;; limitations under the License.
+;;
+
+(ns cnn-text-classification.classifier
+  (:require [cnn-text-classification.data-helper :as data-helper]
+            [org.apache.clojure-mxnet.eval-metric :as eval-metric]
+            [org.apache.clojure-mxnet.io :as mx-io]
+            [org.apache.clojure-mxnet.module :as m]
+            [org.apache.clojure-mxnet.ndarray :as ndarray]
+            [org.apache.clojure-mxnet.optimizer :as optimizer]
+            [org.apache.clojure-mxnet.symbol :as sym]
+            [org.apache.clojure-mxnet.context :as context])
+  (:gen-class))
+
+(def mr-dataset-path "data/mr-data") ;; the MR polarity dataset path
+(def glove-file-path "data/glove/glove.6B.50d.txt")
+
+(defn shuffle-data [test-num {:keys [data label sentence-count sentence-size 
embedding-size]}]
+  (println "Shuffling the data and splitting into training and test sets")
+  (println {:sentence-count sentence-count
+            :sentence-size sentence-size
+            :embedding-size embedding-size})
+  (let [shuffled (shuffle (map (fn [d l] [d l]) data label))
+        train-num (- (count shuffled) test-num)
+        training (into [] (take train-num shuffled))
+        test (into [] (drop train-num shuffled))]
+    {:training {:data  (ndarray/array (into [] (flatten (mapv (fn [v] (first 
v)) training)))
 
 Review comment:
   And I think we should be generally clear on coding preferences whether `#()` 
form is preferable.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to