Tuesday, December 30, 2014

By means of natural selection

I like Tournament selection in evolutionary algorithms. There are a lot of different selection schemes, each of which can perform better for the particular cases. However, the Tournament selection is easy to implement, flexible, and gives some chances to not very fit solutions to take part in the competition. And this selection can be easily adjusted to both minimization and maximization problems. Somewhat arguable feature is independence on the fitness values and their signs, but so far for me this is more an advantage rather than a weakness.
The necessity to cope with both minimization and maximization problems within one package/class library sometimes can be annoying, that is why, many implementations stick to only minimization problems. Leaving it to people, who use the package, to transform the fitness values, the way they find appropriate. There are many ways to make this kind of transform, but no ultimate one. However with selection methods that do not depend on the sign and the value (like Truncation or Tournament selections) this problem simply does not exist. That is why there are also a lot of packages that use these variants of selection.

Friday, January 11, 2013

Some thoughts about learning


When we learn some new subject, I believe, there are always some common properties of learning, regardless the field of the subject. Here I'll try to consider some of them to summarize the process of learning itself, using some notions from system thinking as it is greatly unites knoweldge about systems and their interactions, and of course the subject to learn is also a system. And I'll be very abstract.

So, if we want to learn the subject we may want to be aware of the following:
- The definition of the subject. It is required not only to recognize the subject, but also to recognize something, which is not a subject, to know its 'borders' and distinctive properties and features. It is also useful to know the conditions for the subject to exist (if approriate).
- Which parts constitute the subject? Sure enough every part can be quite complex, i.e. a standalone subject to learn.
- How these parts interact and relate to each other?
- How the subject interacts with other subjects, which primarily are out of scope of the study?
- What are inputs and outputs for the subject and all of its parts?
- What kind of information and materials are transferred through those inputs and outputs?

Why these are important? Because if we are really serious about learning, we can not learn only one part and ignore the others (like learning speaking without learning grammar). It is not only incomplete, but can also leads to incorrect understanding of the subject, because the subject is a system, and by throwing away some part, we are modifying this system (keep in mind system emergence feature). Sometimes it makes us unable to communicate with other people (without knowing some 'auxiliary' definitions from other fields it is generally impossible to write a proper mathematical statement).

Some examples:
1. Language learning.
Definition: usually there is no definition, but it is good to understand how the language relates to other languages, what are differences and similarities. This is usually given in most textbooks and is intuitively learned during the process.
Parts: grammar, phonetics, vocabulary, morphology, speaking, listening, writing.
Interactions: quite straightforward and common for most languages.
Other subjects (possible variant): history of language, history & geography & culture of a country. Of course it is not required to know all of these to the full extend, but at least knowing some key events and ideas is useful (and not only from the language learning point of view!).
Inputs and outputs (just a few): ears, mouth, books, video, songs, radio, talks.
Information and materials: meanings, sounds, sound waves.

2. Learning some mathematical subject (like probability or functional analysis).
Definition: should give a general picture on what kind of problems are considered by the field and by what means.
Parts: definitions, properties, theorems, proofs, rules, algorithms, exercises, open problems, applications.
Interactions: logical connections between different parts. Very crucial to understand the subject.
Other subjects: history of the subject, main contributors and their results, prerequisites, subjects that can be learned using knowledge from learning the current subject.
Inputs and outputs (just a few): timetable, locations, Internet, eyes, ears.
Information and materials: ideas, properties, specific skills (like integration), books, videos, publications, lecture notes.

3. Learning musical theory.
Definition: to know what for musical theory gives and what happens if we don't study it?
Parts: notes, intervals, chords, harmony, styles.
Interactions: straightforward.
Other subjects: history of musical theory, playing a particular instrument, musical software.
Inputs and outputs (just a few): books, Internet, ears.
Information and materials: sounds, compositions, songs.

How can we use the information like this? If we want to learn something we should attack the subject from all the possible directions, because the parts of the  subject are not independent, they overlap significantly. Thus we can generate synergistic effect, but to do this we first should know the options, otherwise it will be random and less effective. The other important thing is that learning requires memorizing and by looking at different things from various angles (like reading, listening, writing, practising) we intrinsincally repeat them.

Saturday, June 16, 2012

Meta-learning and a Concept Drift

Just some thoughts on how concept drift can appear in the meta-learning study.

When trying to learn how to learn one can formulate this problem as the problem of controlling the learning algorithm (sub-learner) by another learning algorithm (meta-learner). An approach, which emerges just at the very beginning, is to recognize some sort of regimes or modes of the sub-learner, e.g. use operators A and B in mode 1 and operators 2, 3 and 4 in  mode 2. The definition of these modes depends on the sub-learner.

