Skip to content

Commit

Permalink
network.js Documentation TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
christianechevarria committed Mar 23, 2019
1 parent 45520d1 commit c8d8c21
Showing 1 changed file with 119 additions and 6 deletions.
125 changes: 119 additions & 6 deletions src/architecture/network.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* Export */
module.exports = Network;

/* Import */
var multi = require('../multithreading/multi');
var methods = require('../methods/methods');
var Connection = require('./connection');
Expand Down Expand Up @@ -53,9 +49,18 @@ function Network (input, output) {
}
}

/*
* @namespace
*/
Network.prototype = {
/**
* Activates the network
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param input
* @param training
*/
activate: function (input, training) {
var output = [];
Expand All @@ -78,6 +83,11 @@ Network.prototype = {

/**
* Activates the network without calculating elegibility traces and such
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param input
*/
noTraceActivate: function (input) {
var output = [];
Expand All @@ -99,6 +109,13 @@ Network.prototype = {

/**
* Backpropagate the network
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param rate
* @param momentum
* @param update
* @param target
*/
propagate: function (rate, momentum, update, target) {
if (typeof target === 'undefined' || target.length !== this.output) {
Expand Down Expand Up @@ -130,6 +147,14 @@ Network.prototype = {

/**
* Connects the from node to the to node
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param from
* @param to
* @param weight
*/
connect: function (from, to, weight) {
var connections = from.connect(to, weight);
Expand All @@ -148,6 +173,11 @@ Network.prototype = {

/**
* Disconnects the from node from the to node
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param from
* @param to
*/
disconnect: function (from, to) {
// Delete the connection in the network's connection array
Expand All @@ -168,6 +198,11 @@ Network.prototype = {

/**
* Gate a connection with a node
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param node
* @param connection
*/
gate: function (node, connection) {
if (this.nodes.indexOf(node) === -1) {
Expand All @@ -181,7 +216,11 @@ Network.prototype = {
},

/**
* Remove the gate of a connection
* Remove the gate of a connection
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param connection
*/
ungate: function (connection) {
var index = this.gates.indexOf(connection);
Expand All @@ -194,7 +233,11 @@ Network.prototype = {
},

/**
* Removes a node from the network
* Removes a node from the network
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param node
*/
remove: function (node) {
var index = this.nodes.indexOf(node);
Expand Down Expand Up @@ -270,6 +313,10 @@ Network.prototype = {

/**
* Mutates the network with the given method
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
*
* @param method
*/
mutate: function (method) {
if (typeof method === 'undefined') {
Expand Down Expand Up @@ -510,6 +557,13 @@ Network.prototype = {

/**
* Train the given set to this network
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param set
* @param options
*/
train: function (set, options) {
if (set[0].input.length !== this.input || set[0].output.length !== this.output) {
Expand Down Expand Up @@ -615,6 +669,16 @@ Network.prototype = {
/**
* Performs one training epoch and returns the error
* private function used in this.train
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param set
* @param batchSize
* @param currentRate
* @param momentum
* @param costFunction
*/
_trainSet: function (set, batchSize, currentRate, momentum, costFunction) {
var errorSum = 0;
Expand All @@ -634,6 +698,13 @@ Network.prototype = {

/**
* Tests a set and returns the error and elapsed time
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param set
* @param cost [Function=]
*/
test: function (set, cost = methods.cost.MSE) {
// Check if dropout is enabled, set correct mask
Expand Down Expand Up @@ -668,6 +739,12 @@ Network.prototype = {

/**
* Creates a json that can be used to create a graph with d3 and webcola
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param {number} width
* @param {number} height
*/
graph: function (width, height) {
var input = 0;
Expand Down Expand Up @@ -774,6 +851,8 @@ Network.prototype = {

/**
* Convert the network to a json object
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*/
toJSON: function () {
var json = {
Expand Down Expand Up @@ -822,6 +901,8 @@ Network.prototype = {

/**
* Sets the value of a property for every node in this network
* @todo Add `@param` tag type
* @todo Add `@param` tag description
*/
set: function (values) {
for (var i = 0; i < this.nodes.length; i++) {
Expand All @@ -832,6 +913,13 @@ Network.prototype = {

/**
* Evolves the network to reach a lower error on a dataset
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param set
* @param options
*/
evolve: async function (set, options) {
if (set[0].input.length !== this.input || set[0].output.length !== this.output) {
Expand Down Expand Up @@ -1108,6 +1196,13 @@ Network.prototype = {

/**
* Convert a json object to a network
* @constructor
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag description
*
* @param json
* @returns {Network} Network
*/
Network.fromJSON = function (json) {
var network = new Network(json.input, json.output);
Expand Down Expand Up @@ -1136,6 +1231,14 @@ Network.fromJSON = function (json) {

/**
* Merge two networks into one
* @todo Add `@param` tag type
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param Network1
* @param Network2
* @returns {Network} Network
*/
Network.merge = function (network1, network2) {
// Create a copy of the networks
Expand Down Expand Up @@ -1178,6 +1281,14 @@ Network.merge = function (network1, network2) {

/**
* Create an offspring from two parent networks
* @todo Add `@param` tag types
* @todo Add `@param` tag descriptions
* @todo Add `@returns` tag type
* @todo Add `@returns` tag description
*
* @param Network1
* @param Network2
* @param equal
*/
Network.crossOver = function (network1, network2, equal) {
if (network1.input !== network2.input || network1.output !== network2.output) {
Expand Down Expand Up @@ -1342,3 +1453,5 @@ Network.crossOver = function (network1, network2, equal) {

return offspring;
};

module.exports = Network;

0 comments on commit c8d8c21

Please sign in to comment.