Skip to content

Commit a3a29e3

Browse files
Code portability
1 parent 341f4bf commit a3a29e3

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

neural/neuralab.pas

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
with this program; if not, write to the Free Software Foundation, Inc.,
1919
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
}
21-
22-
{$MODE Delphi}
21+
{$IFDEF FPC}{$MODE Delphi}{$ENDIF}
2322

2423
interface
2524

@@ -126,8 +125,11 @@ function ABKey(S: array of byte; Divisor: longint): longint;
126125
SumKey: longint;
127126
begin
128127
SumKey := 203;
128+
{$IFDEF FPC}
129129
{$PUSH}
130+
{$ENDIF}
130131
{$OVERFLOWCHECKS OFF}
132+
131133
for I := Low(S) to High(S) do
132134
begin
133135
SumKey :=
@@ -136,7 +138,9 @@ function ABKey(S: array of byte; Divisor: longint): longint;
136138
end;
137139
ABKey := abs(SumKey) mod Divisor;
138140
{$OVERFLOWCHECKS ON}
141+
{$IFDEF FPC}
139142
{$POP}
143+
{$ENDIF}
140144
end;
141145

142146
function ABCmp(var X, Y: array of byte): boolean;

neural/neuralbyteprediction.pas

+4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141

4242
unit neuralbyteprediction; // this unit used to be called UBup3
4343

44+
{$IFDEF FPC}
4445
{$MODE Delphi}
46+
{$ENDIF}
4547

4648
interface
4749

@@ -1189,7 +1191,9 @@ procedure TStatePredictionClass.deleteDuplicateNeurons;
11891191
begin
11901192
NeuronList := TStringList.Create();
11911193
NeuronList.Sorted := True;
1194+
{$IFDEF FPC}
11921195
NeuronList.SortStyle := sslAuto;
1196+
{$ENDIF}
11931197
for neuronPos := Low(FNN) to High(FNN) do
11941198
begin
11951199

neural/neuraldatasets.pas

+7-7
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ procedure CreateCifar10Volumes(out ImgTrainingVolumes, ImgValidationVolumes,
165165
ImgTestVolumes: TNNetVolumeList);
166166

167167
// loads a CIFAR10 into TNNetVolumeList
168-
procedure loadCifar10Dataset(ImgVolumes: TNNetVolumeList; idx:integer; base_pos:integer = 0; color_encoding: byte = csEncodeRGB);
169-
procedure loadCifar10Dataset(ImgVolumes: TNNetVolumeList; fileName:string; base_pos:integer = 0; color_encoding: byte = csEncodeRGB);
168+
procedure loadCifar10Dataset(ImgVolumes: TNNetVolumeList; idx:integer; base_pos:integer = 0; color_encoding: byte = csEncodeRGB); overload;
169+
procedure loadCifar10Dataset(ImgVolumes: TNNetVolumeList; fileName:string; base_pos:integer = 0; color_encoding: byte = csEncodeRGB); overload;
170170

171171
// loads a CIFAR100 into TNNetVolumeList
172-
procedure loadCifar100Dataset(ImgVolumes: TNNetVolumeList; idx:integer; base_pos:integer = 0; color_encoding: byte = csEncodeRGB);
173-
procedure loadCifar100Dataset(ImgVolumes: TNNetVolumeList; fileName:string; base_pos:integer = 0; color_encoding: byte = csEncodeRGB);
172+
procedure loadCifar100Dataset(ImgVolumes: TNNetVolumeList; idx:integer; base_pos:integer = 0; color_encoding: byte = csEncodeRGB); overload;
173+
procedure loadCifar100Dataset(ImgVolumes: TNNetVolumeList; fileName:string; base_pos:integer = 0; color_encoding: byte = csEncodeRGB); overload;
174174

175175
// This function returns TRUE if data_batch_1.bin and error message otherwise
176176
function CheckCIFARFile():boolean;
@@ -187,7 +187,7 @@ procedure TranslateCifar10VolumesToMachineAnimal(VolumeList: TNNetVolumeList);
187187

188188
implementation
189189

190-
uses SysUtils, math, FileUtil{, uvolumelcl, Graphics};
190+
uses SysUtils, math;
191191

192192
procedure TranslateCifar10VolumesToMachineAnimal(VolumeList: TNNetVolumeList);
193193
var
@@ -664,7 +664,7 @@ procedure TestBatch
664664
vOutput.SetClassForReLU( ImgVolumes[ImgIdx].Tag );
665665
end;
666666

667-
ErrorSum += vOutput.SumDiff(pOutput);
667+
ErrorSum := ErrorSum + vOutput.SumDiff(pOutput);
668668

669669
if (bIsSoftmax) then
670670
begin
@@ -679,7 +679,7 @@ procedure TestBatch
679679
CurrentLoss := 1;
680680
end;
681681

682-
Loss += CurrentLoss;
682+
Loss := Loss + CurrentLoss;
683683
end;
684684
end;
685685

neural/neuralgeneric.pas

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
*)
1919
unit neuralgeneric;
2020

21-
{$mode objfpc}{$H+}
21+
{$IFDEF FPC}
22+
{$mode objfpc}
23+
{$ENDIF}
24+
25+
{$H+}
2226

2327
interface
2428

neural/neuralplanbuilder.pas

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(*
1+
(*
22
neuralplanbuilder: This unit "builds and optimizea plans" towards success with
33
AI techniques. A plan (TPlan) is a sequence of actions and predicted states.
44
A composite plan (TCompositePlan) is an array of plans that can work together.
@@ -21,7 +21,9 @@
2121

2222
unit neuralplanbuilder; // this unit used to be called UFway44.
2323

24+
{$IFDEF FPC}
2425
{$MODE Delphi}
26+
{$ENDIF}
2527

2628
{ Lazarus/Free Pascal Source }
2729
// made by Joao Paulo Schwarz Schuler

0 commit comments

Comments
 (0)