Bugfix: Fix Brain.js training issues
This commit is contained in:
parent
7d709c0fa5
commit
25bb302033
2 changed files with 17 additions and 7 deletions
|
@ -82,10 +82,13 @@ class AITrainer {
|
|||
learningRate: this.settings.ai.learning_rate,
|
||||
momentum: this.settings.ai.momentum,
|
||||
|
||||
log: true,
|
||||
logPeriod: 50,
|
||||
|
||||
timeout: Infinity
|
||||
});
|
||||
|
||||
await fs.promises.writeFile(destination_filename, net.toJSON());
|
||||
await fs.promises.writeFile(destination_filename, JSON.stringify(net.toJSON()));
|
||||
// console.log(result);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -42,10 +42,12 @@ class DatasetFetcher {
|
|||
|
||||
// console.log(`Distance from gateway: ${haversine(gateway_location, rssi)}m`);
|
||||
|
||||
let next_output = clamp(normalise(rssi.rssi,
|
||||
{ min: this.settings.ai.rssi_min, max: this.settings.ai.rssi_max },
|
||||
{ min: 0, max: 1 }
|
||||
), 0, 1);
|
||||
let next_output = [
|
||||
clamp(normalise(rssi.rssi,
|
||||
{ min: this.settings.ai.rssi_min, max: this.settings.ai.rssi_max },
|
||||
{ min: 0, max: 1 }
|
||||
), 0, 1)
|
||||
];
|
||||
|
||||
result.push({
|
||||
input: next_input,
|
||||
|
@ -58,11 +60,16 @@ class DatasetFetcher {
|
|||
reading.latitude,
|
||||
reading.longitude
|
||||
);
|
||||
next_input.distance = haversine(gateway_location, reading);
|
||||
next_input.distance = clamp(
|
||||
normalise(haversine(gateway_location, reading),
|
||||
{ min: 0, max: 20000 },
|
||||
{ min: 0, max: 1 }
|
||||
),
|
||||
0, 1);
|
||||
|
||||
result.push({
|
||||
input: next_input,
|
||||
output: 0
|
||||
output: [ 0 ]
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue