aria42 / flare

Dynamic Tensor Graph library in Clojure (think PyTorch, DynNet, etc.)
Eclipse Public License 1.0
284 stars 18 forks source link

logistic-regression example fails #4

Closed azarafrooz closed 6 years ago

azarafrooz commented 6 years ago

This is so good. Thank you for all the efforts you have put into this. I am newbie to Clojure and I was searching for something close to Pytorch spirit and I couldn't get happier finding your codes. Thank you for that!

I was giving your logistic regression example a try and I keep getting some errors. It is highly possible that I am doing something wrong but if you happened to have an idea what might cause these errors, I would appreciate if you could let me know.

Exception in thread "main" java.lang.NullPointerException, compiling:(/private/var/folders/91/1n000v6n5x11vpyywj3mt9kr0000gn/T/form-init5736267063185451972.clj:1:125) at clojure.lang.Compiler.load(Compiler.java:7526) at clojure.lang.Compiler.loadFile(Compiler.java:7452) at clojure.main$load_script.invokeStatic(main.clj:278) at clojure.main$init_opt.invokeStatic(main.clj:280) at clojure.main$init_opt.invoke(main.clj:280) at clojure.main$initialize.invokeStatic(main.clj:311) at clojure.main$null_opt.invokeStatic(main.clj:345) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.invokeStatic(main.clj:424) at clojure.main$main.doInvoke(main.clj:387) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:702) at clojure.main.main(main.java:37) Caused by: java.lang.NullPointerException at clojure.lang.RT.uncheckedLongCast(RT.java:1500) at flare.examples.logistic_regression$train.invokeStatic(logistic_regression.clj:55) at flare.examples.logistic_regression$train.invoke(logistic_regression.clj:51) at flare.examples.logistic_regression$_main.invokeStatic(logistic_regression.clj:112) at flare.examples.logistic_regression$_main.doInvoke(logistic_regression.clj:106) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.Var.invoke(Var.java:377) at user$eval153.invokeStatic(form-init5736267063185451972.clj:1) at user$eval153.invoke(form-init5736267063185451972.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7062) at clojure.lang.Compiler.eval(Compiler.java:7052) at clojure.lang.Compiler.load(Compiler.java:7514) ... 12 more

azarafrooz commented 6 years ago

Ah, the fix was trivial. num-classes option was missing from the example. Just add it to cli-options: ["-c" "--num-classes NUM" "Number of classes" :default 5 :parse-fn #(Integer/parseInt %)]