public virtual Trainer Configure <T>(Model model, int?epochs, Core.fDataSet dataSet, double?learningRate, double?momentum, int?batchSize, double?beta1, double?beta2) where T : CNN.Loss, new() { this.batchSize = batchSize; List <Core.fData> dataList = (List <Core.fData>)dataSet.fData; int index = 0, count; while (index < dataList.Count()) { count = (int)(dataList.Count() - index > batchSize ? batchSize : dataList.Count() - index); Core.fDataSet data = new Core.fDataSet(); data.fData = dataList.GetRange(index, count); batchImages.Add(data); index += (int)batchSize; } base.Configure(model, epochs, batchImages[0]); // 0. assert learningRate and momentum if ((learningRate == null) || (momentum == null) || (beta1 == null) || (beta2 == null)) { throw new Exception(); } this.learningRate = learningRate; this.momentum = momentum; this.beta1 = beta1; this.beta2 = beta2; this.lossfunc = new T(); return(this); }
public virtual Trainer Configure(Model model, int?epochs, Core.fDataSet dataSet) { this.dataSet = dataSet; this.model = model; // 0. assert input and output size for all of data set if (nofSet != 0) { throw new Exception(); } nofSet = dataSet.fData.Count; //for (int i = 0; i < nofSet; i++) // if ((System.Math.Sqrt(dataSet.fData[i].Data.Length) != model.Input.Output[0].Rows) || (dataSet.fData[i].Label.Length != model.Output.Output[0].Rows)) // throw new Exception(); // 1. assert epochs if (epochs == null) { throw new Exception(); } this.epochs = epochs; return(this); }