public GradientWorker(AbstractBatchOptimizer.TrainingWorker <T> mainWorker, int threadIdx, int numThreads, IList <T> queue, AbstractDifferentiableFunction <T> fn, ConcatVector weights)
 {
     // This is to help the dynamic re-balancing of work queues
     this.mainWorker = mainWorker;
     this.threadIdx  = threadIdx;
     this.numThreads = numThreads;
     this.queue      = queue;
     this.fn         = fn;
     this.weights    = weights;
     localDerivative = weights.NewEmptyClone();
 }