Hallo,
danke dir vielmals, hat wunderbar funktioniert und ich konnte so auch mehrere Fehlerquellen finden, dank sichtbarer Ausgabe.
Witzigerweise scheint mein script zu funktionieren, wenn auch mit Einschränkungen.
Aber ich habe neue Unklarheiten.
Folgendes:
Ich starte Membrain, Lasse das Script laufen, das liest beim Start NetError = -1, läuft 1mal ohne durch in die Schleife zu gehen und gibt einen ersten NetError aus.
Output = 0,1734 (Bsp)
Ich starte das script erneut, er liest den NetError Output von vorhin ein und beginnt damit.
die while Routine funktioniert und er ändert auch die Lernrate wenn er NetError kleiner wird. Das sehe ich nur an der Ausgabe der Lernrate, die Ausgabe des NetErrors ändert sich nicht, obgleich ich versucht habe, mit EvaluateNetError() den NetError immer wieder neu einzulesen.
Im Trace Fenster sieht man wunderschön, wie er durch die Anweisungen durchhüpft. Zu beginn nur die erste if Anweisung, dann immer tiefer.
Frage
Kann ich den NetError am Anfang irgendwie festlegen, dass einfach standardmäßig ein hoher Wert ist damit er losrennt?
Ich hatte versucht, am Anfang einfach "double netError = 0.5;" zu schreiben, aber das war wohl zu einfach gedacht.
der Wert netError wird anscheinend nicht laufend angepasst, und evaluateNetError() ist zwar offensichtlich im Hintergrund wichtig, weil sonst läuft das script nicht richtig, aber an der Anzeige ändert es nichts. Wo liegt die mein Fehler?
Angehängt der komplette Code vom Script (bis auf den erklärenden Text am Anfang)
Sorry wenn es offensichtlich sein sollte, ich bin Neuling was angelscript angeht.
Jedenfalls Danke für deine gestrige Hilfe, ich bin zwar immer noch verwirrt, aber auf einer höheren Ebene
Code: Select all
double LEA_RAT_START = 0.1; // The learning rate - start value, 0,01 bs 0,9 akzeptable Werte
double TAR_ERR_M1 = 0.1; // The target net error - step value - if Target Error goes below 0.1, the Learning Rate will be slower
double LEA_RAT_M1 = 0.05; // The learning rate - final value, 0,01 bs 0,9 akzeptable Werte
double TAR_ERR_M2 = 0.05; // The target net error - step value - if Target Error goes below 0.1, the Learning Rate will be slower
double LEA_RAT_M2 = 0.025; // The learning rate - final value, 0,01 bs 0,9 akzeptable Werte
double TAR_ERR_M3 = 0.03; // The target net error - step value - if Target Error goes below 0.1, the Learning Rate will be slower
double LEA_RAT_M3 = 0.011; // The learning rate - final value, 0,01 bs 0,9 akzeptable Werte
double TAR_ERR_FIN = 0.01; // The target net error - final value
// Erstellen der Variablen fuer die Trace-Ausgabe
// double TAR_ERR_CHECK;
double netError = GetNetError();
string netErrStr = "Net Err = " + netError;
string netErrStrNachEv0 = "Net Err nach Eval 0 = " + netError;
string netErrStrNachEv1 = "Net Err nach Eval 1 = " + netError;
string netErrStrFinish = "Net Err nach einem Durchlauf = " + netError;
string netErrStr1 = "Net Err 1 = " + netError;
string netErrStr2 = "Net Err 2 = " + netError;
string netErrStr3 = "Net Err 3 = " + netError;
string leaRatStart = "LEARNRATE START = " + LEA_RAT_START;
string leaRatStart1 = "LEARNRATE M1 = " + LEA_RAT_M1;
string leaRatStart2 = "LEARNRATE M2 = " + LEA_RAT_M2;
string leaRatStart3 = "LEARNRATE M3 = " + LEA_RAT_M3;
void main()
{
// Adjust the view
ViewSetting(BLACK_BG, true);
ViewSetting(SHOW_GRID, false);
ViewSetting(UPDATE_TEACH, true);
ViewSetting(UPDATE_THINK, true);
ViewSetting(SHOW_FIRE, false);
ViewSetting(SHOW_ACT_SPIKES, false);
ViewSetting(SHOW_LINKS, true);
OpenNet("V-02_2HL14.mbn"); // Open the net to be trained and validated
RandomizeNet(); // Randomize all link weights and activation thresholds.
ResetThinkSteps(); // Reset the think step counter
SetLessonCount(1); // Delete all lessons except for #1
/*
This script uses four lessons in the Lesson Editor (create them now).
As a net is already loaded the new lessons will be created in sync with the net
(same I/O names).
*/
SetLessonCount(4);
SelectLesson(1); // First operate on Lesson #1
LoadLesson("trainingdataset.mbl"); // Load training lesson
ShowLessonEditor(false); // Hide the lesson editor again to fully view the net
/*
Set the teacher to be used. This script uses the currently active teacher of MemBrain, thus, the line
is commented out. Use the name of the teacher you want to set as the active one instead here if you want to
ensure that a certain teacher is used.
*/
//SelectTeacher("Std. BP with Momentum"); // Use the teacher with the name 'BP'
//Std. BP with Momentum auf Log mit exp log auf 1 umgestellt bei hl
// Adjust the teacher
TeacherSetting(LEARNRATE, LEA_RAT_START); // The learning rate
TeacherSetting(TARGET_ERR, TAR_ERR_FIN); // The final target net error
TeacherSetting(LESSON_REPS, 1); // Lesson repetitions per teach step,
TeacherSetting(PATTERN_REPS, 1); // Pattern repetitions per teach step,
TeacherSetting(PATTERN_SELECT, RAND_ORDER); // The pattern selection method
SetTeachSpeed(0); // Set maximum teach speed
ShowErrorViewer(true); // Show the net error viewer and reset it
ResetErrorViewer();
EvaluateNetError();
Trace(netErrStrNachEv0 + "\r");
while (netError > TAR_ERR_FIN)
{
EvaluateNetError();
netError = GetNetError();
Trace(netErrStrNachEv1 + "\r");
StartTeaching(); // Start teaching and wait for stop (target error reached)
netError = GetNetError();
Trace(netErrStr + "\r");
Trace(leaRatStart + "\r");
if (TAR_ERR_M1 > netError)
{
Trace(netErrStr1 + "\r");
Trace(leaRatStart1 + "\r");
TeacherSetting(LEARNRATE, LEA_RAT_M1);
// netError = GetNetError();
if (TAR_ERR_M2 > netError)
{
Trace(netErrStr2 + "\r");
Trace(leaRatStart2 + "\r");
TeacherSetting(LEARNRATE, LEA_RAT_M2);
// netError = GetNetError();
if (TAR_ERR_M3 > netError)
{
Trace(netErrStr3 + "\r");
Trace(leaRatStart3 + "\r");
TeacherSetting(LEARNRATE, LEA_RAT_M3);
// netError = GetNetError();
}
}
}
// SleepExec();
StopTeaching();
}
EvaluateNetError();
netError = GetNetError();
Trace(netErrStrFinish + "\r");
// ShowErrorViewer(false); // Hide the error viewer again
ResetThinkSteps(); // Reset think step counter
// Now prepare lesson #3 to record the output of the net
SetRecordingType(RT_ACT); // Record activation values of output neurons
StartRecording(3); // Enable recording of data to lesson #3
ShowLessonEditor(false); // Hide the lesson editor
SetThinkSpeed(0); // 50ms between think steps for animation
// First record network reaction on training data to lesson #3
ThinkLesson(); // Think on every pattern in lesson #1 (and record to #3)
SleepExec(); // Wait until 'Think on Lesson' is finished
StopRecording(); // Deactivate recording again
SelectLesson(2); // Load lesson #2 with the validation data
// ImportLessonRaw("Decoder4To16_Validate.csv");
// Could also import a lesson (see line above but the imported file has to use country
// specific characters for list separation (; or ,) and for decimal point (. or ,)
LoadLesson("testingdataset.mbl");
EnableLessonOutData(false); // Don't need any output data, this lesson is input only
SetRecordingType(RT_ACT); // Record activation values of output neurons
StartRecording(4); // Enable recording of data to lesson #4
ShowLessonEditor(false); // Hide the lesson editor
ThinkLesson(); // Think on every pattern in lesson #2 (and record to #4)
SleepExec(); // Wait until 'Think on Lesson' is finished
StopRecording(); // Deactivate recording again
// Now export lesson #3 and 4 to csv
SelectLesson(3);
ExportLessonRaw("TrainResult_StdBPwithMomentum_Schritt_2.csv");
SelectLesson(4);
ExportLessonRaw("ValidateResult_StdBPwithMomentum_Schritt_2.csv");
SaveNet("V-04_2HL14_StdBPwithMomentum.mbn"); // the net trained and validated
// Adjust for maximum speed again
SetThinkSpeed(0);
// Uncomment the following line if you want MemBrain to terminate after the script execution
// ExitMemBrain();
}