Esempio n. 1
0
        public static string GetFormattedString(TF_DataType dtype, NDArray nd)
        {
            if (nd.size == 0)
            {
                return("[]");
            }

            switch (dtype)
            {
            case TF_DataType.TF_STRING:
                return($"b'{(string)nd}'");

            case TF_DataType.TF_BOOL:
                return((nd.GetByte(0) > 0).ToString());

            case TF_DataType.TF_RESOURCE:
                return("<unprintable>");

            default:
                return(nd.ToString());
            }
        }
Esempio n. 2
0
        public static string GetFormattedString(TF_DataType dtype, NDArray nd)
        {
            if (nd.size == 0)
            {
                return("[]");
            }

            switch (dtype)
            {
            case TF_DataType.TF_STRING:
                return(string.Join(string.Empty, nd.ToArray <byte>()
                                   .Select(x => x < 32 || x > 127 ? "\\x" + x.ToString("x") : Convert.ToChar(x).ToString())));

            case TF_DataType.TF_BOOL:
                return((nd.GetByte(0) > 0).ToString());

            case TF_DataType.TF_RESOURCE:
                return("<unprintable>");

            default:
                return(nd.ToString());
            }
        }