Human action recognition (HAR) is a popular subject for academic society and other stakeholders. Nowadays it has a wide-spread use for lots of practical applications such as for health, assistive living, elderly care, and so on. Both visual and sensor-based data can be used for HAR. Visual data includes video images, still images, skeleton images, etc., whilst sensor-based data is acquired as numerical data from devices such as accelerometer, gyroscope, and so on. Employed classification methods and data types are of crucial importance on HAR performance. In this paper, sensor data based activity recognition is performed using stacked autoencoders (SAE). Finding near optimal accuracy results with SAEs is a challenging process if structural optimization is left to user experience. The purpose of this study is to improve the accuracy of HAR classifying methods such as SAEs using heuristic optimization algorithms. Hence the structural parameters of SAEs have been optimized using artificial bee colony optimization algorithm (ABC), genetic algorithm, differential evolution algorithm, particle swarm optimization algorithm (PSO) and an afresh developed hybrid algorithm (hABCPSO) which includes PSO and ABC in its internal structure. Leave-one-out cross-validation (LOOCV) test method is used for validating the results. Each algorithm is performed for 30 runs and the results of these runs are analyzed by statistical methods in detail. According to experimental results, hABCPSO supported SAE gives the minimum error and is the most robustness algorithm among the others. Obtained success rates show that the proposed SAE achieved the best accuracy rate ever on UCI human activity recognition dataset and a close result to best on wireless sensor data mining dataset with regard to LOOCV test technique.