Encog Command Line

From Encog Machine Learning Framework
Jump to: navigation, search

The Encog Command Line utility can be used to perform many Encog operations from the command line. It is a C# application designed for the Microsoft Windows operating system. It is distributed as EncogCmd.exe. The typical format for calling this utility is as follows.

EncogCmd [command] [arg1] [arg2] [argx] [-setting1:value] [-setting2:value] [-settingx:value]

The following commands are available:

  • wizard
  • analyst
  • csv2egb
  • egb2csv
  • train
  • create
  • evaluate

XOR Example

To see how to create an XOR example, using only the Encog Command Line perform the following steps. First, create a neural network with 2 input neurons and one output neurons. This network will be created into the file net.eg. This is done with the following command.

c:\test>EncogCmd create net.eg feedforward "2:B->SIGMOID->4:B->SIGMOID->1"

Now create a text file, in the same directory, named xor.csv. This file should have the following contents.

0,0,0
0,1,1
1,0,1
1,1,0

This file must be converted to a binary training file(*.egb). This can be done with the following command.

C:\test>EncogCmd csv2egb xor.csv xor.egb
Encog 3.0.0(32-bit) Command Line Utility
Copyright 2011 by Heaton Research, Inc. Released under the Apache License

Executing command: csv2egb
Enter value for [headers] (default=True): f
Enter value for [inputCount] (default=0): 2
Enter value for [outputCount] (default=0): 1
Enter value for [format] (default=decpnt|comma):
0 : Importing to binary file: xor.egb
0 : Done importing to binary file: xor.egb
Done.  Runtime was 00:00:00 (253ms).

C:\test>

Now that the training file is ready, we can train the network. The following command trains the network. We are going to train using Resilient Propagation to an error of 1%.

C:\test>EncogCmd train net.eg xor.egb
Encog 3.0.0(32-bit) Command Line Utility
Copyright 2011 by Heaton Research, Inc. Released under the Apache License

Executing command: train
Enter value for [type] (default=rprop):
Enter value for [args] (default=):
Enter value for [maxError] (default=0.01):
Beginning training...
Iteration #1 Error:29.279649% Target Error: 1.000000%
Iteration #2 Error:26.941811% Target Error: 1.000000%
Iteration #3 Error:25.532748% Target Error: 1.000000%
Iteration #4 Error:25.426521% Target Error: 1.000000%
Iteration #5 Error:25.374336% Target Error: 1.000000%
Iteration #6 Error:24.972098% Target Error: 1.000000%
Iteration #7 Error:24.760695% Target Error: 1.000000%
Iteration #8 Error:24.571377% Target Error: 1.000000%
Iteration #9 Error:24.197759% Target Error: 1.000000%
Iteration #10 Error:23.778488% Target Error: 1.000000%
...
Iteration #58 Error:1.352527% Target Error: 1.000000%
Iteration #59 Error:1.185736% Target Error: 1.000000%
Iteration #60 Error:1.128403% Target Error: 1.000000%
Iteration #61 Error:1.041876% Target Error: 1.000000%
Iteration #62 Error:0.923030% Target Error: 1.000000%
Saving machine learning method
Done.  Runtime was 00:00:00 (179ms).

C:\test>

We would now like to evaluate the output from this neural network. We will feed the training data back into the network and observe the output. This can be done with the following commands.

C:\test>EncogCmd evaluate net.eg xor.csv out.csv

Encog 3.0.0(32-bit) Command Line Utility
Copyright 2011 by Heaton Research, Inc. Released under the Apache License

Executing command: evaluate
Enter value for [headers] (default=True): f
Enter value for [format] (default=decpnt|comma):
1 : Analyzing
4/4 : Done analyzing
1/4 : Processing
4/4 : Done processing
Done evaluating file.
Done.  Runtime was 00:00:00 (0ms).

C:\test>

If you examine the contents out out.csv you will see the following output.

"input:0","input:1","ideal:0","output:0"
0,0,0,0.0641317457
0,1,1,0.917184219
1,0,1,0.9095793007
1,1,0,0.1162775545

As you can see the first and last lines are near zero, whereas the middle two lines are near one. This is the expected output for the XOR function.

Personal tools