Exemple #1
0
        /// <summary>
        /// Configures the model for training.
        /// </summary>
        /// <param name="optimizer">The optimizer function name used for training the model.</param>
        /// <param name="loss">The function name with which the training loss will be minimized.</param>
        /// <param name="metric"> The metric name to be evaluated by the model during training and testing.</param>
        /// <param name="regulizer">The regulizer instance to apply penalty on layers parameters.</param>
        public void Compile(BaseOptimizer optimizer, string loss, string metric = "", Regulizers regulizer = null)
        {
            CompileModel();

            learners.Add(optimizer.Get(modelOut, regulizer));
            lossName = loss;
            lossFunc = Losses.Get(loss, labelVariable, modelOut);
            if (!string.IsNullOrWhiteSpace(metric))
            {
                metricName = metric;
                metricFunc = Metrics.Get(metric, labelVariable, modelOut);
            }
            else
            {
                metricName = loss;
                metricFunc = lossFunc;
            }
        }
Exemple #2
0
 /// <summary>
 /// Mean Absolute Percentage Error the specified labels.
 /// </summary>
 /// <param name="labels">The labels.</param>
 /// <param name="predictions">The predictions.</param>
 /// <returns>Function.</returns>
 private static Function MAPE(Variable labels, Variable predictions)
 {
     return(Losses.MeanAbsPercentageError(labels, predictions));
 }
Exemple #3
0
 /// <summary>
 /// Mean Squared Error of the specified labels.
 /// </summary>
 /// <param name="labels">The labels.</param>
 /// <param name="predictions">The predictions.</param>
 /// <returns>Function.</returns>
 private static Function MSE(Variable labels, Variable predictions)
 {
     return(Losses.MeanSquaredError(labels, predictions));
 }