How to use the numjs.sigmoid function in numjs

To help you get started, we’ve selected a few numjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eimg / hello-nn-js / hello.dnn.gd.js View on Github external
function train(inputs, test_result, iterations) {
    for(var i = 0; i < iterations; i++) {
        var layer_zero = inputs;

        var layer_one = nj.sigmoid( layer_zero.dot(weights_zero) );
        var layer_two = nj.sigmoid( layer_one.dot(weights_one) );

        var layer_two_error = test_result.subtract(layer_two);

        if ((i % 10000) == 0) {
            console.log(i + " - Error: " + nj.mean(nj.abs(layer_two_error)));
        }

        // Backpropagation (sending back layer_two errors to layer_one)
        var layer_two_delta = layer_two_error.multiply( curve(layer_two) );
        var layer_one_error = layer_two_delta.dot( weights_one.T );
        var layer_one_delta = layer_one_error.multiply( curve(layer_one) );

        // Adjusting weights
        weights_one = weights_one.add(
            layer_one.T.dot(layer_two_delta).multiply(alpha)
        );
github eimg / burmese-text-classifier / classify.js View on Github external
function think(sentence) {
    var x = bow(sentence, words);

    var l0 = x;
    var l1 = nj.sigmoid(nj.dot(l0, synapse_0));
    var l2 = nj.sigmoid(nj.dot(l1, synapse_1));

    return l2;
}
github eimg / hello-nn-js / hello.dnn.js View on Github external
function think(inputs) {
    var layer_one = nj.sigmoid( inputs.dot(weights_zero) );
    var layer_two = nj.sigmoid( layer_one.dot(weights_one) );

    return layer_two;
}
github eimg / hello-nn-js / hello.dnn.gd.js View on Github external
function think(inputs) {
    var layer_one = nj.sigmoid( inputs.dot(weights_zero) );
    var layer_two = nj.sigmoid( layer_one.dot(weights_one) );

    return layer_two;
}
github MindExMachina / smartgeometry / services / sketch-rnn / lib / sketch_rnn.js View on Github external
LSTMCell.prototype.forward = function(x, h, c) {
    var concat = nj.concatenate([x, h]);
    var hidden = nj.add(nj.dot(concat, this.Wfull), this.bias);
    var num_units = this.num_units;
    var forget_bias = this.forget_bias;

    var i = nj.sigmoid(hidden.slice([0 * num_units, 1 * num_units]));
    var g = nj.tanh(hidden.slice([1 * num_units, 2 * num_units]));
    var f = nj.sigmoid(nj.add(hidden.slice([2 * num_units, 3 * num_units]), forget_bias));
    var o = nj.sigmoid(hidden.slice([3 * num_units, 4 * num_units]));

    var new_c = nj.add(nj.multiply(c, f), nj.multiply(g, i));
    var new_h = nj.multiply(nj.tanh(new_c), o);

    return [new_h, new_c];
};
LSTMCell.prototype.encode = function(sequence) {
github eimg / hello-nn-js / hello.dnn.js View on Github external
function think(inputs) {
    var layer_one = nj.sigmoid( inputs.dot(weights_zero) );
    var layer_two = nj.sigmoid( layer_one.dot(weights_one) );

    return layer_two;
}