Open calumroy opened 7 years ago
Looking at just the functions in the np_temporal pooler for the same HTM network:
93155 function calls in 0.060 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
18414 0.018 0.000 0.052 0.000 np_temporal.py:149(checkColBursting)
1 0.008 0.008 0.060 0.060 np_temporal.py:364(updateProximalTempPool)
37851 0.032 0.000 0.032 0.000 np_temporal.py:94(checkCellActive)
18429 0.001 0.000 0.001 0.000 {len}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
30 0.000 0.000 0.000 0.000 {min}
18429 0.002 0.000 0.002 0.000 {range}
8705 function calls in 0.010 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 fromnumeric.py:823(argsort)
10 0.000 0.000 0.000 0.000 np_temporal.py:116(setLearnCell)
3069 0.003 0.000 0.003 0.000 np_temporal.py:126(checkCellPredict)
2046 0.001 0.000 0.005 0.000 np_temporal.py:139(checkCellActivePredict)
10 0.000 0.000 0.000 0.000 np_temporal.py:168(segmentNumSynapsesActive)
1 0.000 0.000 0.000 0.000 np_temporal.py:193(getBestMatchingSegment)
1 0.000 0.000 0.000 0.000 np_temporal.py:262(findLeastUsedSeg)
1 0.000 0.000 0.000 0.000 np_temporal.py:280(getPrev2NewLearnCells)
1 0.000 0.000 0.000 0.000 np_temporal.py:336(newRandomPrevActiveSynapses)
1 0.002 0.002 0.010 0.010 np_temporal.py:428(updateDistalTempPool)
14 0.000 0.000 0.000 0.000 np_temporal.py:84(checkCellLearn)
3078 0.003 0.000 0.003 0.000 np_temporal.py:94(checkCellActive)
3 0.000 0.000 0.000 0.000 numeric.py:476(asanyarray)
10 0.000 0.000 0.000 0.000 random.py:293(sample)
3 0.000 0.000 0.000 0.000 shape_base.py:113(atleast_3d)
1 0.000 0.000 0.000 0.000 shape_base.py:319(dstack)
68 0.000 0.000 0.000 0.000 {len}
13 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'argsort' of 'numpy.ndarray' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
10 0.000 0.000 0.000 0.000 {method 'random' of '_random.Random' objects}
1 0.000 0.000 0.000 0.000 {method 'ravel' of 'numpy.ndarray' objects}
3 0.000 0.000 0.000 0.000 {numpy.core.multiarray.array}
1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.concatenate}
1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.unravel_index}
356 0.000 0.000 0.000 0.000 {range}
The function (checkColBursting) in the function (updateProximalTempPool) is taking significantly longer then the rest of the class ~0.052 seconds.
This function could be deleted if we just added as an input to the updateProximalTempPool which columns are bursting. Other calculators such as the np_activeCells sets the columns into the bursting state. It could also store which columns are bursting and pass this to the np_learning calculator.
Alternatively we could implement a theano_temporal calculator but this will take some time and may not give as big of a speed improvement as desired.
An input was added to the function updateProximalTempPool so the columns bursting times don't have to be recalculated. This has doubled the speed of this function.
17832 function calls in 0.032 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
17391 0.003 0.000 0.003 0.000 np_temporal.py:149(checkColBursting)
1 0.028 0.028 0.032 0.032 np_temporal.py:357(updateProximalTempPool)
17 0.000 0.000 0.000 0.000 {len}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
405 0.000 0.000 0.000 0.000 {min}
17 0.000 0.000 0.000 0.000 {range}
8662 function calls in 0.010 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 fromnumeric.py:823(argsort)
15 0.000 0.000 0.000 0.000 np_temporal.py:116(setLearnCell)
3069 0.003 0.000 0.003 0.000 np_temporal.py:126(checkCellPredict)
2046 0.001 0.000 0.005 0.000 np_temporal.py:139(checkCellActivePredict)
1 0.000 0.000 0.000 0.000 np_temporal.py:273(getPrev2NewLearnCells)
1 0.003 0.003 0.010 0.010 np_temporal.py:424(updateDistalTempPool)
16 0.000 0.000 0.000 0.000 np_temporal.py:84(checkCellLearn)
3098 0.004 0.000 0.004 0.000 np_temporal.py:94(checkCellActive)
3 0.000 0.000 0.000 0.000 numeric.py:476(asanyarray)
3 0.000 0.000 0.000 0.000 shape_base.py:113(atleast_3d)
1 0.000 0.000 0.000 0.000 shape_base.py:319(dstack)
40 0.000 0.000 0.000 0.000 {len}
17 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'argsort' of 'numpy.ndarray' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
1 0.000 0.000 0.000 0.000 {method 'ravel' of 'numpy.ndarray' objects}
3 0.000 0.000 0.000 0.000 {numpy.core.multiarray.array}
1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.concatenate}
1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.unravel_index}
343 0.000 0.000 0.000 0.000 {range}
The majority of the remaining time is spent checking if cells are active in the function "checkCellActive". The next best method to increase the speed of this calcualtor would be to implement a pure theano GPU version. This will take a significant amount of time. Further work should be done investigating if the current numpy temporal pooling algorithm is performing as expected before embarking on the theano version.
The numpy temporal calculator is slow. Here is the profiling for a the top htm layer performing temporal poooling with the following configuration parameters for the HTM network;
The profiling of one step of this layer is shown below.
Note the temporal pooling time of ~0.095 seconds, this is over half the total calcualtion time. (0.095 0.032 HTM_network.py:823(temporalPooler))