class Neuron {
  constructor() {
    this.weights = [];
  }

  randomWeight() {
    return Math.random() * 2 - 1;
  }

  activate(input) {
    let sum = 0;
    for (let i = 0; i < input.length; i++) {
      sum += input[i] * this.weights[i];
    }
    return 1 / (1 + Math.exp(-sum));
  }
}

class NeuralNetwork {
  constructor(inputSize, hiddenSize, outputSize) {
    this.inputSize = inputSize;
    this.hiddenSize = hiddenSize;
    this.outputSize = outputSize;

    this.hiddenLayer = [];
    for (let i = 0; i < hiddenSize; i++) {
      let neuron = new Neuron();
      neuron.weights = Array(inputSize).fill(0).map(() => neuron.randomWeight());
      this.hiddenLayer.push(neuron);
    }

    this.outputLayer = [];
    for (let i = 0; i < outputSize; i++) {
      let neuron = new Neuron();
      neuron.weights = Array(hiddenSize).fill(0).map(() => neuron.randomWeight());
      this.outputLayer.push(neuron);
    }
  }

  feedForward(input) {
    let hiddenOutput = this.hiddenLayer.map(neuron => neuron.activate(input));
    let output = this.outputLayer.map(neuron => neuron.activate(hiddenOutput));
    return output;
  }
}
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence