Exemple #1
0
        /// <summary>
        /// Gets the underlaying tensor instance.
        /// </summary>
        /// <returns></returns>
        public Tensor GetTensor()
        {
            if (UnderlayingTensor == null)
            {
                UnderlayingTensor = K.CreateVariable(UnderlayingVariable.Data <float>(), Shape);
            }

            return(UnderlayingTensor);
        }
Exemple #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 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));
        }