Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting elements in TNeuralFit.FitTrainingPair #125

Open
mikerabat opened this issue Oct 9, 2023 · 1 comment
Open

Getting elements in TNeuralFit.FitTrainingPair #125

mikerabat opened this issue Oct 9, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@mikerabat
Copy link

I was browsing through the code to understand the loading mechanism in the neuralfit classes.
In my first attempt I use the TNeuralFit class and need to move on to a more memory conserving loading mechanism.

Here is my question: The code actually uses a random index to be used as "next" element:

function TNeuralFit.FitTrainingPair(Idx: integer; ThreadId: integer): TNNetVolumePair;
var
  ElementIdx: integer;
begin
  ElementIdx := Random(FTrainingVolumes.Count);         
  FitTrainingPair := FTrainingVolumes[ElementIdx];
end;

First... why random? Is that better for the weight update?
Second: the call to Random is not thread safe and issued accross many threads. I don't know if there are side effects in that regard...

And how about this suggestion: through each batch one could create a (new) randomized list - this is quite fast and can be done
in one go. The list is spit over the attending threads. This also circumvents the possibility that not every example is handled in one
batch....

Is that feasable or over engineered then?

@joaopauloschuler joaopauloschuler self-assigned this Nov 6, 2023
@joaopauloschuler joaopauloschuler added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Nov 6, 2023
@joaopauloschuler
Copy link
Owner

@mikerabat , thank you for bringing to my attention that random is not thread safe!

In my own experimentation, random feeding gives better results than a predictable feeding.

I can certainly code something better than pure random numbers. I'll eventually work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants