melisgl / mgl

Common Lisp machine learning library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add more examples/documentation

MatthewRock opened this issue · comments

Hello! Nice work there. I am beginner, and I would like to learn machine learning, and probably use your library for this purpose as well. However, right now it's kind of hard to see how things work; from my understanding, examples only show how to train neural networks, not how to use them.

For example, I would like to present other implementation of Recurrent Neural Network:
https://github.com/karpathy/char-rnn

The documentation(or "README", if you will) shows how to install dependencies(this is also kind of lacking, but that's for different conversation), and following the instructions you train and use your nn to generate text. Not so easy with examples in here - I only see how to train the network, but not how to actually use it. I would be very glad if you made some additional documentation.

Also, congratulations on amazing work.

Hello,
I agree this is an amazing project and also think it would be very helpful to have a simple example of using a model once it has been trained.
Congratulations,

jc

As an example of creating a predict function in digit-fnn.lisp I did the following:
Stored the trained fnn model in net global variable.
Then redifined set-input thus:

(defmethod set-input (digits (fnn digit-fnn))
       (let ((input (nodes (find-clump 'input fnn))))
         (fill! 0 input)
         (loop for i upfrom 0
               for digit in digits
               do (setf (mref input i digit) 1))))

And predict like this:

(defun predict (input-digit)
       (set-input (list input-digit) *net*)
       (forward *net*)
       (let ((output (coerce (mat-to-array (copy-row (nodes (find-clump 'output *net*)) 0)) 'list)))
         (position (apply 'max output) output)))

Evaluating (predict 4) will return the expeted value (mod (1+ d) 3)

Is this the best way to do this?
How would I go about doing the same for the rnn example in sum-sign-rnn.lisp?