Constitutive relations of granular materials are of great significance to many fields, such as geotechnical engineering. Different from traditional phenomenological constitutive theory, this study explores a micromechanics-informed data-driven constitutive modelling approach for granular materials via machine learning models. On the basis of Vogit’s homogenization assumption, an analytical small-strain stress-strain relation is established. This relation uniquely determines a group of micromechanical fabric variables associated with the constitutive behavior of granular materials. These recognized variables, together with principal strain and stress sequence pairs reflecting macroscopic properties of granular materials, are obtained via a series of discrete element models of triaxial compression tests. Considering the fact that these microscopic fabric tensors are internal variables, which cannot be directly used as inputs of a material constitutive model, a directed graph is introduced to incorporate microstructural information implicitly in the prediction of stress-strain responses. The gated recurrent unit (GRU) based recurrent neural networks are used as basic deep learning models to describe the mapping relation between nodes in the designed directed graph. In this study, the entire stress-strain prediction model can be assembled with two neural networks that are trained separately, after unfolding the directed graph from the target node to the source node. By testing the trained deep learning model based on brand new datasets, the results demonstrate that the proposed training approach can satisfactorily capture the multi-directional stress-strain responses with reversal loadings, such as conventional triaxial compression with unloading-reloading cycles, true-triaxial compression with constant intermediate principal stress (constant-b
), and constant mean effective effective stress (constant-p
) conditions with unloading-reloading cycles. The prediction results also show that the trained model possesses satisfactory interpolation and extrapolation capability. Considering the excellent ability of deep learning in terms of capturing the mechanical responses of granular materials and the unique features of open learning when new data is available, integrating a data-driven paradigm with theoretical constitutive models may be one of the important directions for constitutive research of granular materials.