Neuron.fromWeights constructor

Neuron.fromWeights(
  1. int nin, {
  2. bool nonlin = true,
})

Implementation

factory Neuron.fromWeights(int nin, {bool nonlin = true}) {
  final w = List<Value>.generate(
      nin,
      (int index) => Value(
          math.Random().nextDouble() * 0.1), // Example: small random values
      growable: false);

  Value b = Value(0.0); // Often good to initialize biases to 0
  return Neuron(ValueVector(w), b: b, nonlin: true);
}