mlp_
Download scriptThis script serves as a diagnostic utility designed to visualize the internal structural framework of a Multi-Layer Perceptron (MLP), which is a type of artificial neural network. Rather than executing trades or performing live market analysis, this program acts as a "blueprint viewer" that identifies the connections between different layers of the neural model.
The logic follows these specific steps:
Core Architecture Visualization
The primary purpose of the script is to map out the "weights" within the neural network. In machine learning, weights represent the strength of the relationship between different points of data. The script organizes these into two distinct categories to show how information flows through the system:
- Input to Hidden Layer Connections: The script identifies the connections between the raw input data (the initial market signals) and the hidden neurons (the internal processing units). By listing these, it shows how the "raw" data is being distributed into the network's internal brain.
- Hidden Layer to Output Connections: The script then maps the relationship between those same hidden neurons and the final outputs (the resulting predictions or signals). This illustrates how the processed information is eventually distilled into a final result.
Operational Workflow
When the script is activated on a chart, it performs the following sequence:
- Initialization: It clears any existing visual data to prepare for a fresh display.
- Mapping Process: The program runs through a series of loops that systematically visit every connection point in the network's architecture. It treats the neural network like a grid, visiting each "bridge" between neurons one by one.
- Data Compilation: For every connection found, it builds a text string representing the specific coordinate of that weight (e.g., identifying exactly which input connects to which hidden neuron).
- On-Screen Display: Finally, the script compiles all these coordinates into a comprehensive list and displays them directly on the trading chart.
In summary, this tool provides a clear, text-based map of a neural network's internal wiring, allowing a user to see exactly how many connections exist between the input signals, the hidden processing layers, and the final outputs.
//+------------------------------------------------------------------+
//| mlp_.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#define IN 2
#define IN1 3 //IN+1
#define OUT 2
#define N_HU 3
#define N_HU1 4 //N_HU + 1
string m1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
m1="";
PrintMLPInStr();
Comment(m1);
//----
return(0);
}
//+------------------------------------------------------------------+
void PrintMLPInStr()
{
int i, j;
// weights between hidden neurons and inputs
m1=m1+"\nweights between hidden neurons and inputs:\n";
for (i = 0; i<IN1; i++)
{
for (j = 0; j< N_HU1; j++)
{
//w1[j][i] = Random(-1.0, 1.0);
m1=m1+" w1["+j+"]["+i+"]";
}
m1=m1+"\n";
}
// weights between outputs and hidden neurons
m1=m1+"\nweights between outputs and hidden neurons:\n";
for (i = 0; i<OUT; i++)
{
for (j = 0; j< N_HU1; j++)
{
//w2[i][j] = Random(-1.0, 1.0);
m1=m1+" w2["+i+"]["+j+"]";
}
m1=m1+"\n";
}
}
Comments