LoRaWAN-Signal-Mapping/server/train-ai/DatasetFetcher.mjs
Starbeamrainbowlabs 192e31a925 Write the the data input, but it's untested.
There's also some confusion over the batch size. If it doesn't work, we 
probably need to  revise our understanding of the batch size in 
different contexts.
2019-07-18 16:34:25 +01:00

38 lines
786 B
JavaScript

"use strict";
import { normalise, clamp } from '../Helpers/Math.mjs';
class DatasetFetcher {
constructor({ settings, RSSIRepo }) {
this.settings = settings;
this.repo_rssi = RSSIRepo;
}
*fetch_input(gateway_id) {
for(let rssi of this.repo_rssi.iterate_gateway(gateway_id)) {
yield [
normalise(rssi.latitude,
{ min: -90, max: +90 },
{ min: 0, max: 1 }
),
normalise(rssi.longitude,
{ min: -180, max: +180 },
{ min: 0, max: 1 }
)
];
}
}
*fetch_output(gateway_id) {
for(let rssi of this.repo_rssi.iterate_gateway(gateway_id)) {
yield [
clamp(normalise(rssi.rssi,
{ min: this.settings.ai.rssi_min, max: this.settings.ai.rssi_max },
{ min: 0, max: 1 }
), 0, 1)
];
}
}
}
export default DatasetFetcher;