Train with NeuralNetworkGPU more slower than CPU
- Dominant language
- TypeScript
- Stars
- 14.9k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description

## _What_ is wrong?
Training with GPU takes too much time ( 2 min for 3000 data )
## _Where_ does it happen?
When I try to train with "NeuralNetworkGPU" instead of "NeuralNetwork"
## _How_ do we replicate the issue?
you can try to run this code ->
**Code:**
```
const abalone = require('./abalone.json');
const {NeuralNetworkGPU} = require('brain.js')
const sexToNumber = (sex) => {
switch(sex) {
case 'F': return 0;
case 'M': return 1;
default: return 0.5
}
}
const preparedData = (data, ratio = 29) => {
return data.map(row => {
const values = Object.values(row).slice(0, -1);
values[0] = sexToNumber(values[0]);
return { input: values, output: [row.rings / ratio] };
})
}
const shuffle = (arr) => arr.sort(() => Math.random() - .5);
const split = (arr, trainRatio = .75) => {
const l = Math.floor(arr.length * trainRatio);
return { train: arr.slice(0, l), test: arr.slice(l) };
}
const prepared = split(shuffle(preparedData(abalone)));
const config = {
iterations: 5000,
log: true,
logPeriod: 20,
};
const net = new NeuralNetworkGPU();
net.train(prepared.train, config);
let totalError = 0;
prepared.test.forEach(item => {
const output = net.run(item.input);
console.log(`Expected: ${item.output * 29} Predicted: ${output * 29}`);
totalError += (output - item.output) ** 2;
});
console.log(totalError / prepared.test.length);
```
## Expected behavior (i.e. solution)
I've RTX 3060Ti & i5-10500 when I try to train with cpu it takes 2-3 sec but when I switch to gpu maybe options same data takes almost 2 min. I believe my GPU is much stronger and faster than my CPU. GPU should more accurate and faster I think
## Version information
brain.js: 2.0.0-beta.23
gpu.js: 2.16.0
### Nodejs:
node: v16.16.0
### Browser:
### Brain.js:
brain.js: 2.0.0-beta.23
## _How_ important is this (1-5)?
5
## Other Comments
Maybe the config is not works on gpu version or I should enable some feature on my gpu. If so, brain.js should at least warn me about this
iterating 20 times each time

[abalone.csv](https://github.com/BrainJS/brain.js/files/12709353/abalone.csv) U can convert .csv to .json for code if you want
Contributor guide
Assessment
This issue has not been assessed yet.