When we want to incorporate machine learning solutions into our company, we may encounter difficulties when it comes to integrating them with our software or platforms. One solution is to use a program that allows you to run these solutions without needing installation. Neural Designer allows you to run the program without installation. This post will guide you to learn how to do it, so you can start using machine learning in your projects.

Contents:

    1. Introduction
    2. Tasks
      1. Perform training
      2. Randomize parameters
      3. Calculate outputs
      4. Perform response optimization
      5. Export write expression
      6. Export neural networks to programming language
        1. Export to PHP
        2. Export to Python
        3. Export to C
        4. Export to JavaScript
    3. How to execute NeuralEngine
      1. Ubuntu
        1. Warning
      2. Windows
    4. Output file

Introduction

To understand the following tutorial, it’s important to know some terms explained below.

Neural Designer” is the graphical environment we use to handle the model, “NeuralEngine” is the executable we call using “.ndt” files to carry out tasks, and “NeuralViewer” is responsible for displaying the results collected in the “.ndo” file.

The “.ndt” or “taskfiles”, which are also XML files that send a work order to the “neuralengine,” will have communication between these components through XML files emphasized in this post. The following section explores some tasks we can use in the NeuralEngine.

You can further your knowledge about Neural Designer in the post Neural Designer components, which explains the 3 main actors that make up the Neural Designer application and the communication between them.

Tasks

As mentioned above, the ‘neuralengine’ creates a taskfile for every action it intends to perform, outlining the specific order and considering the associated guidelines or restrictions. Knowing that, let’s analyze some of the most important tasks.

Perform training:

This task merely signals the need for training the model without altering the current specifications. The project file “.ndp” holds a dedicated section defining the training specifications, but for this scenario, it’s inconsequential as this task doesn’t modify the established settings.

Randomize parameters:

Next, we have this other task that sets random values to all the variables of the neural network. In this way, we will lose the adjustment made to the model by previous training, so the next training will have to start from 0. Therefore, we should not modify this task either.

Calculate outputs:

Thanks to this task, the neural network will calculate the output value of the neural network depending on the inputs we send it. Therefore, we must modify this task to define the input values we desire for each variable. By the standard used in the company, the input values are defined twice, first in the <Inputs> tag and then in the <InputsNames> tag. Here’s an example extracted from the demonstration provided in this article:

<NeuralDesignerTasks>
   <NeuralNetworkTask>Calculate outputs
      <Inputs>265.444;86.2852;62.7953;183.059;6.99577;956.059;764.377
      </Inputs>
      <InputsNames>265.444;86.2852;62.7953;183.059;6.99577;956.059;764.377
      </InputsNames>
   </NeuralNetworkTask>
</NeuralDesignerTasks>

Perform response optimization:

Using this last task, the “neuralengine” will find the optimal values for the variables of a process for some given conditions/restrictions. We can define these restrictions ourselves in the TaskFile using the symbols that will be specified below:

  • Used Token:: None

Meaning: This variable will not affect the process of the response optimization task.

  • Used Token:: &lt;

Meaning: “Less than”. Only the rows with a value less than the value defined for this variable are considered.

  • Used Token:: &lt;=

Meaning: “Less than or equal”. Only rows with a value less than or equal to the value defined for this variable are considered.

  • Used Token:: >

Meaning: “Greater than”. Only rows with a value greater than the value defined for this variable are considered.

  • Used Token:: >=

Meaning: “Greater than or equal”. Only rows with a value Greater than or equal to the value defined for this variable are considered.

  • Used Token:: =

Meaning: “Equal to”. Only rows with a value equal to the value defined for this variable are considered.

  • Used Token:: Between

Meaning: A range will be established, and only rows with a value between the minimum and maximum of that range are considered.

  • Used Token:: Maximize

Meaning: This variable’s value will maximized with the restrictions previously mentioned.

  • Used Token:: Minimize

Meaning: This variable’s value will minimized with the restrictions previously mentioned.

By the standard used in the company, the instructions for each variable are defined in the <Conditions> tag, then in the <Values> tag, the values for each condition are defined. Here’s an example extracted from the demonstration provided in this article:

<NeuralDesignerTasks>
 
   <NeuralNetworkTask>Perform response optimization
      <Conditions>Between None &lt; > None > None Minimize</Conditions>
      <Values>102 540 0 0 0 0 800 0 0</Values>
   </NeuralNetworkTask>
</NeuralDesignerTasks>

Export write expression

Thanks to this task, we can generate the mathematical expression corresponding to the current state of the neural network used in the model, i.e., the list of mathematical calculations the neural network makes to calculate the output based on the input. You should not modify this task.

Export neural network to programming language

Using this “task,” we can export the mathematical expression corresponding to the neural network translated to different programming languages, among which we can find C, PHP, Javascript, and Python.

The files for C and Python comprise straightforward scripts that compute the output using the neural network. However, the Javascript and PHP files differ slightly. The Javascript code is designed to create a table in HTML, visually modifying the network inputs. Conversely, the PHP code aims to be integrated as an API. This Task changes depending on the type of file generated.

Export to PHP

<NeuralDesignerTasks>
   <NeuralNetworkTask>Export to PHP
      <PHPFileName>/Your/directory/model.php
      </PHPFileName>
   </NeuralNetworkTask>
</NeuralDesignerTasks>

Export to Python

<NeuralDesignerTasks>
   <NeuralNetworkTask>Export to Python
      <PythonFileName>/Your/directory/model.py
      </PythonFileName>
   </NeuralNetworkTask>
</NeuralDesignerTasks>

Export to C

<NeuralDesignerTasks>
   <NeuralNetworkTask>Export to C
      <CfileName>/Your/directory/model.c
      </CFileName>
    </NeuralNetworkTask>
