예제 #1
0
        static void Main()
        {
            // dims
            int h = 162;
            int w = 128;

            // read array
            float[] arrFlat = new float[h * w];
            HDFql.Execute("SELECT FROM \\path\\to\\weights.h5 \"/dense1/dense1/kernel:0\" INTO MEMORY " + HDFql.VariableTransientRegister(arrFlat));
            // reshape
            float[,] arr = new float[h, w];      // row-major
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    arr[i, j] = arrFlat[i * w + j];
                }
            }
            // show one entry
            Console.WriteLine(arr[13, 87].ToString());
            Console.WriteLine(arrFlat[13 * w + 87].ToString());
            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
예제 #2
0
 public static void Main(string [] args)
 {
     // use (i.e. open) HDF file "my-file.h5"
     HDFql.Execute("USE FILE my-file.h5");
     // select (i.e. read) attribute "foo" and populate default cursor with its data
     HDFql.Execute("SELECT FROM foo");
     // display content of default cursor
     while (HDFql.CursorNext() == HDFql.Success)
     {
         System.Console.WriteLine(HDFql.CursorGetChar());
     }
 }
예제 #3
0
    public static void Main(string [] args)
    {
        // declare variables
        double [,] data = new double[3, 3];
        int x;
        int y;

        // use (i.e. open) HDF file "test.h5"
        HDFql.Execute("USE FILE test.h5");
        // register variable "data" for subsequent use (by HDFql)
        HDFql.VariableRegister(data);
        // select (i.e. read) dataset "dset" into variable "data"
        HDFql.Execute("SELECT FROM dset INTO MEMORY " + HDFql.VariableGetNumber(data));
        // unregister variable "data" as it is no longer used/needed (by HDFql)
        HDFql.VariableUnregister(data);
        // display content of variable "data"
        for (x = 0; x < 3; x++)
        {
            for (y = 0; y < 3; y++)
            {
                System.Console.WriteLine(data[x, y]);
            }
        }
    }
예제 #4
0
    public static void Main(string [] args)
    {
        int datatype;

        // create an HDF file named "example.h5" and use (i.e. open) it
        HDFql.Execute("CREATE FILE example.h5");
        HDFql.Execute("USE FILE example.h5");
        // create an attribute named "attrib" of type float
        HDFql.Execute("CREATE ATTRIBUTE attrib AS FLOAT");
        // get datatype of attribute "attrib" and populate HDFql default cursor with it
        HDFql.Execute("SHOW DATATYPE attrib");
        // move HDFql default cursor to first position
        HDFql.CursorFirst();
        // retrieve datatype from HDFql default cursor
        datatype = (int)HDFql.CursorGetInt();
        // print message according to datatype
        if (datatype == HDFql.TinyInt || datatype == HDFql.VarTinyInt)
        {
            System.Console.WriteLine("Datatype is a char");
        }
        else if (datatype == HDFql.UnsignedTinyInt || datatype == HDFql.UnsignedVarTinyInt)
        {
            System.Console.WriteLine("Datatype is an unsigned char");
        }
        else if (datatype == HDFql.SmallInt || datatype == HDFql.VarSmallInt)
        {
            System.Console.WriteLine("Datatype is a short");
        }
        else if (datatype == HDFql.UnsignedSmallInt || datatype == HDFql.UnsignedVarSmallInt)
        {
            System.Console.WriteLine("Datatype is an unsigned short");
        }
        else if (datatype == HDFql.Int || datatype == HDFql.VarInt)
        {
            System.Console.WriteLine("Datatype is an int");
        }
        else if (datatype == HDFql.UnsignedInt || datatype == HDFql.UnsignedVarInt)
        {
            System.Console.WriteLine("Datatype is an unsigned int");
        }
        else if (datatype == HDFql.BigInt || datatype == HDFql.VarBigInt)
        {
            System.Console.WriteLine("Datatype is a long long");
        }
        else if (datatype == HDFql.UnsignedBigInt || datatype == HDFql.UnsignedVarBigInt)
        {
            System.Console.WriteLine("Datatype is an unsigned long long");
        }
        else if (datatype == HDFql.Float || datatype == HDFql.VarFloat)
        {
            System.Console.WriteLine("Datatype is a float");
        }
        else if (datatype == HDFql.Double || datatype == HDFql.VarDouble)
        {
            System.Console.WriteLine("Datatype is a double");
        }
        else if (datatype == HDFql.Char || datatype == HDFql.VarChar)
        {
            System.Console.WriteLine("Datatype is a char");
        }
        else if (datatype == HDFql.Opaque)
        {
            System.Console.WriteLine("Datatype is an opaque");
        }
        else
        {
            System.Console.WriteLine("Unknown datatype");
        }
    }
