In this paper, we propose a deep neural network-based feature learning methodology for fault diagnosis in electromechanical systems such as rotary machines. In order to classify faults in bearings and gears, an unsupervised algorithm, which trains one layer of a deep neural network at a time and minimizes the reconstruction error, is used for feature learning. To validate our approach, the proposed method is applied to two datasets for bearing and gearbox faults. Using the proposed method, we achieved fault classification accuracies of up to 99% and 96% for bearing and gearbox faults, respectively. Three different computational hardware platforms are used to validate the efficiency of real-time implementation of our proposed algorithm.