based on FANN and pyfann versions from http://leenissen.dk/fann/wp/