class SofomoreDataLogger(interfaces.BaseDataLogger):
Constructor: SofomoreDataLogger(name_prefix, modulo, append)
data logger for class CMAEvolutionStrategy.
The logger is identified by its name prefix and (over-)writes or reads according data files. Therefore, the logger must be considered as global variable with unpredictable side effects, if two loggers with the same name and on the same working folder are used at the same time.
Examples
import cma
es = cma.CMAEvolutionStrategy(...)
logger = cma.CMADataLogger().register(es)
while not es.stop():
...
logger.add() # add can also take an argument
logger.plot() # or a short cut can be used:
cma.plot() # plot data from logger with default name
logger2 = cma.CMADataLogger('just_another_filename_prefix').load()
logger2.plot()
logger2.disp()
import cma
from matplotlib.pylab import *
res = cma.fmin(cma.ff.sphere, rand(10), 1e-0)
logger = res[-1] # the CMADataLogger
logger.load() # by "default" data are on disk
semilogy(logger.f[:,0], logger.f[:,5]) # plot f versus iteration, see file header
cma.s.figshow()
Details
After loading data, the logger has the attributes xmean, xrecent,
std, f, D and corrspec corresponding to xmean,
xrecentbest, stddev, fit, axlen and axlencorr
filename trails.
| See Also | |
disp (), plot () |
| Method | __init__ |
initialize logging of data from a CMAEvolutionStrategy instance, default modulo=1 means logging with each call |
| Method | add |
append some logging data from Sofomore class instance es, if number_of_times_called % modulo equals to zero, never if modulo==0. |
| Method | initialize |
reset logger, overwrite original files, modulo: log only every modulo call |
| Method | load |
No summary |
| Method | plot |
load filename if given and plot the result. |
| Method | plot |
No summary |
| Method | plot |
No summary |
| Method | plot |
No summary |
| Method | plot |
No summary |
| Method | register |
register a Sofomore instance for logging, append=True appends to previous data logged under the same name, by default previous data are overwritten. |
| Class Variable | default |
Undocumented |
| Instance Variable | append |
append to previous data |
| Instance Variable | counter |
number of calls to add |
| Instance Variable | es |
Undocumented |
| Instance Variable | file |
Undocumented |
| Instance Variable | last |
Undocumented |
| Instance Variable | modulo |
how often to record data, allows calling add without args |
| Instance Variable | name |
Undocumented |
| Instance Variable | original |
Undocumented |
| Instance Variable | persistent |
Undocumented |
| Instance Variable | registered |
Undocumented |
| Method | _enter |
assumes that a figure is open |
| Method | _finalize |
Undocumented |
| Method | _xlabel |
Undocumented |
initialize logging of data from a CMAEvolutionStrategy
instance, default modulo=1 means logging with each call
append some logging data from Sofomore class instance es,
if number_of_times_called % modulo equals to zero, never if modulo==0.
more_data is a list of additional data to be recorded where each data entry must have the same length.
When used for a different optimizer class, this function can be (easily?) adapted by changing the assignments under INTERFACE in the implemention.
register a Sofomore instance for logging,
append=True appends to previous data logged under the same name,
by default previous data are overwritten.