public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Scheme+ for Kawa and example
@ 2023-11-14 22:17 Damien Mattei
  0 siblings, 0 replies; only message in thread
From: Damien Mattei @ 2023-11-14 22:17 UTC (permalink / raw)
  To: kawa mailing list

[-- Attachment #1: Type: text/plain, Size: 1749 bytes --]

hello,
here is an example of function and a full example of code written in
Scheme+ for Kawa:
; modify coefficients layer
(define (modification_des_poids M_i_o η z_input z_output z̃_output ᐁ_i_o
მzⳆმz̃) ; derivative of activation function of the layer

 ; the length of output and input layer with coeff. used for bias update
 {(len_layer_output len_layer_input_plus1forBias) <+ (dim-matrix M_i_o)} ;
use values and define-values to create bindings

 {len_layer_input <+ {len_layer_input_plus1forBias - 1}}

 (for-each-in (in-range len_layer_output) ; line
    (lambda (j)
(for-each-in (in-range len_layer_input) ; column , parcours les colonnes de
la ligne sauf le bias
 (lambda (i)
   {M_i_o[j {i + 1}]  <-  M_i_o[j {i + 1}] - {(- η) * z_input[i] *
მzⳆმz̃(z_output[j] z̃_output[j]) * ᐁ_i_o[j]}}))

; and update the bias
            {M_i_o[j 0]  <-  M_i_o[j 0] - {(- η) * 1.0 * მzⳆმz̃(z_output[j]
z̃_output[j]) * ᐁ_i_o[j]}})))

the full code example is available here (best viewed with Safari due to z̃
special character in this example):
https://github.com/damien-mattei/AI_Deep_Learning/blob/c7c9794627f4d498f86f7ddf94d56517c5be1f7f/exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa%2B.scm#L78

and the current version of Scheme+ for Kawa code is available here:
https://github.com/damien-mattei/Scheme-PLUS-for-Kawa

it is now available as a simple module in Kawa that can be loaded this way:
(require Scheme+)

but due to the lack of SRFI 105 curly infix in Kawa a Scheme+ program must
be parsed before by curly-infix2prefix4kawa.scm to convert it in Kawa
scheme code like this:
curly-infix2prefix4kawa.scm kawa_code+.scm | tr -d '|' > kawa_code.scm

Damien

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-14 22:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 22:17 Scheme+ for Kawa and example Damien Mattei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).