For example if the sub-learner is a neuroevolutionary algorithm the modes may be:
1. Complexify network structure.
2. Simplify network structure.
3. Search the weights space using current or only slightly changing structure.

There may also be combinations of these or some other modes.

To understand in which mode the sub-learning algorithm is performing some set of mode features should be defined. Possible variant is to trace the algorithm's behaviour and recognize modes depending on the behaviour outcomes. So for NE algorithm there's a set of operators, like add/remove connection or change activations and we can log fitness changes involved by these operators for each individual in the population. Averaged influence of the operators on the Ne algorithm performance over several last generations can indicate the current mode.

However the analysis of operators' performance may be affected by the problem at hand and a good meta-learning approach should be able to deal with various problems. So for problem P1 mode 1 can be indicated by the different operators log than for some other problem P2. It is presumed that the meta-learner starts without knowing which problem the sub-learner is to solve and should make decisions on the fly based upon analysis of sub-learner performance.

Thus it is possible to define at least two possible sources of the concept drift for the meta-learning approach:
1. The concept drift due to problems swtiching (the mode1 definition changes  when the problem is changed).
2. The concept drift due to dynamical problem environment (conditions for sub-learner are changing and hence influence it's performance and operators analysis).

Friday, February 24, 2012

The NexGen Algorithms


Modern evolutionary algorithms do not learn. They can be adaptive during the search of solution, but when the run is over, they forget everything and if we re-run the problem, the algorithm starts its work from a scratch. This is normal for algorithms, but if we look at all living beings we'll see that they do not forget everything that catastrophically! Yes, single experience can be resultless, but after trying to solve some problem for hundreds and thousands times a new knowledge and experience eventually emerges. This is the way people learn to walk, speak, handle spoon and many other things. As people get older their past experience helps them to learn things easier (if these new things correlate with their experience).
From the other hand there are incremental learning algorithms, which are being more or less actively developed for the last 2 decades. Those algorithms can learn in complexifying and/or dynamic environments, which makes them more adaptive and they do not suffer that much from 'afterun amnesia'. There are certain problems though, like 'catastrophic forgetting', when after several updates algorithm totally forgets what it learned initially and starts behave in a new unexpected way. Well, that's normal for humans, it's just like if some person learned to speak English in a childhood and after living in France for years speaking in French this person forgets its first language. I believe that if catastrophic forgetting is not very fast then it's not a major problem. The larger issue here is that incremental earning algorithms usually are applicable to a certain domain only. That is they do learn something and collect past experience, but this experience is almost useless for solving other problems. So 'increamental learning' can be called something like 'temporal adaptation' and is good in its way, but still far from true learning algorithm. And, yes, increamental learning is usually for machine learning, but not for optimization.
The ultimate goal here may be in creation of the algorithms, which simply learns from any problem and extracts some general abstract regularities and rules to improve its performance for future tasks. This is closely related to the meta-learning concept and I believe that this can be done if some external trainable control system is attached to the algorithm to guide this algorithm's behaviour. This is a very amibitious task, connected with creation of very adaptive algorithms and probably one of the milestones to overcome on the way to true AI, since some implicit method 'to learn how to learn' is already built-in by evolution inside living organisms (animals can improve their skills!) and is essential for survival and for emergence of highly-organized intelligence.
There's a well-known meta-systems transition theory by V. Turchin which states that system enters a new level of development when a meta-level control system appears. For the existing evolutionary algorithms some origins of such systems can be found, like rules for adaptation or some heuristics like: if we move in the same direction, then increase movement speed; or try to cluster variables to understand their relations for proper optimization. And the next big step here is possible unification of these heuristics and adding memory fo EA, so that the algorithm could remember what problems it already solved and what were useful and useless rules. Having this memory it could be possible to recognize some common parts between problems (like, 'hmm, I solved something like this before, and I probably should apply correpondent set of optimization rules'). That may be my fantasy, and there are a lot of open questions (how to store information about problems features and compare problems of different dimensionalities etc.), but this is a real task for scientists, which probably can boost development of algorithms. That's why NexGen :)    

Tuesday, February 21, 2012

The Neuroevolution, or to Randomness and Back Again

