{"size": 739, "ext": "js", "max_stars_repo_path": "lib/neurons/softmax.js", "max_stars_repo_name": "garbados/ronaldo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/neurons/softmax.js", "max_issues_repo_name": "garbados/ronaldo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/neurons/softmax.js", "max_forks_repo_name": "garbados/ronaldo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.5277777778, "max_line_length": 98, "alphanum_fraction": 0.6874154263}
var Neuron = require('./interface');
var util = require('util');
var _ = require('underscore');

/**
TODO doc SoftmaxNeuron

@class
@implements Neuron
*/
function SoftmaxNeuron () {
  return Neuron.apply(this, arguments);
}

util.inherits(SoftmaxNeuron, Neuron);

/**
TODO doc SoftmaxNeuron._process

@function
@param {array} input - an array of input bits
@returns {number} - the neuron's reduction of the input array to a value between 0 and 1 inclusive
*/
SoftmaxNeuron.prototype._process = function (input) {
  var self = this;
  var result = input.map(function (x, i) {
    return (self.weight(i) * x);
  }).reduce(function (a, b) {
    return a + b;
  }, self.bias());

  return Math.exp(result);
};

module.exports = SoftmaxNeuron;
