Skip to content

Commit 55a5a16

Browse files
Update README.md
1 parent f6e54de commit 55a5a16

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

examples/VisualGAN/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
# Artificial Art Example
2-
<img src="https://github.com/joaopauloschuler/neural-api/blob/master/docs/art2.jpg" height="400">
2+
<img src="https://github.com/joaopauloschuler/neural-api/blob/master/docs/art2.jpg" height="400"></img>
3+
4+
In this example, 2 neural networks will enter an arms race via a [Generative Adversarial Neural Network](https://en.wikipedia.org/wiki/Generative_adversarial_network): `FGenerative` and `FDiscriminator`. The Generative network will learn how to create images while the discriminator will compare these images against the CIFAR-10 dataset.
5+
6+
The discriminator `FDiscriminator` is trained via `TNeuralDataLoadingFit`:
7+
```
8+
FFit.OnAfterEpoch := @Self.DiscriminatorOnAfterEpoch;
9+
FFit.OnAfterStep := @Self.DiscriminatorOnAfterStep;
10+
FFit.OnStart := @Self.DiscriminatorOnStart;
11+
FFit.DataAugmentationFn := @Self.DiscriminatorAugmentation;
12+
...
13+
{$ifdef OpenCL}
14+
if FHasOpenCL then
15+
begin
16+
FFit.EnableOpenCL(FEasyOpenCL.PlatformIds[0], FEasyOpenCL.Devices[0]);
17+
Generative.EnableOpenCL(FEasyOpenCL.PlatformIds[0], FEasyOpenCL.Devices[0]);
18+
end;
19+
{$endif}
20+
//FFit.FitLoading(FDiscriminator, 64*10, 500, 500, 64, 35000, @GetDiscriminatorTrainingPair, nil, nil); // This line does the same as below
21+
FFit.FitLoading(FDiscriminator, 64*10, 500, 500, 64, 35000, @GetDiscriminatorTrainingProc, nil, nil); // This line does the same as above
22+
```
23+
24+
From the above code, some events are used and are interesting to note:
25+
* `FFit.OnStart := @Self.DiscriminatorOnStart;` is responsible for building required memory structures.
26+
* `FFit.OnAfterEpoch := @Self.DiscriminatorOnAfterEpoch;` calls the generative training. Therefore, the generative training is done after each discriminator epoch.
27+
28+
In order to show how `TNeuralDataLoadingFit` loads training data, above implementation has 2 equivalent calls (the first is commented) with both `GetDiscriminatorTrainingPair` and `GetDiscriminatorTrainingProc`.

0 commit comments

Comments
 (0)