</NeuralDesignerTasks>

Export to JavaScript

<NeuralDesignerTasks>
   <NeuralNetworkTask>Export to JavaScript
       <JavaScriptFileName>/Your/directory//model.html
       </JavaScriptFileName>
    </NeuralNetworkTask>
</NeuralDesignerTasks>

How to execute NeuralEngine

Now that we have defined and explained the “Tasks”, let’s move on to the section where we will explain the instructions to execute the “NeuralEngine” depending on the operating system.

Ubuntu

First, a folder stores the project files, tasks, and necessary libraries to avoid dependency problems. The folder consists of three subdirectories and one document, and for this specific example, we will call it Linux:

  • neuralengine: In this folder, the executable and the libraries that avoid dependency problems are stored.
  • project: Here is stored both the project file “.ndp” and all other related files: “.csv”, “ndo”,…
  • tasks: Finally, this directory will host the different tasks that will later be used to give different execution commands to the engine.
  • run_neuralengine.sh: This bash/shell script will launch the neuralengine when executed. (It must have run permissions to be launched).

The folder will look like this:

To make things simpler, we have created a small demo, and you can download it at the following link:

Linux_demo

You can modify the project folder to work on the desired project while modifying the task folder to add the desired tasks. Still, to avoid execution problems, you should not modify the NeuralEngine directory.

Now that the working directory is ready follow the instructions below to get a correct execution:

  • First, copy the path of the linux folder provided for this demo, for example:

“/home/Artelnics/demo”.

  • Then execute this command using the command line terminal:

Artelnics@artelnics:/home$ cd /home/Artelnics/demo/linux.

(You can also open the command line terminal inside the “linux” directory to bypass this initial step.)

  • As mentioned earlier, we require certain libraries to run the “neuralengine”; so for this to be not a problem, the script “run_neuralengine.sh” we have created. Which executes the file without dependency problems.

If you open “run_neuralengine.sh” with a text editor, you will find 4 lines with four different commands. Next, simply remove the “#” symbol to uncomment the command you wish to execute upon launching “run_neuralengine.sh”:

#$N_DIR/neuralengine project/domo.ndp tasks/training_task.ndt 1

#$N_DIR/neuralengine project/domo.ndp tasks/randomize_parameters.ndt 1

#$N_DIR/neuralengine project/domo.ndp tasks/calculate_outputs_task.ndt 1

#$N_DIR/neuralengine project/domo.ndp tasks/perform_response_optimization.ndt 1

The command’s syntax is “Path/to/neuralengine Path/to/ProjectFile Path/to/TaskFile 1”. With this, we ask the engine to execute the task specified in the TaskFile to get the desired output  (TaskFiles will be explained in the next section). Only these tasks are mentioned in this example, but all the tasks specified in the previous section can be used.

  • Once we have uncommented the desired command, we will execute the following line   using the previously opened command line terminal:

Artelnics@artelnics:~demo/linux$ sudo run_neuralengine.sh

Warning

If during the execution of “run_neuralengine.sh” an error similar to “segmentation fault (core dumped)” occurs, try deleting the files inside the folder “neuralengine/x86_64-linux-gnu/” and relaunch the program.

Windows

First, a folder stores the project files, tasks, and necessary libraries to avoid dependency problems. The folder consists of three subdirectories and one document, and for this specific example, we will call it win64:

  • neuralengine: This folder stores the executable and libraries designed to circumvent dependency issues.
  • project: This location houses both the project file “.ndp” and all other associated files such as “.csv”, “ndo”,…
  • tasks: Ultimately, this directory serves as the repository for various tasks, which will later be utilized to provide diverse execution commands to the engine.

The folder will look like this:

To make things simpler, we have created a small demo, and you can download it at the following link:

Demo_win64

You can modify the project folder to work on the desired project while modifying the task folder to add the desired tasks. Still, to avoid execution problems, you should not modify the NeuralEngine directory.

Now that the working directory is ready follow the instructions below to get a correct execution:

  • First, copy the path of the win64 folder provided for this demo; for example:

C:sersersersArtelnicsDesktopwin64″.

  • Then execute this command using the command line terminal:

C:Yourdirectory> cd C:UsersArtelnicsDesktopwin64>.

  • Now, using the same command line, we can use the following commands to execute different tasks:

C:\UsersArtelnics\Desktop\win64>neuralengine\neuralengine.exe project/domo.ndp tasks/training_task.ndt 1

C:\UsersArtelnics\Desktop\win64>neuralengine\neuralengine.exe project/domo.ndp tasks/randomize_parameters.ndt 1

C:\UsersArtelnics\Desktop\win64>neuralengine\neuralengine.exe project/domo.ndp tasks/calculate_outputs_task.ndt 1

C:\UsersArtelnics\Desktop\win64>neuralengine\neuralengine.exe project/domo.ndp tasks/perform_response_optimization.ndt 1

Following the instructions given for Ubuntu, the command syntax used on Windows is     “Path/to/neuralengine Path/to/ProjectFile Path/to/TaskFile 1”. With this, we ask the engine to execute the task specified in the TaskFile to modify the ProjectFile (TaskFiles will be explained in the next section). Only these tasks are mentioned in this example, but all the tasks specified in the previous section can be used.

Output file:

The project file, “.ndp,” links to this file, which contains the output generated by each task. Each time a task runs, it stores the output displayed in the command line terminal into the “.ndo” file, also known as the output file. If, for any reason, all the generated outputs should be discarded and the text that has been accumulated in the “.ndo” file should be deleted, the <NeuralDesignerOutput> and </NeuralDesignerOutput> tags must be kept to maintain the correct functioning of the neuralengine.

Primera imagen
==>
==>
==>
Segunda imagen

Related Posts