Transfer stored data from the internal logger memory to the logging target
Log Data to Disk in a Custom Training Loop
This example shows how to log data to disk when training an agent using a custom training loop.
flgr = rlDataLogger();
Set up the logger object. This operation initializes the object performing setup tasks such as, for example, creating the directory to save the data files.
Within a custom training loop, you can now store data to the logger object memory and write data to file.
For this example, store random numbers to the file logger object, grouping them in the variables
Context2. When you issue a write command, a MAT-file corresponding to an iteration and containing both variables is saved with the name specified in
flgr.LoggingOptions.FileNameRule, in the folder specified by
for iter = 1:10 % Store three random numbers in memory % as elements of the variable "Context1" for ct = 1:3 store(flgr, "Context1", rand, iter); end % Store a random number in memory % as the variable "Context2" store(flgr, "Context2", rand, iter); % Write data to file every 4 iterations if mod(iter,4)==0 write(flgr); end end
Clean up the logger object. This operation performs clean up tasks like for example writing to file any data still in memory.
Introduced in R2022b