I'm developing a JS library with the ability to create 'flexible' neural networks. Flexible meaning that they don't consist of layers, but merely of single neurons or neuron 'groups'.
I don't want to activate neurons layer by layer, as this does not give a lot of options for layer mutation/modification.
So i'm looking for an algorithm which decides the neuron activation order. Example of a neural net:
This quite a complex net. But I want to decide the activation order of this neural network with an algorithm, ofcourse I can figure it out myself, some of the correct orders are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 2, 4, 3, 5, 6, 8, 7, 10, 9
3, 5, 8, 1, 2, 4, 6, 7, 9, 10
I need al agorithm which returns a possible activation order! Any hints?
(the algorithm is given the connections between neurons)
But it get's more complex... say we have some short term memory:
The algorithm should not take any connections that serve as memory into consideration. So these two added memory connections shouldn't alter the activation order!
Apply topological sorting to the neural network, and pretend no memory connection exists while sorting.
Related
To generate the Huffman code for given set of frequencies.
{1, 1, 2, 3, 4, 8, 12, 21}
According to my understanding we generate the huffmann code for a given problem according to the frequency (times a symbol occurs) and thus calculating the freqency so the table for the above set would be this :-
Probability Table
Then I tried to make the frequency tree but I am stuck anyone mind helping me a little bit ?
I was reading Tortoise and hare algorithm from wikipedia. I am wondering whether the python pseudocode is wrong. It seems to fail for the array: [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, ....] as at the very beginning, the two values meet and the algorithm continues to find the start of the cycle which is doomed to failure.
I understand that there is condition of i ≥ μ, should this constraint be added to the code for finding the start of the cycle?
If this constraint is added, should the algorithm terminate and return no cycle found when failed or continue for another iteration? Since what if the input is [1, 2, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, ....] ?
How does this algorithm guarantee that at the first meeting point, both pointers are inside some cycles?
The tortoise and hare algorithm runs two pointers, one at offset i and the other at offset 2i, both one-based, so initially 1 and 2, and is meant to detect cycles in linked-list-style data structures.
And, just to be clear, it compares the pointers rather than data values they point to, I'm unsure whether you understand that so, on the off-chance you didn't, I just thought I'd mention it.
The initial start point is to have the tortoise on the first element and the hare on the second (assuming they exist of course - if they don't, no loop is possible), so it's incorrect to state that they're equal at the start. The pointer value can only ever become equal if the hare cycles and therefore catches the tortoise from behind.
I'm speaking with reference to Scheduling algorithm for a round-robin tournament?.
I need to pair (or triple) a group of people into trios, in order for them to meet. For example, in a group of 9 people, the first meetings would be: [1, 2, 3], [4, 5, 6], [7, 8, 9]. Next meetings would be something like [1, 4, 7], [2, 5, 8], [3, 6, 9]. Things end when everyone has met everyone else, and we need to minimize the number of "rounds".
I'm at wit's end thinking of the solution to this. Many thanks to someone who can point me in the right direction :)
If "everyone has met everyone else" means that all pairs appear in the schedule, then this is a generalization of Kirkman's schoolgirl problem, solvable in the minimum number of rounds when there is an odd number of groups (existence of Kirkman triple systems, due to Ray-Chaudhuri and Wilson). The social golfer problem is a generalization to other group sizes, and I expect that the situation for even numbers of groups would be studied under that name.
In the (seemingly unlikely) event that "everyone has met everyone else" means that all possible groups have been used, then you want to use the construction in Baranyai's theorem to find hypergraph factors (see my previous answer on the topic for a Python implementation).
Similar questions in the database seem to be much more complicated than my example. I want to cluster 100'ish points on a line. Number of groups is irrelevant; the closeness of points is more important.
What is a term, method or algorithm to deal with this grouping problem? K-means, Hamming distance, hierarchical agglomeration, clique or complete linkage??
I've reduced two examples to bare minimum for clarification:
Simple example:
Set A = {600, 610, 620, 630} and the set of differences between its elements is diff_A = {10, 20, 30, 10, 20, 10}. I can then group as follows: {10, 10, 10}, {20, 20}, and {30}. Done.
Problematic example:
Set B = {600, 609, 619, 630} and the set of differences is diff_B = {9, 10, 11, 19, 21, 30}. I try to group with a tolerance of 1, i.e. differences that are 1 (or less) are 'similar enough' to be grouped but I get a paradox: {9, 10} AND/OR {10, 11}, {19}, {21}, and {30}.
Issue:
9 and 10 are close enough, 10 and 11 are close enough, but 9 and 11 are not, so how should I handle these overlapping groups? Perhaps this small example is unsolvable because it is symmetrical?
Why do you work on the pairwise differences? Consider the values 1, 2, 101, 102, 201, 202. Pairwise differences are 1,100,101,200,201,99,100,199,200,1,100,101,99,100,1
The values of ~200 bear no information. There is a different "cluster" inbetween. You shouldn't use them for your analysis.
Instead, grab a statistics textbook and look up Kernel Density Estimation. Don't bother to look for clustering - these methods are usually designed for the multivariate case. Your data is 1 dimensional. It can be sorted (it probably already is), and this can be exploited for better results.
There are well-established heuristics for density estimation on such data, and you can split your data on local minimum density (or simply at a low density threshold). This is much simpler, yet robust and reliable. You don't need to set a paramter such as k for k-means. There are cases where k-means is a good choice - it has origins in signal detection, where it was known that there are k=10 different signal frequencies. Today, it is mostly used for multidimensional data.
See also:
Cluster one-dimensional data optimally?
1D Number Array Clustering
partitioning an float array into similar segments (clustering)
What clustering algorithm to use on 1-d data?
I would just like to know the key differences between these two sorting methods because they are very similar and have got me confused.
For example, if I had a sorted array:
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
What would be some differences in the number of comparisons and movements between using selection and bubble sort on this sorted list.
Take a look at this, its a visual and audio representation of the behavior of different sorting algorithms. Very entertaining and educational to give you an idea how they behave.
http://www.youtube.com/watch?v=t8g-iYGHpEA
Since your list you provided is already perfectly sorted we are dealing with best case scenario for both algorthms, which is O(n) for bubble and O(n^2) for selection sort.