Candidate Utilities
NaiveGAflux.CandidateModel
— TypeCandidateModel <: Candidate
CandidateModel(model)
A candidate model which can be accessed by model(c)
for CandidateModel c
.
NaiveGAflux.CandidateOptModel
— TypeCandidateOptModel <: AbstractCandidate
CandidateOptModel(optimiser, candidate; checkimplicit=true)
A candidate adding an optimiser to another candidate. The optimiser is accessed by [opt(c)
] for CandidateOptModel c
.
Usecheckimplicit=false
` to avoid consistenty checks for implicit optimiser state (e.g. NaiveNASflux.AutoOptimiser).
NaiveGAflux.CandidateDataIterMap
— TypeCandidateDataIterMap{T<:AbstractIteratorMap, C<:AbstractCandidate}
CandidateDataIterMap(itermap::AbstractIteratorMap, c::AbstractCandidate)
Maps training and validation data iterators using iteratormap
for the wrapped candidate c
.
Useful for searching for hyperparameters related to training and validation data, such as augmentation and batch size.
While one generally don't want to augment the validation data, it is useful to select the largest possible batch size for validation for speed reasons.
NaiveGAflux.FittedCandidate
— TypeFittedCandidate{F, C} <: AbstractWrappingCandidate
FittedCandidate(c::AbstractCandidate, fitnessvalue, generation)
FittedCandidate(c::AbstractCandidate, fitnessfun::AbstractFitness, generation)
An AbstractCandidate
with a computed fitness value. Will compute the fitness value if provided an AbstractFitness
.
Basically a container for results so that fitness does not need to be recomputed to e.g. check stopping conditions.
Also useful for fitness smoothing, e.g. with EwmaFitness
as it gives access to previous fitness value.
NaiveGAflux.FileCandidate
— TypeFileCandidate <: AbstractWrappingCandidate
FileCandidate(c::AbstractCandidate)
Keeps c
on disk when not in use and just maintains its DRef
.
Experimental feature. May not work as intended!
NaiveGAflux.MapCandidate
— TypeMapCandidate{T, F}
MapCandidate(mutations, mapothers::F)
Return a callable struct which maps AbstractCandidate
s to new AbstractCandidate
s through mutations
which is a tuple of AbstractMutation
s or AbstractCrossover
s.
Basic purpose is to combine multiple mutations operating on different types into a single mapping function which creates new candidates from existing candidates.
When called as a function with an AbstractCandidate c
as input, it will map fields f
in c
(recursively through any wrapped candidates of c
) satisfying typeof(f) <: MT
through m(f)
where m <: AbstractMutation{MT}
in mutations
.
All other fields are mapped through the function mapothers
(default deepcopy
).
For instance, if e = MapCandidate(m1, m2)
where m1 isa AbstractMutation{CompGraph}
and m2 isa AbstractMutation{Optimisers.AbstractRule}
then e(c)
where c
is a CandidateOptModel
will create a new CandidateOptModel
where the new model is m1(model(c))
and the new optimiser is m2(opt(c))
When called as a function with a tuple of two AbstractCandidate
s as input it will similarly apply crossover between the two candidates, returning two new candidates.
Note that all mutations
must be either AbstractMutation
s or AbstractCrossover
s as the resulting function either works on a single candidate or a pair of candidates.
Furthermore, all mutations
must operate on different types, i.e there must not be two AbstractMutation{T}
(or AbstractCrossover{T}
) for any type T
.
Intended use is together with EvolveCandidates
.
NaiveGAflux.Population
— Typestruct Population{N, P}
Population(gen, members)
Population(members)
Basic population type which just adds generation counting to its members.
Evolving the population returns a new Population
with the generation counter incremented.
NaiveGAflux.model
— Functionmodel(c::AbstractCandidate; [default])
Return the model of candidate c
if c
has a model, default
(which defaults to nothing
) otherwise.
model(f, c::AbstractCandidate; [default])
Return the result of f(
[model(c; default)
])
.
NaiveGAflux.opt
— Functionopt(c::AbstractCandidate; [default])
Return the optimiser of candidate c
if c
has an optimiser, default
(which defaults to nothing
) otherwise.
NaiveGAflux.lossfun
— Functionlossfun(c::AbstractCandidate; [default])
Return the loss function of candidate c
if c
has a lossfunction, default
(which defaults to nothing
) otherwise.