Example #1
0
        public void Optimize(Optimizers.OptimizerBase optimizer, LossFunc loss)
        {
            Optimizer = optimizer;
            Model.Optimize();

            LossFuncs = new LossFunc[Model.GetOutputLayersCount()];
            for (int i = 0; i < LossFuncs.Length; ++i)
            {
                LossFuncs[i] = loss;
            }
        }
Example #2
0
        public void Optimize(Optimizers.OptimizerBase optimizer, Dictionary <string, LossFunc> lossDict)
        {
            Optimizer = optimizer;
            Model.Optimize();

#if VALIDATION_ENABLED
            if (lossDict.Count != Model.GetOutputLayersCount())
            {
                throw new Exception($"Mismatched number of loss functions ({lossDict.Count}) and output layers ({Model.GetOutputLayersCount()})!");
            }
#endif

            LossFuncs = new LossFunc[Model.GetOutputLayersCount()];
            int i = 0;
            foreach (var outLayer in Model.GetOutputLayers())
            {
                LossFuncs[i++] = lossDict[outLayer.Name];
            }
        }