A research project on chemical AI, called the Molecular Cybernetics Project, was launched in Japan in 2021 with the goal of creating a molecular machine that can learn a type of conditioned reflex through the process of classical conditioning. In this project, we have developed a learning method for the network of such learning molecular machines, which is reported in this paper. First, as a model of a learning molecular machine, we formulate a logic gate that can learn conditioned reflex and introduce the network of the logic gates. Then we derive a key principle for learning, called the flipping principle, by which we present a learning algorithm for the network to realize a desired function.