neural-api icon indicating copy to clipboard operation
neural-api copied to clipboard

XorAndOr test project issue

Open Kryuski opened this issue 1 year ago • 4 comments

I tested the XorAndOr neural network in the new Lazarus 2.24 (FPS 3.2.2), and found an unintentional modification of the structure of NN in the Fit procedure. Before Fit:

Layer  0 Neurons:   0 Weights:     0 TNNetInput(2,1,1,0,0) Output:2,1,1 ...
Layer  1 Neurons:   3 Weights:     6 TNNetFullConnect(3,1,1,0,0) Output:3,1,1 ...
Layer  2 Neurons:   3 Weights:     9 TNNetFullConnectLinear(3,1,1,0,0) Output:3,1,1 ...

After Fit:

Layer  0 Neurons:   0 Weights:     0 TNNetInput(2,1,1,0,0) Output:2,1,1 ...
Layer  1 Neurons:  32 Weights:    64 TNNetFullConnectReLU(32,1,1,0,0) Output:32,1,1  ...
Layer  2 Neurons:  32 Weights:  1024 TNNetFullConnectReLU(32,1,1,0,0) Output:32,1,1  ...
Layer  3 Neurons:   1 Weights:    32 TNNetFullConnectLinear(1,1,1,0,0) Output:1,1,1  ...

I used NN.DebugStructure to get the structure. Can anyone confirm this, or is it just me? P.S. Delphi 10.4 Community Edition does not have this problem.

Kryuski avatar Feb 27 '23 16:02 Kryuski

OK the issue is eliminated. How to fix: delete autosave.nn on the beginning of procedure TNeuralDataLoadingFit.FitLoading:

  FileName := FFileNameBase + '.nn';
  if FileExists(FileName) then // <-- add these lines
    SysUtils.DeleteFile(FileName);

Kryuski avatar Feb 28 '23 07:02 Kryuski

@Kryuski , Many thanks for reporting.

I'm reopening until I can reproduce and apply a fix to the source code.

joaopauloschuler avatar Mar 04 '23 12:03 joaopauloschuler

@Kryuski , Have you got this error while running one of the examples that come with this API?

joaopauloschuler avatar Mar 04 '23 14:03 joaopauloschuler

Yes, I ran various applications from the examples folder. Some of them create the autosave.nn file as they work. The XorAndOr app printed information to the console from this file, which was left over from running another example.

Kryuski avatar Mar 11 '23 10:03 Kryuski