Giter Club home page Giter Club logo

cl-waffe's Issues

!argmax/!argmin requires tensor to be copied.

In the function trainer:

(defun valid (trainer dataset batch-size)
  "Valid trainer"
  (let ((count 0)
	(correct 0))
    (loop for index fixnum upfrom 0 below (get-dataset-length dataset) by batch-size
	  do (let* ((ds (get-dataset dataset index))
		    (x (car ds))
		    (y (second ds))
		    (out (const (value (call (slot-value trainer 'model) x))))
		    (out-labels (!argmax out))
		    (y-labels   (!argmax (const (copy-mat (data y)))))) ; <--- Here
	       (with-facets ((out-labels ((data out-labels) 'backing-array :direction :input))
			     (y-labels   ((data y-labels) 'backing-array :direction :input)))
		 (loop for i below (length out-labels)
		       do (progn
			    (incf count 1)
			    (if (= (aref out-labels i) (aref y-labels i))
				(incf correct 1)
				(incf correct 0)))))))
	     (format t "Accuracy:~a~C" (coerce (/ correct count) 'float) #\newline)))

This creates y's copy every time otherwise y-labels' value is not updated.

I guess this is due to accessing the wrong facets or something like that.
hmm

Gradient explosion of Seq2Seq (possibly related to linearlayer/embedding)

(defmodel Encoder (vocab-size embedding-dim hidden-size)
  :parameters ((embedding (Embedding vocab-size embedding-dim :pad-idx 0))
               (layer     (RNN embedding-dim hidden-size :num-layers 1)))
  :forward ((x)
            (with-calling-layers x
                (embedding x)
                (layer x))))

(defmodel Decoder (vocab-size embedding-dim hidden-size)
  :parameters ((embedding (Embedding vocab-size embedding-dim :pad-idx 0))
               (layer     (RNN embedding-dim hidden-size :num-layers 1))
               (h2l       (linearlayer hidden-size vocab-size)))
  :forward ((encoder-state y)
            (let* ((ye (call (self embedding) y))
                   (hs (call (self layer) ye encoder-state))
                   (h-output (call (self h2l) hs)))
                  h-output)))

(defmodel Seq2Seq (vocab-size-lang1 vocab-size-lang2 embedding-dim input-size)
  :parameters ((encoder (Encoder vocab-size-lang1 embedding-dim input-size))
               (decoder (Decoder vocab-size-lang2 embedding-dim input-size)))
  :forward ((x y)
            (let ((x-state (call (self encoder) x)))
                 (call (self decoder)
                       x-state
                       (!aref y t '(0 -1))))))```

こんな感じのSeq2Seqがあって、

```lisp
(setq model (Seq2Seq 1000 1000 100 100))

vocab_sizeを1000以上で初期化して、学習を進めると2~3回で勾配爆発を起こす

LinearLayer/Embeddingの重みの初期値は適切だと思うんだけど、どこが悪いんだぁ〜ぐあぁ〜〜

Split large files into small

The total lines of files like ‘tensor. lisp’, ‘operators. lisp’ is too large and for example algorithms like sampling beta shouldn't write in that file.

Move them into /distributions, activations.lisp, copy.lisp

Support GPU

Almost features are based on mgl-mat so it is not going to be a rocky road.
If possible, I want backends to support FP16

TODO

  1. Optimize the overhead of generic functions call-forward/call-backward (Less Important) It's done.

  2. make print-object rich(Done)

Allowing other options to use matrices in cl-waffe

As of this writing, all matrices in cl-waffe is a type of mgl-mat, even if I enter simple-array, cl-waffe coerces it to mgl-mat. However, The only part that depends on mgl-mat is the standard implementation. Considering with-backend allows to use other matrix operation libraries, it would be more reasonable not to restricted the datastructure of matrix.

To add: Dispatch nodes based on a given tensor’s backend

sorry for being written in Japanese...

defnode-backendみたいなマクロを作る。←このマクロはdefnodeで定義されたマクロのバックエンドを拡張する。

バックエンドはシンボルで管理されていて、(display-backend)関数で定義されたバックエンド一覧とノードの数を表示する。

define-node-methodのcall-forward/call-backwardでカーネルを割り当てる。

カーネルが存在しない場合はcl-waffe標準の:mglカーネルで計算。

そのためテンソルの型などは変更しない、他のライブラリで使うときはfacetを作ってもらう。

→numericals等他のライブラリに拡張できるようにする。
→他のバックエンドのバージョンを:cl-waffe-openclみたいに別のライブラリとして書けるようにする

(setf !aref) is ugly

To update the computation nodes, (setf !aref) needed to be called like:

(setq tensor (setf (!aref tensor ~) x))

This should be rewritten with macro, being easy to cause mistakes.

Add: (with-config ~) macro

Tensorデータ型やBackendは全てdefparameterを参照しているから

(with-config (:dtype :float)
             (:backends (:simd :numcl :mgl)) ; Backendの優先順位
   ...)```

みたいなマクロでまとめて設定できると便利そう。FP16対応する方法思いついたら作ろっかな〜

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.