Most researchers, who develop neuroevolutionary algorithms involving evolution of ANN structure, concentrate on creating 'smart' algorithms out-of-box. This means, that the algorithm should have some predefined constraints to prevent too fast growth of the number of nodes and connections. It's also possible to track nodes' activity, counting each node's degree or total signal, which is translated through a node. Knowing these activities can be helpful for defining, for example, which nodes to connect ('active' ones) and which to remove ('lazy' nodes)
In one of my earlier posts there was an interesting observation that average number of hidden units tend to stabilize over time if there were some rules to decide, which operation to modify ANN structure to apply. Those rules depended on current ANN topology.
The interesting question is whether we could observe this 'auto'-stabilization if no ad-hoc rules are there, guiding which operation to use to mutate ANN.
I made series of experiments for one of the simplest NE algorithms for evolving both weights and structure of ANN (including activations).
The following operators were used

  • Add Node with Default Activation (Sigmoid). Adds isolated node. This operations has no immediate effect on individual's fitness (neutral operation), but in some consequent generation this node can be advantageous. Note also that even adding connections to this node not obligatory lead to a fitness change, if there is no other node in the network that accepts output signal of a new node.
  • Remove Random Node. Removes random node regardless on the number of its connections or that ANN structure can become meaningless, when input signals are not translated onto ANN outputs. Input and output nodes can not be removed.
  • Add Random Connection. Adds connection with random weight between two randomly chosen nodes.
  • Remove Random Connection. Removes random connection from a network. If in result some node becomes isolated, then this node is removed ('dying').
  • Modify Weight. Changes weight of randomly chosen connection. The weight's delta is defined using uniform distirbution.
  • Modify Activation. Changes activation function for random node. Can not change activation for input nodes
It's easy to see that these operators do not use any heuristic rules and behave randomly. To make algorithm even more random selection of operators is made also at random. That is when some ANN undergoes mutation and the algorithm to decide mutation operator, a random operator is picked.
I've used quite a bunch of test problems
  • XOR
  • Artificial Ant
  • 1 and 2 Poles Balancing
  • 7 problems from the Proben1 set (cancer1, card1, diabetes1, glass1, heart1, horse1, thyroid1)
And here are some results. Below are plots with averaged change of average number of nodes and connections for different problems (click to enlarge).



It's easy to see, that in most problems change of nodes number is step-like and that increase of the number of hidden nodes goes slowly.
So even for the NE algorithm with simplest acting operators and pure random operators choice scheme the number of hidden nodes seems to be controllable. Thus we can conclude that ANN structure growth during evolution may be not a major problem. Surely if some rules for application of operators change then different results can be achieved.
One more interesting question is was such a random NE algorithm succesfull at solving the test problems. And the answer is partially.

Here are the solved problems (in brackets there are test set classification errors)
  • 1-Pole Balancing (100k ticks equilibrium)
  • Artificial Ant (ate all 89 pellets)
  • card1 (13,95%)
  • heart1 (21,30%)
  • horse1 (31,87%)
And the unsolved problems
  • 2-Poles
  • cancer1 (37,36%)
  • diabetes1 (36,46%)
  • glass1 (69,81%)
  • thyroid1 (97,78%)
  • XOR (66,06%)
The results for unsolved problems seem rather devastating (up to 97,78% errors), but I doubt that everything was that bad. It was a very simple NE algorithm, a lot should be done to make it work well. And moreover it's already sort of miracle that this algorithm was able to solve several problems working almost at random using only evolution for a guidance.
One of the errors with current algorithm is that for some problems the resulting ANN always fires with only one output, and all other outputs are silent. Such a network gives correct answers from time to time, but it's just like stopped clock that shows correct time twice a day. So possible solution is to add regularization term into fitness function to encourage diversity of ANN outputs. But it is a work for future research and there are some other interesting results which I'll present a bit later.

Wednesday, December 7, 2011

Gradiention Day

This is a sketch for a review on meta-heuristic tricks for learning properties of a search space. More formally, a lot of advanced (and not so much) algorithms try to figure out an information about local gradient for more efficient evolutionary search. This is surely feasible, because (ideally) the gradient shows the best direction to move towards local optimum and most numeric optimization methods use this information. The question about how to get away from a local optimum concerns another (although associated) problem and is not considered.

It's worth noting, that getting gradient info for noisy functions can be difficult and requires some statistical processing, which may result in several alternatives for the best direction (not obligatory collinear). Probably fuzzy logic could be of help here. I also assume that objective function has local trend, i.e. that for each point *there is* the best movement direction, which is at least good for some not very small neighborhood, because otherwise finding gradient doesn't make sense. One can say that this means that the function can be approximated by some smooth function with the same global optimum.

We can find 2 groups of methods, which learn gradient information:
1. Explicit gradient learning. There are formulae for gradient approximation, which are used during recombination or variation operations.
2. Implicit gradient learning. These methods simply do not tell directly that they are learning gradient, but they are sort of 'I'll-know-it-when-I-see-it'.

Examples of the first group are: EA with direction crossover and Pseudo-Gradient, CMA-ES, many real-valued EDAs and (h)BOA algorithms.

For the second group examples are: Swarm Optimization Methods, Differential Evolution.

