[Nengo DL]: Unable to replicate `max_to_avg_pool` operation

Hello there,

I am attempting to replicate the MaxPooling and max_to_avg_pool operations (in a converted Nengo-DL network) by replacing the MaxPooling TensorNode with a custom Node which does a simple np.max() and np.mean() respectively in each case. With np.max() in the custom Node for MaxPooling I am able to get the exact results, whereas when I compare the np.mean() results with max_to_avg_pool results, it differs a lot.

I am under the assumption that when max_to_avg_pool = True, the mean of each of the pooled inputs (i.e. 4 or 8 spike amplitudes) is forwarded to the next layer each timestep (instead of the max of all the pooled spike amplitudes). The kernel code mentioned here for ConvertAvgPool is bit difficult to follow, but looks like it should compute average when convolved. Does this not happen?

Please let me know.

I think it’s solved now. So while replicating MaxPooling op, the custom Node with np.max() is connected to the previous and next Ensembles with no synapse (i.e. synapse=None); and this perfectly reproduced the same results (do keep in mind that we need to set the same np.random.seed(<seed>) before using nengo_dl.Converter to convert the trained TF model).

In case of max_to_avg_pool=True too, the custom Node with np.mean() was connected to the previous and next Ensembles with no synapse. And this is perhaps the reason of discrepancy in the attempt to reproduce results. When I connect the custom Node to the next Ensemble with a synapse used in nengo_dl.Converter it reproduces the exact same result (as when max_to_avg_pool=True). Interestingly, when both the previous and next Ensembles are connected with a synapse, they don’t faithfully reproduce the results of max_to_avg_pool=True.

Therefore, I believe when max_to_avg_pool=True, the previous Ensemble is connected to the AveragePooling layer without any synapse, but the next Ensemble is connected via converter synapse.