コード例 #1
0
        /// <summary>
        /// Checks that the shape of the Previous Vector Action input placeholder is the same in the
        /// model and in the Brain Parameters.
        /// </summary>
        /// <param name="tensor"> The tensor that is expected by the model</param>
        /// <returns>If the Check failed, returns a string containing information about why the
        /// check failed. If the check passed, returns null.</returns>
        private string CheckPreviousActionShape(Tensor tensor)
        {
            var numberActionsBp = _brainParameters.vectorActionSize.Length;
            var numberActionsT  = tensor.Shape[tensor.Shape.Length - 1];

            if (numberActionsBp != numberActionsT)
            {
                return(string.Format(
                           "Previous Action Size of the model does not match. " +
                           "Received {0} but was expecting {1}.",
                           numberActionsBp, numberActionsT));
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Checks that the shape of the Vector Observation input placeholder is the same in the
        /// model and in the Brain Parameters.
        /// </summary>
        /// <param name="tensor"> The tensor that is expected by the model</param>
        /// <returns>If the Check failed, returns a string containing information about why the
        /// check failed. If the check passed, returns null.</returns>
        private string CheckVectorObsShape(Tensor tensor)
        {
            var vecObsSizeBp     = _brainParameters.vectorObservationSize;
            var numStackedVector = _brainParameters.numStackedVectorObservations;
            var totalVecObsSizeT = tensor.Shape[tensor.Shape.Length - 1];

            if (vecObsSizeBp * numStackedVector != totalVecObsSizeT)
            {
                return(string.Format(
                           "Vector Observation Size of the model does not match. " +
                           "Received {0} x {1} but was expecting {2}.",
                           vecObsSizeBp, numStackedVector, totalVecObsSizeT));
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Checks that the shape of the visual observation input placeholder is the same in the
        /// model and in the Brain Parameters.
        /// </summary>
        /// <param name="tensor"> The tensor that is expected by the model</param>
        /// <param name="visObsIndex"> The index of the visual observation.</param>
        /// <returns>If the Check failed, returns a string containing information about why the
        /// check failed. If the check passed, returns null.</returns>
        private string CheckVisualObsShape(Tensor tensor, int visObsIndex)
        {
            var resolutionBp = _brainParameters.cameraResolutions[visObsIndex];
            var widthBp      = resolutionBp.width;
            var heightBp     = resolutionBp.height;
            var pixelBp      = resolutionBp.blackAndWhite ? 1 : 3;
            var heightT      = tensor.Shape[1];
            var widthT       = tensor.Shape[2];
            var pixelT       = tensor.Shape[3];

            if ((widthBp != widthT) || (heightBp != heightT) || (pixelBp != pixelT))
            {
                return(string.Format(
                           "The visual Observation {0} of the model does not match. " +
                           "Received Tensor of shape [?x{1}x{2}x{3}] but was expecting [?x{4}x{5}x{6}].",
                           visObsIndex, widthBp, heightBp, pixelBp, widthT, heightT, pixelT));
            }
            return(null);
        }