This study investigated whether using an inertial measurement unit (IMU) can identify different walking conditions, including level walking (LW), descent (DC) and ascent (AC) slope walking as well as downstairs (DS) and upstairs (US) walking. Thirty healthy participants performed walking under five conditions. The IMU was stabilised on the exterior of the left shoe. The data from IMU were used to establish a customised prediction model by cut point and a prediction model by using deep learning method. The accuracy of both prediction models was evaluated. The customised prediction model combining the angular velocity of dorsi–plantar flexion in the heel-strike (HS) and toe-off (TO) phases can distinctly determine real conditions during DC and AC slope, DS, and LW (accuracy: 86.7–96.7%) except for US walking (accuracy: 60.0%). The prediction model established by deep learning using the data of three-axis acceleration and three-axis gyroscopes can also distinctly identify DS, US, and LW with 90.2–90.7% accuracy and 84.8% and 82.4% accuracy for DC and AC slope walking, respectively. In conclusion, inertial measurement units can be used to identify walking patterns under different conditions such as slopes and stairs with customised prediction model and deep learning prediction model.