Optimizing Performance of Feedforward and Convolutional Neural Networks through Dynamic Activation Functions