void BuildNetwork()
    {
        net = new Noedify.Net();

        /* Input layer */
        Noedify.Layer inputLayer = new Noedify.Layer(
            Noedify.LayerType.Input, // layer type
            2,                       // input size
            "antenas layer"          // layer name
            );
        net.AddLayer(inputLayer);

        // Hidden layer 1
        Noedify.Layer hiddenLayer0 = new Noedify.Layer(
            Noedify.LayerType.FullyConnected,   // layer type
            150,                                // layer size
            Noedify.ActivationFunction.Sigmoid, // activation function
            "fully connected 1"                 // layer name
            );
        net.AddLayer(hiddenLayer0);

        /* Output layer */
        Noedify.Layer outputLayer = new Noedify.Layer(
            Noedify.LayerType.Output,           // layer type
            2,                                  // layer size
            Noedify.ActivationFunction.Sigmoid, // activation function
            "output layer"                      // layer name
            );
        net.AddLayer(outputLayer);

        net.BuildNetwork();
    }
    void BuildModel()
    {
        net = new Noedify.Net();

        /* Input layer */

        Noedify.Layer inputLayer = new Noedify.Layer(
            Noedify.LayerType.Input2D, // layer type
            new int[2] {
            28, 28
        },                // input size
            1,            // # of channels
            "input layer" // layer name
            );
        net.AddLayer(inputLayer);

        // Hidden layer 1
        Noedify.Layer hiddenLayer0 = new Noedify.Layer(
            Noedify.LayerType.Convolutional2D, // layer type
            inputLayer,                        // input to layer
            new int[2] {
            4, 4
        },                       // filter size
            new int[2] {
            2, 2
        },                                   // stride
            8,                               // # of filters
            new int[2],
            Noedify.ActivationFunction.ReLU, // activation function
            "convolutional 1"                // layer name
            );
        net.AddLayer(hiddenLayer0);

        // Hidden layer 2
        Noedify.Layer hiddenLayer1 = new Noedify.Layer(
            Noedify.LayerType.FullyConnected, // layer type
            100,
            Noedify.ActivationFunction.Sigmoid,
            "fully connected 1" // layer name
            );
        net.AddLayer(hiddenLayer1);

        // Output layer
        Noedify.Layer outputLayer = new Noedify.Layer(
            Noedify.LayerType.Output,           // layer type
            no_labels,                          // layer size
            Noedify.ActivationFunction.Sigmoid, // activation function
            "output layer"                      // layer name
            );
        net.AddLayer(outputLayer);

        net.BuildNetwork();
    }
Exemple #3
0
    void BuildModel()
    {
        net = new Noedify.Net();

        /* Input layer */

        Noedify.Layer inputLayer = new Noedify.Layer(
            Noedify.LayerType.Input2D, // layer type
            new int[2] {
            28, 28
        },                // input size
            1,            // # of channels
            "input layer" // layer name
            );
        net.AddLayer(inputLayer);

        // Hidden layer 1
        Noedify.Layer hiddenLayer0 = new Noedify.Layer(
            Noedify.LayerType.FullyConnected, // layer type
            200,
            Noedify.ActivationFunction.Sigmoid,
            "fully connected 1" // layer name
            );
        net.AddLayer(hiddenLayer0);

        // Output layer
        Noedify.Layer outputLayer = new Noedify.Layer(
            Noedify.LayerType.Output,           // layer type
            no_labels,                          // layer size
            Noedify.ActivationFunction.SoftMax, // activation function
            "output layer"                      // layer name
            );
        net.AddLayer(outputLayer);

        net.BuildNetwork();
    }
Exemple #4
0
    Noedify.Net BuildAndImportModel()
    {
        modelImportComplete = false;
        int no_labels = 10;

        bool importTensorflowModel = false;

        net = new Noedify.Net();

        // Attempt to load network saved as a binary file
        // This is much faster than importing form a parameters file
        bool status = net.LoadModel("Noedify-Model_Digit_Drawing_Test");

        if (status == false)
        {
            print("Binary file not found. Importing Tensorflow parameters.");
            importTensorflowModel = true;
        }
        // If the binary file doesn't exist yet, import the parameters from the Tensorflow file
        // This is slower, so we will save the network as a binary file after importing it
        if (importTensorflowModel)
        {
            /* Input layer */
            Noedify.Layer inputLayer = new Noedify.Layer(
                Noedify.LayerType.Input2D, // layer type
                new int[2] {
                28, 28
            },                // input size
                1,            // # of channels
                "input layer" // layer name
                );
            net.AddLayer(inputLayer);

            // Hidden layer 0
            Noedify.Layer hiddenLayer0 = new Noedify.Layer(
                Noedify.LayerType.FullyConnected,   // layer type
                600,                                // layer size
                Noedify.ActivationFunction.Sigmoid, // activation function
                "fully connected 1"                 // layer name
                );
            net.AddLayer(hiddenLayer0);

            // Hidden layer 2
            Noedify.Layer hiddenLayer1 = new Noedify.Layer(
                Noedify.LayerType.FullyConnected,   // layer type
                300,                                // layer size
                Noedify.ActivationFunction.Sigmoid, // activation function
                "fully connected 2"                 // layer name
                );
            net.AddLayer(hiddenLayer1);

            // Hidden layer 2
            Noedify.Layer hiddenLayer2 = new Noedify.Layer(
                Noedify.LayerType.FullyConnected,   // layer type
                140,                                // layer size
                Noedify.ActivationFunction.Sigmoid, // activation function
                "fully connected 3"                 // layer name
                );
            net.AddLayer(hiddenLayer2);

            /* Output layer */
            Noedify.Layer outputLayer = new Noedify.Layer(
                Noedify.LayerType.Output,           // layer type
                no_labels,                          // layer size
                Noedify.ActivationFunction.Sigmoid, // activation function
                "output layer"                      // layer name
                );
            net.AddLayer(outputLayer);

            net.BuildNetwork();

            status = NSAI_Manager.ImportNetworkParameters(net, "FC_mnist_600x300x140_parameters");
            if (status)
            {
                print("Successfully loaded model.");
            }
            else
            {
                print("Tensorflow model load failed. Have you moved the \"...Assets/Noedify/Resources\" folder to: \"...Assets/Resources\" ?");
                print("All model parameter files must be stored in: \"...Assets/Resources/Noedify/ModelParameterFiles\"");
                return(null);
            }
            net.SaveModel("Noedify-Model_Digit_Drawing_Test");
            print("Saved binary model file \"Noedify-Model_Digit_Drawing_Test\"");
        }
        solver = Noedify.CreateSolver();
        solver.suppressMessages = true;
        modelImportComplete     = true;
        return(net);
    }