LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
Build a neural network in 7 steps
In this tutorial we build a neural network that
approximates a function defined by a set of data
points.
The data for this application can be obtained from the
data.csv file.
To solve this application, the next steps are followed:
1. Create approximation project.
2. Configure data set.
3. Set network architecture.
4. Train neural network.
5. Improve generalization performance.
6. Test results.
7. Deploy model.
1. Create approximation project
Open Neural Designer.
The start page is shown.
Email us
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
Click on the button New approximation project.
Save the project file in the same folder as the data
file.
The main view of Neural Designer is shown.
2. Configure data set
In the Data set page, click on the Import data file
button.
A file chooser dialog will appear.
Select the file "data.csv".
Click on the Finish button.
The program loads the data and sets the default
configuration.
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
This data set has 2 variables and 50 samples.
We define the use of the variables:
-The first column represents the independent variable,
or input variable, x.
-The second column represents the dependent
variable, or target variable, y.
We leave that default values.
Then we define the use of the instances:
-60% of the data is used for training.
-20% of the data is used for selection.
-20% of the data is used for testing.
We leave that default values.
Once the data set is configured, we can run some
dataset analysis related tasks.
For instance, in the Task Manager, click on Data set>
Plot scatter chart.
The viewer window will appear with a chart of the
data.
As we can see the shape of this data is a sinus
function.
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
In any project, the quality of the data must be checked
by running different data set tasks.
3. Set network architecture
Click on the Neural network tab to configure the
approximation model.
The next screenshot shows this page.
The Perceptron layers section is the most important
one here.
By default, the number of layers is 2 (hidden layer and
output layer).
By default, the hidden layer has 3 neurons with
hyperbolic tangent activation function.
LEARN
As we have 1 target (y), the Coutput
O M PA N Y
layer Lmust
OGIN
haveF R1E E TRIAL
neuron. The default activation function here is the
linear activation function. BLOG SOLUTIONS PRODUCTS
We leave that default values.
To visualize the network architecture, click on Task
manager> Neural network> Report neural network.
The viewer window will appear with a graph of the
network architecture.
4. Train neural network
In the Training strategy page the information about the
error method and the optimization algorithm is set.
The next figure shows this page.
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
The normalized squared error is the default error
method. A regularization term is also added here.
The quasi-Newton method is the default optimization
algorithm.
We leave that default values.
The most important task is the so-called Perform
training, which appears in the list of Training strategy
tasks from the Task manager.
Running that task, the optimization algorithm
minimizes the loss index, i.e., makes the neural
network to fit the data set.
The following figure shows the results from the
Perform training task in the Viewer window.
In the figure above we can see the training results and
LEARN
how both the training (blue)Cand
O M PA N Y LOGIN
selection (orange)F R E E TRIAL
errors decrease during the training process.
BLOG SOLUTIONS PRODUCTS
5. Improve generalization performance
The model selection tab shows the options that allow
to configure the model selection process.
The next image shows the content of this page.
Incremental order and growing inputs are the default
options for Order selection and Inputs selection
respectively.
Since there is only one input, Inputs selection won´t be
needed.
To perform the Order selection, double click on Task
manager> Model selection> Perform order selection
We leave the default values.
The figure below shows the Viewer windows with the
results of this task.
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
As we can see, a optimal network architecture has
been defined after performing the Order selection
task.
This redefined neural network is already trained.
6. Test results
There are several tasks to test the model that has
been previously trained. These tasks are grouped
under Testing analysis in the Task manager.
To test this model, double click on Task manager>
Testing analysis> Perform linear regression analysis
The next figure shows the results of this task.
LEARN C O M PA N Y LOGIN FREE TRIAL
BLOG SOLUTIONS PRODUCTS
The correlation, as we can observe in the table shown
in the Viewer, is very close to 1, so we can say the
model is predicting well.
7. Deploy model
Once the model has been tested, it is ready to make
predictions. The tasks for this purpose are found
under Model deployment in the Task manager.
Double click on Task manager> Model deployment>
Plot directional output to see the variation of the
outputs as a function of a single input.
The picture below shows the results after performing
LEARN C O M PA N Y LOGIN FREE TRIAL
this task.
BLOG SOLUTIONS PRODUCTS
Model deployment tasks also include the option of
writing the expression of the predictive model, in
addition to exporting this expression to Python or R.
The Python code corresponding to this model is
presented below.
#!/usr/bin/python
from math import tanh
def expression(inputs) :
if type(inputs) != list:
print('Argument must be a list')
exit()
if len(inputs) != 1:
print('Incorrect number of inputs')
exit()
x=inputs[0]
scaled_x = 2*(x+3.14159)/(3.14159+3.14159)-1
y_1_1 = tanh (-0.0888747+ (scaled_x*1.54341))
y_1_2 = tanh (0.236827+ (scaled_x*-0.565758))
scaled_y = tanh (-2.08255+ (y_1_1*6.22222)+ (y_1_2*11
LEARN C O M PA N Y LOGIN FREE TRIAL
y = (0.5*(scaled_y+1.0)*(1.57046+0.971189)-0.971189)
return y BLOG SOLUTIONS PRODUCTS
To learn more see the next example:
Classification of iris flowers from sepal and
petal dimensions.
Start Building Your AI
Models
Today With the Free
Trial
Get Neural Designer Now
Do you need help? Contact us | Legal notice | © 2020, Artificial
Intelligence Techniques, Ltd.
Subscribe to our Newsletter