0% found this document useful (0 votes)
70 views

EKON 24 ML Community Edition

K-CAI NEURAL API is a Keras based neural network API for machine learning that will allow you to prototype with a lots of possibilities of Tensorflow! Python, Free Pascal and Delphi together in Google Colab, Git or the Community Edition.

Uploaded by

Max Kleiner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

EKON 24 ML Community Edition

K-CAI NEURAL API is a Keras based neural network API for machine learning that will allow you to prototype with a lots of possibilities of Tensorflow! Python, Free Pascal and Delphi together in Google Colab, Git or the Community Edition.

Uploaded by

Max Kleiner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

10 Writeln 'Hi AI';

20 Goto 10;

ML
Community
Edition
1
Agenda EKON 24
• Tensorflow64 Library
• FANN (Fast Artificial Neural Network )
• CAI NEURAL API
• K-CAI NEURAL API (Jupyter Notebook)
• Installation, Optimisation & Sources

2
Machine Learning

http://docs.codehaus.org/display/SONAR/Plugin+Library

3
Develop for Multiple Devices

https://www.tensorflow.org/

4
• unit tensorflow;

• interface

• Const
• tensorflow_dll = 'tensorflow64.dll';

• Type
• pTFChar = PAnsiChar;
• ppTFChar = ^pTFChar;
• size_t = NativeUInt;
• int64_t = Int64;
• pint64_t = ^int64_t;
• ppint64_t = ^pint64_t;
• psize_t = ^size_t;
• TEnumType = Cardinal;
• Float = Single;
• pFloat = ^Float; Now Demo: TensorFlowTest64.dproj

5
FANN
• Fast Artificial Neural Network (FANN) Library is a free open
source neural network library, which implements multilayer
artificial neural networks in C with support for both fully
connected and sparsely connected networks.

• Cross-platform execution in both fixed and floating point are


supported. It includes a framework for easy handling of
training data sets. It is easy to use, versatile, well
documented, and fast.
• Bindings to more than 15 programming languages are
available.
• https://github.com/libfann/fann

6
Delphi Wrapper
• Fast Artificial Neural Network Library (FANN) v2.2.0
(Original: https://github.com/libfann/fann)
• Fast Artificial Neural Network Library (FANN) v2.2.0
(https://github.com/hatsunearu/fann with FANN_RELU
and FANN_LEAKY_RELU)
• TensorFlow 1.3.0 → Demo

https://github.com/Laex/Delphi-Artificial-Neural-Network-Library

7
FANN Scripting
NN:= TFannNetwork.create(self)
with NN do begin
Layers.add('2')
Layers.add('3')
Layers.add('1')
LearningRate:= 0.699999988079071100
ConnectionRate:= 1.000
TrainingAlgorithm:= taFANN_TRAIN_RPROP
ActivationFunctionHidden:= afFANN_SIGMOID
ActivationFunctionOutput:= afFANN_SIGMOID
end;
C:\maXbox\EKON24\examples\814_FANN_XorSample2.pas

8
CAI NEURAL API
• K-CAI NEURAL API is a Keras based neural
network API for machine learning that will
allow you to prototype with a lots of
possibilities of Tensorflow! Python, Free
Pascal and Delphi together in Google Colab,
Git or the Community Edition.

• https://github.com/joaopauloschuler/neural-api

9
CAI NEURAL API II
• CAI NEURAL API is a pascal based neural
network API optimized for AVX, AVX2 and
AVX512 instruction sets plus OpenCL capable
devices including AMD, Intel and NVIDIA. This
API has been tested under Windows and Linux.
• This project is a subproject from a bigger and
older project called CAI and is sister to Keras
based K-CAI NEURAL API.
https://github.com/joaopauloschuler/neural-api

10
Colab as Universal Platform
Simple Image Classification with any Dataset:
this example shows how to create a model and train it
with a dataset (samples and features) passed as
parameter. Open In Colab
https://colab.research.google.com/github/maxkleiner/maXbox/blob/master/Copy_of_simple_image_classification_with_any_dataset.ipynb

https://colab.research.google.com/github/maxkleiner/
maXbox/blob/master/Copy_of_simple_image_classificat
ion_with_any_dataset.ipynb

11
CIFAR-10 Image Classifier
This example has interesting aspects to look at:

Its source code is very small.


Layers are added sequentially.
Training hyper-parameters are defined before calling fit method.
Model parameters are saved as hdf5 EKONSimpleImageClassifier.nn

https://github.com/maxkleiner/maXbox/blob/master/EKON24_SimpleImageClassificationCPU.ipynb

and the same in colab.research:

https://colab.research.google.com/github/maxkleiner/maXbox/blob/master/EKON24_SimpleImageClassificationCPU.ipynb

12
Win 10 Core Optimisation

CPU or GPU or TPU?

13
Win 32 or 64 API ?

14
Save the model
• Keras separates the concerns of saving your model
architecture and saving your model weights.
• Model weights are saved to HDF5 format. This is a grid
format that is ideal for storing multi-dimensional arrays of
numbers.

•Layer 11 Max Output: 0.812 Min Output: 0.000 TNNetSoftMax 10,1,1 Times: 0.00s 0.00s Parent:10
•Starting Testing.
•Epochs: 50 Examples seen:2000000 Test Accuracy: 0.8383 Test Error: 0.4463 Test Loss: 0.4969 Total
time: 162.32min
•Epoch time: 2.7 minutes. 100 epochs: 4.5 hours.
•Epochs: 50. Working time: 2.71 hours.
•Finished.

15
Save files local
• import os
• import urllib.request
• import tarfile

• if not os.path.isfile('cifar-10-batches-bin/data_batch_1.bin'):
• print("Downloading CIFAR-10 Files")
• url = 'https://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz'
• urllib.request.urlretrieve(url, './file.tar')

• tar = tarfile.open("file.tar")
• tar.extractall()
• tar.close()

16
Finally you can get with git
• C:\maXbox\mX399100\maxbox4\maxbox42\maxbox4>git clone
https://github.com/joaopau
• loschuler/k-neural-api.git k
• Cloning into 'k'...
• remote: Enumerating objects: 65, done.
• remote: Counting objects: 100% (65/65), done.
• remote: Compressing objects: 100% (43/43), done.
• remote: Total 356 (delta 38), reused 38 (delta 18), pack-reused 291
• Receiving objects: 100% (356/356), 224.47 KiB | 1.57 MiB/s, done.
• Resolving deltas: 100% (225/225), done.

http://docs.codehaus.org/display/SONAR/Developers%27+Seven+Deadly+Sins 17
18
Links & Sources
• Almost all files:

• https://sourceforge.net/projects/maxbox/files/Examples/EKON/EKON24/

• https://maxbox4.wordpress.com/blog/

• https://github.com/maxkleiner/maXbox4/releases

19
May the source be with you!
[email protected]
www.softwareschule.ch

20

You might also like