2011-04-24 15:40:28 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class Fann < Formula
|
2012-04-01 16:58:48 +00:00
|
|
|
homepage 'http://leenissen.dk/fann/wp/'
|
|
|
|
url 'http://downloads.sourceforge.net/project/fann/fann/2.2.0/FANN-2.2.0-Source.tar.gz'
|
2012-06-27 15:45:36 +00:00
|
|
|
sha1 'ff8341e4104bdbc0f3ab7ad39aef33285f8512d4'
|
2012-04-01 16:58:48 +00:00
|
|
|
|
|
|
|
depends_on 'cmake' => :build
|
2013-01-21 21:12:37 +00:00
|
|
|
option :universal
|
2011-04-24 15:40:28 +00:00
|
|
|
|
|
|
|
def install
|
2013-01-21 21:12:37 +00:00
|
|
|
ENV.universal_binary if build.universal?
|
2012-05-22 21:37:04 +00:00
|
|
|
system "cmake", ".", *std_cmake_args
|
2011-04-24 15:40:28 +00:00
|
|
|
system "make install"
|
|
|
|
end
|
2012-06-27 15:45:36 +00:00
|
|
|
|
2013-02-02 05:12:34 +00:00
|
|
|
test do
|
|
|
|
(testpath/'xor.data').write <<-EOS.undent
|
|
|
|
4 2 1
|
|
|
|
-1 -1
|
|
|
|
-1
|
|
|
|
-1 1
|
|
|
|
1
|
|
|
|
1 -1
|
|
|
|
1
|
|
|
|
1 1
|
|
|
|
-1
|
|
|
|
EOS
|
2012-06-27 15:45:36 +00:00
|
|
|
|
2013-02-02 05:12:34 +00:00
|
|
|
(testpath/'test.c').write <<-EOS.undent
|
|
|
|
#include "fann.h"
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
const unsigned int num_input = 2;
|
|
|
|
const unsigned int num_output = 1;
|
|
|
|
const unsigned int num_layers = 3;
|
|
|
|
const unsigned int num_neurons_hidden = 3;
|
|
|
|
const float desired_error = (const float) 0.001;
|
|
|
|
const unsigned int max_epochs = 500000;
|
|
|
|
const unsigned int epochs_between_reports = 1000;
|
|
|
|
struct fann *ann = fann_create_standard(num_layers, num_input,
|
|
|
|
num_neurons_hidden, num_output);
|
|
|
|
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
|
|
|
|
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
|
|
|
|
fann_train_on_file(ann, "xor.data", max_epochs,
|
|
|
|
epochs_between_reports, desired_error);
|
|
|
|
fann_save(ann, "xor_float.net");
|
|
|
|
fann_destroy(ann);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
system ENV.cc, "-o", "test", "test.c", "-lfann"
|
|
|
|
system "./test"
|
|
|
|
system "cat xor_float.net"
|
|
|
|
puts
|
2012-06-27 15:45:36 +00:00
|
|
|
end
|
2011-04-24 15:40:28 +00:00
|
|
|
end
|