I have this simple method for a neural network in C#:
private void InitNeurons()
{
//Neuron Initilization
List<float[]> neuronsList = new List<float[]>();
for (int i = 0; i < _layers.Length; i++) //run through all layers
{
neuronsList.Add(new float[_layers[i]]); //add layer to neuron list
}
_neurons = neuronsList.ToArray(); //convert list to array
}
How do I do this in F#? I was thinking it could be simpler. Perhaps something like this?
namespace NeuralNetwork
type NeuralNetworkF(layers : int[]) =
member this.Layers = layers
member this.Neurons : float[][] = [| for layer in layers do new float[]|]
This causes a compiler error in F#. I want to take the size of the int array "_layers" and for each value iterate over and add that value to the Neurons member in F#.