Among all cancer‐related deaths, lung cancer leads all indicators, accounting for approximately 20% of all types. Patients diagnosed in the early stages have a 1‐year survival rate of 81% to 85%, while in an advanced stage have 15% to 19% chances of survival. The primary manifestation of this cancer is through pulmonary nodule on computed tomography images. In the early stages, it is a complex task even for experienced specialists and presents some challenges to classify these nodules in benign or malignant. So, to assist specialists, computer‐aided diagnosis systems have been used to improve the accuracy in the diagnosis. In this article, we explored and compared the use of random search, simulating annealing, and Tree‐of‐Parzen‐estimators algorithms of hyperparameter tuning to find the best architecture of a convolutional neural network to classify small pulmonary nodules in benign or malignant with a diameter of 5 to 10 mm. Our best model used result was the model using the simulating annealing algorithm and yielded an area under the receiver operating characteristic curve of 0.95, the sensitivity of 82%, the specificity of 94%, and accuracy of 88% using a balanced data set of nodules. Therefore, our model is capable of classifying early lung nodules, where the patients have bigger chances of survival.