for i := 0 to 500 тут поидее должно мыть 23 так как 24 выходных нейрона do
begin
writeln(Format('out %f', [calc_out[i]]));
str.Add(FloatToStr(calc_out[i]));
end;
program XorConsole;
{$APPTYPE CONSOLE}
{$POINTERMATH ON}
uses
SysUtils, system.classes,
delphi_fann in '..\..\source\delphi_hatsunearu_fann.pas';
var
ann: PFann;
inputs: array [0 .. 47] of fann_type;
calc_out: PFann_Type_array;
i, j: integer;
train_data,inp: PFann_Train_Data;
str: TStringList;
k1: double;
min, max, b, res: double;
kf: TStringList;
mini, maxi, mino, maxo: Single;
begin
try
str := TStringList.Create;
try
str.LoadFromFile('..\..\datasets\in.txt');
ann := fann_create_standard(3, 48, 72, 24);
train_data := fann_read_train_from_file('..\..\datasets\test.test');
inp:=fann_read_train_from_file('..\..\datasets\in2.txt');
mini := 9999999;
mino := 9999999;
maxi := 0;
maxo := 0;
for j := 0 to train_data.num_data - 1 do
for i := 0 to train_data.num_input - 1 do
begin
if train_data.input[j][i] > maxi then
begin
maxi := train_data.input[j][i];
end;
if train_data.input[j][i] < mini then
begin
mini := train_data.input[j][i];
end;
end;
for j := 0 to train_data.num_data - 1 do
for i := 0 to train_data.num_output - 1 do
begin
if train_data.output[j][i] > maxo then
begin
maxo := train_data.output[j][i];
end;
if train_data.output[j][i] < mino then
begin
mino := train_data.output[j][i];
end;
end;
Writeln(format('mini= %f maxi= %f mino= %f maxo= %f',[mini,maxi,mino,maxo]));
readln;
fann_set_scaling_params(ann, train_data,mini,maxi,mino,maxo);
fann_scale_train_data(train_data, -1, 1);
fann_set_activation_steepness_hidden(ann, 1);
fann_set_activation_steepness_output(ann, 1);
fann_set_activation_function_hidden(ann, FANN_SIGMOID);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_learning_rate(ann,0.001);
fann_set_learning_momentum(ann,0.8);
fann_set_train_stop_function(ann, FANN_STOPFUNC_BIT);
fann_set_bit_fail_limit(ann, 0.001);
fann_set_training_algorithm(ann,FANN_TRAIN_RPROP);
fann_init_weights(ann, train_data);
fann_train_on_data(ann, train_data, 100, 1000, 0.001);
for i := 0 to 47 do
begin
inputs[i] := strtofloat(str[i]);
end;
{ for i := 0 to 47 do
begin
Writeln(inputs[i]);
end;}
fann_scale_input(ann, @inputs[0] --- --------------- тут должен быть pfan_type);
calc_out := fann_run(ann, @inputs[0]);
fann_descale_output(ann,calc_out);
str.Clear;
for i := 0 to 500 do
begin
writeln(Format('out %f', [calc_out[i]]));
str.Add(FloatToStr(calc_out[i]));
end;
str.SaveToFile('out.txt');
readln;
fann_destroy(ann);
finally
str.Free
end;
except
on E: Exception do
begin
writeln(E.ClassName, ': ', E.Message);
readln;
end;
end;
end.