csys: provide generic synapse op: modify-value
This commit is contained in:
parent
385cbefe16
commit
d4b032f156
1 changed files with 11 additions and 5 deletions
|
|
@ -14,7 +14,7 @@
|
|||
#:neuron #:std-proc #:eff-proc
|
||||
#:handle-action #:basic-actions #:forward #:notify
|
||||
#:no-op #:printer #:value-add #:create #:connect
|
||||
#:multiply
|
||||
#:modify-value #:multiply #:divide
|
||||
#:send-message #:send-create #:send-connect #:send-switch))
|
||||
|
||||
(in-package :scopes/csys)
|
||||
|
|
@ -154,7 +154,7 @@
|
|||
(setf (value scope) (shape:data-value msg :value))
|
||||
(values msg scope)))
|
||||
|
||||
(defun value-add (&key (bias 0) (threshold 1) (limits '(0 10)))
|
||||
(defun value-add (&key (bias 0) (threshold 1) (limits '(0 15)))
|
||||
(lambda (msg scope)
|
||||
(let* ((val (getf (shape:data msg) :value))
|
||||
(newval (+ val (value scope)))
|
||||
|
|
@ -210,12 +210,18 @@
|
|||
|
||||
;;;; synapse ops
|
||||
|
||||
(defun multiply (n)
|
||||
(defun modify-value (fn &rest args)
|
||||
(lambda (msg)
|
||||
(let* ((data (copy-list (shape:data msg))))
|
||||
(setf (getf data :value) (* (getf data :value 0) n))
|
||||
(let ((data (copy-list (shape:data msg))))
|
||||
(setf (getf data :value) (apply fn (getf data :value 0) args))
|
||||
(message:create (shape:head msg) :data data))))
|
||||
|
||||
(defun multiply (n)
|
||||
(modify-value #'* n))
|
||||
|
||||
(defun divide (n)
|
||||
(modify-value #'floor n))
|
||||
|
||||
;;;; public shortcuts
|
||||
|
||||
(defun send-message (cell head data)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue