Using Trained Keras Weights In Racket Scheme Code
Originally posted September 8, 2018
I am interested in using pre-trained deep learning models as functional components in functional languages like Scheme and Haskell.
I want to share a simple experiment that I wrote that uses Keras to train a model on the Wisconsin cancer data set (that I have used in the last three years in two books I have written in example programs), saves the weights in CSV files, and then uses those weights in a Racket Scheme program. There are two github repos:
- optional: https://github.com/mark-watson/save_keras_for_use_misc_prog_languages that trains a model and saves the weights
- Scheme code that includes the CSV weight files: https://github.com/mark-watson/racket_neural_net_from_keras
Sample run:
$ racket neural.rkt
** weights loaded **
shape of w2:
64
64
(number correct: 139)(number wrong: 12)(accuracy: 92.05298013245033)