Machine-learning structural and electronic properties of metal halide perovskites using a hierarchical convolutional neural network