We have developed a viscoplastic model that reproduces creep behavior and inelastic deformation of rock during loading-unloading cycles. We use a Perzyna-type description of viscous deformation that derives from a maximization of dissipated energy during plastic flow, in combination with a modified Cam-clay model of plastic deformation. The plastic flow model is of the associative type, and the viscous deformation is proportional to the ratio of driving stress and a material viscosity. Our model does not rely on any explicit time parameters; therefore, it is well-suited for standard and cyclic loading of materials. We validate the model with recent triaxial experiments of time-dependent deformation in clay-rich (Haynesville Formation) and carbonate-rich (Eagle Ford Formation) shale samples, and we find that the deformation during complex, multiscale loading-unloading paths can be reproduced accurately. We elucidate the role and physical meaning of each model parameter, and we infer their value from a gradient-descent minimization of the error between simulation and experimental data. This inference points to the large, and often unrecognized, uncertainty in the preconsolidation stress, which is key to reproducing the observed hysteresis in material deformation.