Due to the ever-expanding volume of observed spectroscopic data from surveys such as SDSS and LAMOST, it has become important to apply artificial intelligence (AI) techniques for analysing stellar spectra to solve spectral classification and regression problems like the determination of stellar atmospheric parameters Teff, log g, [Fe/H]. We propose an automated approach for the classification of stellar spectra in the optical region using Convolutional Neural Networks. Traditional machine learning (ML) methods with shallow architecture (usually up to 2 hidden layers) have been trained for these purposes in the past. However, deep learning methods with a larger number of hidden layers allow the use of finer details in the spectrum which results in improved accuracy and better generalisation. Studying finer spectral signatures also enables us to determine accurate differential stellar parameters and find rare objects. We examine various machine and deep learning algorithms like Artificial Neural Networks (ANN), Random Forest (RF), and Convolutional Neural Network (CNN) to classify stellar spectra using the Jacoby Atlas, ELODIE and MILES spectral libraries as training samples. We test the performance of the trained networks on the Indo-U.S. Library of Coude Feed Stellar Spectra (CFLIB). We show that using convolutional neural networks, we are able to lower the error up to 1.23 spectral sub-classes as compared to that of 2 sub-classes achieved in the past studies with ML approach. We further apply the trained model to classify stellar spectra retrieved from the SDSS database with SNR>20.