The objective of this work is to achieve disturbance rejection and constant orientation of the trunk of a multi-legged robot. This is significant when payloads (such as cameras, optical systems, armaments) are carried by the robot. In particular, this paper presents an application of an on-line learning method to actively correct the open-loop gait generated by a central pattern generator (CPG) or a limit-cycle method. The learning method employed is based on a Nonlinear Autoregressive Neural Network with Exogenous inputs (NARX-NN)- a recurrent neural network architecture typically utilized for modeling nonlinear difference systems. A supervised learning approach is used to train the NARX-NN. The input to the neural network includes states of the robot legs, trunk attitude and attitude rates, and foot contact forces. The neural network is used to estimate the total torque imparted on the robot. The learned effects of the internal forces and disturbances are then applied in an inverse dynamics/computed torque controller, which is utilized to achieve a stable trunk (i.e., a constant orientation of the trunk). The efficacy of the proposed approach is shown in detailed simulation studies of a quadruped robot.