
TNeuron = class(TObject)
private
FThreshold: Single;
FInputCount: Integer;
FInputs:TSingleDynArray;
FWeights:TSingleDynArray;
FAnalogOutput:Boolean;
function GetInput(Index: Integer): Single;
function GetOutput: Single;
function GetWeight(Index: Integer): Single;
procedure SetInput(Index: Integer; const Value: Single);
procedure SetWeight(Index: Integer; const Value: Single);
procedure SetInputCount(const Value: Integer);
function GetLoad: Single;
public
Constructor Create(aInputCount:Integer);
procedure RandomInitialize;
Property Load:Single read GetLoad;
property Output:Single read GetOutput;
property Threshold:Single read FThreshold write FThreshold;
property Inputs[Index: Integer]: Single read GetInput write SetInput;
property Weights[Index: Integer]: Single read GetWeight write SetWeight;
property InputCount:Integer read FInputCount write SetInputCount;
property AnalogOutput read FAnalogOutput write FAnalogOutput;
end;
Download the updated TNeuron project for Delphi XE5 Firemonkey.
Head over and read the full blog post about the Delphi XE5 neuron object.
Great post! I’ve been interested in neural networks for quite some time and can still remember writing my first neural network code during a slow day as a part-time college computer lab assistant with Turbo Pascal for DOS. 🙂
The neuron object presented here is OK, but readers may be interested in the much more fleshed-out and mature FANN library which has good documentation and bindings for many languages including Delphi:
http://leenissen.dk/fann/wp/