Nuclear $\beta$-decay half-lives are investigated using the two-hidden-layer neural network and compared with the model averaging method. By carefully designing the input and hidden layers of the neural network, the neural network achieves better accuracy of nuclear $\beta$-decay half-life predictions and well eliminates the too strong odd-even staggering predicted by the previous neural networks. For nuclei with half-lives less than $1$ second, the neural network can describe experimental half-lives within $1.6$ times. The half-life predictions of the neural network are further tested with the newly measured half-lives, demonstrating its reliable extrapolation ability not far from the training region. Compared to the model averaging method, the neural network has higher accuracy and smaller uncertainties of half-life predictions in the known region. When extrapolated to the unknown region, the half-life uncertainties of the neural network are still smaller than those of the model averaging method within about $5 - 10$ steps for nuclei with $35 \lesssim Z \lesssim 90$, while the model averaging method has smaller half-life uncertainties for nuclei near the drip line.