sped up HSP_NN

only compute z for input layer once