Example #1
0
        /// <summary>
        /// Generates output predictions for the input samples.
        /// </summary>
        /// <param name="x">The input data frame to run prediction.</param>
        /// <returns></returns>
        public Tensor Predict(DataFrame x)
        {
            List <float> predictions = new List <float>();

            Tensor output = x.GetTensor();

            foreach (var layer in Layers)
            {
                if (layer.SkipPred)
                {
                    continue;
                }

                layer.Forward(output);
                output = layer.Output;
            }

            predictions.AddRange(output.ToArray().Cast <float>());

            return(K.CreateVariable(predictions.ToArray(), output.Shape));
        }
Example #2
0
        /// <summary>
        /// Generates output predictions for the input samples.
        /// </summary>
        /// <param name="x">The input data frame to run prediction.</param>
        /// <returns></returns>
        public DataFrame Predict(DataFrame x)
        {
            List <float> predictions = new List <float>();

            Tensor output = x.GetTensor();

            foreach (var layer in Layers)
            {
                if (layer.SkipPred)
                {
                    continue;
                }

                layer.Forward(output);
                output = layer.Output;
            }

            predictions.AddRange(output.ToArray().Cast <float>());
            DataFrame result = new DataFrame();

            result.Load(predictions.ToArray());

            return(result);
        }