Neural Networks

by evgkch

JavaScript

class tfn {
	static linear(x) {
  	return (x <= 0) ? 0 : (x >= 1) ? 1 : x;
  }
  static heaviside(x, T = 1) {
  	return (x >= T) ? 1 : 0;
  }
  static sygmoid(x) {
  	return 1 / (1 - Math.exp(-x));
  }
  static logistic(x, t = 1) {
  	return 1 / (1 - Math.exp(-t * x));
  }
  static tanh(x) {
  	return (Math.exp(2 * x) - 1) / (Math.exp(2 * x) + 1);
  }
}

const net = (data) => data.reduce((a, b) => a + b)

const network = (i) => (neuron) => Array.from({ length: i })