In my opinion, the meta-heuristic method can be aknowledged as 'gradient learning' if there is sort of memory for the best movement direction.

Where are conventional real-coded EAs? In my current understanding it should be placed into the 2nd group. Here is my motivation: many EA operators do not look for gradient, but simply search for better solutions in vicinity of parent individuals. Most operators do not 'remember' good searching directions. But there is a selection, which selects in which direction the population evolves and thus follows the gradient. Probably many EAs should even be treated as 'implicitly implicit' gradient learning methods :).

Up to now only continuous spaces were considered, because gradient is natural there. What about binary spaces? Or spaces of graphs, computer programs, agents policies or neural networks? I believe that the gradient notion can still be applied there as long as there is a proper metric over the set of representations.

Recall that there's a large class of finite-difference methods, which quintify the space making it non-continous, but can still be succesfully applied for continous modelling problems. It can be also argued that one of the most used variant of the Taylor expansion has linear form from which the approximate gradient can be calculated.

So the largest problem for defining gradient in non-continous spaces is setting a good metric. By this 'good' word I mean that it should not be just everything, which satisfies metric properties, but it also should reflect the problem's properties. For example, setting metric for directed weighted graphs for TSP problem is not the same as setting metric for directed weighted graphs for evolution of neural networks. That's the issue. An interesting question: if a kind of 'approximate' metrics exists, which is metrics, but without the whole pack of desired problem dependent properties?

Monday, December 5, 2011

On representation of candidate-solutions

Recently I've come up with an idea that traditional approach for programming EAs may have a strong alternative.

In a traditional way we are dancing from the EA perspective, that is, there are individuals = candidate-solutions, they form population, which is modified by EA, consisting of various operators and a (posssibly hardcoded) scheme for their application sequence. Problem domain is somewhat alien and is communicated via fitness function. If some unusual representation of the solution is used (like Gray-coded strings for real-valued optimization problem), then genotype->phenotype transform should be made to evaluate an individual's performance. This transform is often made somewhere inside a fitness function, which means that fitness function can be divided into 2 sections:
  1. Transform of the solution to the representation, which can be evaluated, even if a single method is called.
  2. Evaluation itself.
Many implementations consider that problem lives in a problem environment, which is often convenient for control, adaptive behaviour and A-Life applications, but candidate-solutions are still are part of the EA.

We can say that here fitness function is a 'friend' for EA, which means that EA can work with any representation and the function performs all the necessary transformations itself or that individuals can convert themselves to different phenotypes (arrays, matrices, networks etc.). It's very convenient for EA, but not very convenient for the problem, we have to track whether individual can be transformed to the proper representation for fitness evaluation.

Nothing is wrong with this approach, it's good, but there's another decomposition variant.

Suppose that candidate-solutions are independent things. That is they have two sides (or faces/facets): one for EA and the other for a problem. The first side can be binary chromosome, or Lisp expression, or some graph representation, whatever the EA operators can work with. The second side is for the problem: real-valued vector, neural network, agent's policy representation, whatever the fitness function should handle.

In other words, candidate solutions are no longer parts of EA (although they can still be named individuals, particles, and so on), neither they are parts of a problem. This can be convenient for both EA and a problem, because there's no need to worry about conversions and transforms. When EA side is set, the problem's side can be updated at once, or on the first demand (implementing so called 'lazy' programming concept). If 1-to-1 mapping between genotype and phenotype exists, then this transform can be reversed and if problem's side is updated, for example by some local search algorithm, the EA side can be updated as well.

There're no miracles, it just means that all conversions are localized and they should be implemented explicitely, but neither EA nor problem's side should worry how it's done and by what means.

If genotype and phenotype are the same (real-valued EAs, direct graphs representation etc.) the individuals can be made either one-sided (I would call it 'Moebius representation' ;)) or two-sided, but with no difference between sides.

And as adopted, some pros and cons of this approach:

Pros:
  • Can appear as two distinct objects at the same time.
  • Potentially faster (because phenotype can be computed when genotype is changed)
  • More natural (genotype + phenotype)
  • Objective function does not need to support different encodings, it obtains the object it's meant to evaluate --> Easier to adapt for 3rd party applications
  • Possibly easier to parallelize because problem side representations are independent and there very small chance of their conflicts.
Cons:
  • Requires more memory, because problem-side representations are stored for each EA-side representation.
  • Adds extra interaction layer between EA and a problem.
  • Probably more code to write due to more complex structure of candidate-solutions.
  • The candidate-solutions become 'heavier'.
Anyway, I think this idea of two-sided representations is interesting.

P.S. Oh, it's possible that I've just rediscovered someone else's idea. Yeah. What if Plato was right? ;)