예제 #5
0
        /// <summary>
        /// Retrieves all of the image data from the .h5 file and
        /// initializes all of the data attributes.
        /// </summary>
        /// <param name="file">The .h5 file specified by the user</param>
        private void Initialize(string file)
        {
            // Get the relative path of the file since only relative paths work as of right now.
            // TODO: Make absolute paths work.
            string relativePath = GetRelativePath(file, System.IO.Directory.GetCurrentDirectory());

            fileName = file;

            // Open the .h5 file specified by the user
            HDFql.Execute("USE FILE " + relativePath);

            // Create myCursor "myCursor" and use it
            myCursor = new HDFqlCursor();
            HDFql.CursorUse(myCursor);

            string path = "";

            HDFql.Execute("SHOW DATASET LIKE {50e35494-f4dd-4122-96f8-4d47c927abe5}/resultarray/inputdata WHERE DATATYPE IS INT");
            if (HDFql.CursorNext() == HDFql.Success)
            {
                path = HDFql.CursorGetChar();
            }
            else
            {
                HDFql.Execute("SHOW DATASET LIKE inputdata WHERE DATATYPE IS INT");

                if (HDFql.CursorNext() == HDFql.Success)
                {
                    path = HDFql.CursorGetChar();
                }
                else
                {
                    HDFql.Execute("SHOW DATASET LIKE Cube/resultarray/inputdata WHERE DATATYPE IS INT");

                    if (HDFql.CursorNext() == HDFql.Success)
                    {
                        path = HDFql.CursorGetChar();
                    }
                }
            }

            // Populate cursor "myCursor" with size of dataset "example_dataset" and display it
            if (path == "{50e35494-f4dd-4122-96f8-4d47c927abe5}/resultarray/inputdata")
            {
                HDFql.Execute("USE GROUP {50e35494-f4dd-4122-96f8-4d47c927abe5}");
                HDFql.Execute("USE GROUP resultarray");
                HDFql.Execute("USE DATASET inputdata");
            }
            else if (path == "inputdata")
            {
                HDFql.Execute("USE DATASET inputdata");
            }
            else
            {
                HDFql.Execute("USE GROUP Cube");
                HDFql.Execute("USE GROUP resultarray");
                HDFql.Execute("USE DATASET inputdata");
            }

            HDFql.Execute("SHOW SIZE inputdata");
            HDFql.CursorFirst();
            Console.WriteLine("Dataset size: {0}", HDFql.CursorGetInt());

            HDFql.Execute("SHOW DIMENSION inputdata");
            HDFql.CursorFirst();
            Console.WriteLine("Dataset size: {0}", HDFql.CursorGetInt());

            // Console.WriteLine lambda count, should be 78
            HDFql.CursorFirst(null);
            lambdaCount = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;
            Console.WriteLine("inputdata dimension 0 (Λ): " + lambdaCount);

            // Console.WriteLine the the x and y dimensions of the dataset
            HDFql.CursorAbsolute(null, 2);
            int xDimension = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;

            Console.WriteLine("inputdata dimension 2 (X): " + xDimension);

            HDFql.CursorAbsolute(null, 3);
            int yDimension = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;

            Console.WriteLine("inputdata dimension 3 (Y): " + yDimension);

            // Set the size of the data array to be lambdaCount * xDimension * yDimension
            data = new float[lambdaCount, xDimension, yDimension];

            // Register variable "data" for subsequent use (by HDFql)
            HDFql.VariableRegister(data);

            // Select (y.e. read) dataset into variable "data"
            HDFql.Execute("SELECT FROM inputdata INTO MEMORY " + HDFql.VariableGetNumber(data));

            // Unregister variable "data" as it is no longer used/needed (by HDFql)
            HDFql.VariableUnregister(data);

            // Set the length and width of the textures
            imageWidth  = yDimension;
            imageHeight = xDimension;

            FindMinAndMaxValue();
        }