[libfann] 66/242: added python files

Christian Kastner chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

chrisk-guest pushed a commit to tag Version2_0_0
in repository libfann.

commit 7fd00499eadfcbb03d3f4ce7229e1a47d5f8b5f0
Author: Steffen Nissen <lukesky at diku.dk>
Date:   Wed Jan 28 08:46:19 2004 +0000

    added python files
---
 python/Makefile        | 20 ++++++++++++++++++++
 python/README          | 13 +++++++++++++
 python/fann.i          | 14 ++++++++++++++
 python/simple_train.py | 20 ++++++++++++++++++++
 4 files changed, 67 insertions(+)

diff --git a/python/Makefile b/python/Makefile
new file mode 100644
index 0000000..d2e4cac
--- /dev/null
+++ b/python/Makefile
@@ -0,0 +1,20 @@
+# This makefile is on purpose not made with configure, to show how to use the library
+# The make file requires that the fann library is installed (see ../README)
+
+TARGETS = _fann.so 
+
+all: $(TARGETS)
+
+_%.so: %_wrap.o
+	gcc -shared $< -lfann -o $@ 
+
+%.o: %.c 
+	gcc -c -fpic $< -I/usr/include/python2.3/
+
+%_wrap.c: %.i 
+	swig -python $<
+
+
+
+clean:
+	rm -f $(TARGETS) *_wrap.* fann.py fann.pyc xor_float.net *~
diff --git a/python/README b/python/README
new file mode 100644
index 0000000..8b4bb8e
--- /dev/null
+++ b/python/README
@@ -0,0 +1,13 @@
+This python binding is provided by Vincenzo Di Massa <hawk.it at tiscalinet.it>
+
+MAKE
+Make sure to make and install the fann library first.
+Make sure that you have swig and python development files installed.
+Perhaps change the include directory of python.
+Then run 'make' to compile.
+
+INSTALL
+Copy the generated _fann.so and fann.py files to pyhon modules or into working directory.
+
+USAGE
+Just import fann.
diff --git a/python/fann.i b/python/fann.i
new file mode 100644
index 0000000..10eaa27
--- /dev/null
+++ b/python/fann.i
@@ -0,0 +1,14 @@
+/* File : fann.i */
+%module fann
+
+%include "typemaps.i"
+
+%{
+#include "../src/include/fann.h"
+%}
+
+/* Let's just grab the original header file here */
+#define FANN_INCLUDE
+%varargs(10,int n = 0) fann_create;
+%include "../src/include/fann.h"
+
diff --git a/python/simple_train.py b/python/simple_train.py
new file mode 100755
index 0000000..edf6a45
--- /dev/null
+++ b/python/simple_train.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+import fann
+
+connection_rate = 1
+learning_rate = 0.7
+num_layers = 3
+num_input = 2
+num_neurons_hidden = 4
+num_output = 1
+
+
+ann = fann.fann_create(connection_rate, learning_rate, num_layers,num_input, num_neurons_hidden, num_output)
+
+desired_error = 0.0001
+max_iterations = 500000
+iterations_between_reports = 1000
+fann.fann_train_on_file(ann, "../examples/xor.data", max_iterations, iterations_between_reports, desired_error)
+fann.fann_save(ann, "xor_float.net")
+
+fann.fann_destroy(ann)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfann.git



More information about the debian-science-commits mailing list