The identification of hazardous materials is a key measure in the prevention and control of fire and explosion disasters. Conventional techniques used to identify hazardous materials include contact detection and post-sampling laboratory testing, which cannot meet the needs of extreme environments, where personnel and equipment are not accessible for on-site detection. To address this problem, this paper proposes a method for the classification and identification of hazardous materials based on convolutional neural networks, which can achieve non-contact remote detection of hazardous materials. Firstly, a dataset containing 1800 hyperspectral images of hazardous materials, which can be used for deep learning, is constructed based on the hazardous materials hyperspectral data cube. Secondly, based on this, an improved ResNet50-based classification method for hazardous materials is proposed, which innovatively utilizes a classification network based on offset sampling convolution and split context-gated convolution. The results show that the method can achieve 93.9% classification accuracy for hazardous materials, which is 1% better than the classification accuracy of the original ResNet50 network. The network also has high performance under small data volume conditions, effectively solving the problem of low classification accuracy due to small data volume and blurred image data features of labelled hazardous material images. In addition, it was found that offset sampling convolution and split context-gated convolution showed synergistic effects in improving the performance of the network.