Mechanical metamaterials are artificial structures that exhibit unusual mechanical properties at the macroscopic level due to architected geometric design at the microscopic level. With rapid advancement of multi-material 3D printing techniques, it is possible to design mechanical metamaterials by varying spatial distributions of different base materials within a representative volume element (RVE), which is then periodically arranged into a lattice structure. The design problem is challenging however, considering the wide design space of potentially infinitely many configurations of multi-material RVEs. We propose an optimization framework that automates the design flow. We adopt variational autoencoder (VAE), a machine learning generative model to learn a latent, reduced representation of a given RVE configuration. The reduced design space allows to perform Bayesian optimization (BayesOpt), a sequential optimization strategy, for the multi-material design problems. In this work,we select two base materials with distinct elastic moduli and use the proposed optimization scheme to design a composite solid that achieves a prescribed set of macroscopic elastic moduli. We fabricated optimal samples with multi-material 3D printing and performed experimental validation, showing that the optimization framework is reliable.