Cerebral microbleeds are important biomarkers of many cerebrovascular diseases and cognitive dysfunctions. Their distribution patterns can indicate some underlying aetiologies. Hitherto, few researches tried to detect cerebral microbleeds accurately and automatically. Some improvements have been achieved via traditional machine learning methods. In this paper, we proposed a method based on convolutional neural network (CNN) for further improving the performance. Firstly, sliding neighborhood processing method was applied to generate the input and target datasets based on 10 3D brain images of cerebral autosomal-dominant arteriopathy with subcortical infarcts and Leukoencephalopathy scanned by susceptibility-weighted imaging (SWI). Then, CNN was used to classify the cerebral microbleeds. To exert the full-power of convolutional neural network, almost all hyperparameters of CNN structure that could affect the performance were tested, such as the number of layers, type of activation function, pooling method, and filter size. A fully-optimized convolutional neural network structure for cerebral microbleeds classification was obtained. It performed better than four existed state-of-the-art approaches with a sensitivity of 99.74%, a specificity of 96.89% and an accuracy of 98.32%.