Speedups in logistic_layer.py