anchor.diff:  ﻿open System
   open System.IO
  +open System.Text.RegularExpressions
   open persistence
   
   let bias = 1.0
   let learningConstant = 0.9
  +let rnd = System.Random()
   
   // Creating
  -let rnd = System.Random()
  -let randomWeight() =  rnd.NextDouble() * 2.0 - 1.0
  -
  -let createNeuron inputCount =
  -    [for i in 1 .. inputCount -> randomWeight()]
  -
  -let createLayer neuronCount inputCount =
  -    [for i in 1 .. neuronCount -> createNeuron (inputCount + 1)]
  -    
  -let createNet netInputCount hiddenLayerSizes outputLayerSize = 
  -    let neuronLayerSizes = hiddenLayerSizes @ [outputLayerSize]
  -    let inputCounts = netInputCount :: hiddenLayerSizes
  -    (neuronLayerSizes, inputCounts) ||> List.map2 createLayer
  +let createNet layerSizes =    
  +    let createNeuron inputLayerSize = 
  +        [for i in 1 .. 1 + inputLayerSize -> rnd.NextDouble() * 2.0 - 1.0]
  +    let createLayer inputLayer neuronCount  = 
  +        [for i in 1 .. neuronCount -> createNeuron (List.length inputLayer)]
  +    (([], layerSizes) ||> List.scan createLayer).Tail.Tail
   
   // Evaluating
  -let sigmoid x = 1.0 / (1.0 + exp -x)
  -
  -let evalNeuron inputs neuron =
  -    let aggregate sum a b = sum + a * b
  -    let sum = ((0.0, neuron, inputs) |||> List.fold2 aggregate)
  -    let result = sigmoid sum
  -    result
  -
  -let evalLayer inputs layer =
  -    (layer |> List.map (evalNeuron (bias::inputs)))
  -
  -let evalNet net netInputs =
  -    net |> List.scan evalLayer netInputs
  -
  -let evalOutputs net netInputs =
  -    evalNet net netInputs |> List.reduce (fun _ l -> l)
  +let evalNet net inputs =
  +    (inputs, net) ||> List.scan (fun inputs layer ->
  +        layer |> List.map (fun neuron ->
  +            (neuron, bias::inputs)
  +            ||> List.map2 (*)
  +            |> List.sum
  +            |> (fun sum -> 1.0 / (1.0 + exp -sum))))
  +
  +let feedForward net inputs =
  +    evalNet net inputs |> List.reduce (fun _ l -> l)
   
   // Training
   let bodyAndTail list =
  
positive.code:     let newNet, _, _, _ = 
          let outCount = netOutputs.Length
          let netWeights = [for x in [1..outCount] -> [for y in [1..outCount] -> if x = y then 1.0 else 0.0]]
          let netDeltas = List.map2 (fun answer output -> answer - output) answers netOutputs 
          let initialState = ([], netOutputs, netWeights, netDeltas)
          (allInputs, net, initialState) |||> List.foldBack2 getBpData 
      newNet
  
  
negative.code: let goDigits() = 
      let now() = DateTime.UtcNow
      let start = now()
      let sampleSize = 324  
      // 80; 512; 3280; 21000 ?
      // 5; 40; 324; 2609; 21000;
      printfn "Loading data and calculating initial values ..."
   
      let buildAnswerList count index  =
  