38 lines
794 B
JavaScript
38 lines
794 B
JavaScript
|
"use strict";
|
||
|
|
||
|
import tf from '@tensorflow/tfjs-node-gpu';
|
||
|
|
||
|
class AITrainer {
|
||
|
constructor({ settings }) {
|
||
|
this.settings = settings;
|
||
|
this.model = this.generate_model();
|
||
|
}
|
||
|
|
||
|
generate_model() {
|
||
|
let model = tf.sequential();
|
||
|
model.add(tf.layers.dense({
|
||
|
units: 256, // 256 nodes
|
||
|
activation: "sigmoid", // Sigmoid activation function
|
||
|
inputShape: [3], // 2 inputs - lat and long
|
||
|
}))
|
||
|
model.add(tf.layers.dense({
|
||
|
units: 1, // 1 output value - RSSI
|
||
|
activation: "sigmoid" // The example code uses softmax, but this is generally best used for classification tasks
|
||
|
}));
|
||
|
|
||
|
model.compile({
|
||
|
optimizer: tf.train.adam(),
|
||
|
loss: "absoluteDifference",
|
||
|
metrics: [ "accuracy", "meanSquaredError" ]
|
||
|
});
|
||
|
|
||
|
return model;
|
||
|
}
|
||
|
|
||
|
train() {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default AITrainer;
|