"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleNN = void 0;
var tfjs_node_1 = require("@tensorflow/tfjs-node");
var SimpleNN = /** @class */ (function () {
    function SimpleNN(parameters, wordEmbeddingsMatrix) {
        this._maxSeqLen = parameters.maxSeqLen;
        this._learningRate = parameters.learningRate;
        this._intentsCount = parameters.intentsCount;
        this._trainableEmbeddings = parameters.trainableEmbeddings;
        this._wordEmbeddingsMatrix = wordEmbeddingsMatrix;
        this._createModel();
    }
    Object.defineProperty(SimpleNN.prototype, "model", {
        get: function () {
            this._model.summary();
            return this._model;
        },
        enumerable: false,
        configurable: true
    });
    SimpleNN.prototype._createModel = function () {
        this._model = tfjs_node_1.sequential();
        this._addEmbeddingLayer();
        this._addLSTMLayer();
        this._addDenseLayer();
        this._compile();
    };
    SimpleNN.prototype._addEmbeddingLayer = function () {
        this._model.add(tfjs_node_1.layers.embedding({
            inputDim: this._wordEmbeddingsMatrix.shape[0],
            outputDim: this._wordEmbeddingsMatrix.shape[1],
            inputLength: this._maxSeqLen,
            trainable: this._trainableEmbeddings,
            weights: [this._wordEmbeddingsMatrix],
        }));
    };
    SimpleNN.prototype._addLSTMLayer = function () {
        this._model.add(tfjs_node_1.layers.lstm({
            units: 128,
            dropout: 0.3,
            recurrentDropout: 0.3,
        }));
    };
    SimpleNN.prototype._addDenseLayer = function () {
        this._model.add(tfjs_node_1.layers.dense({
            units: this._intentsCount,
            activation: 'softmax',
        }));
    };
    SimpleNN.prototype._compile = function () {
        this._model.compile({
            optimizer: tfjs_node_1.train.adam(this._learningRate),
            loss: 'sparseCategoricalCrossentropy',
            metrics: ['accuracy'],
        });
    };
    return SimpleNN;
}());
exports.SimpleNN = SimpleNN;
//# sourceMappingURL=simpleNN.js.map