I'm trying to build a deep-learning model in Keras. In this model, I want to insert some copies of a "pre-trained unit". This unit corresponds to a Keras model model_1, whose parameters I optimazed at an earlier stage.
Now I want to properly define model_2 (to train) such that it includes some copies of model_1. The final layout of model_2 will be something like this, where each box contains a copy of model_1
and the red connections correspond to parameters extracted from pre-training.
Thus, the weights and biases associated with the red connections are known numbers.
I want to train model_2 by keeping fixed these parameters and optimizing the other parameters (i.e. weights and biases associated with the black connections).
I have not found any similar example in literature. Is it possible to realize such a Neural Network architecture by using Keras? How can I properly define model_2?
Of course, I can manually extract the pre-trained parameters par (as a numpy.array) from model_1 and put them into model_2, by using something like model_2.set_weights(par). The problem is that I have very large numbers of neurons/parameters. This means that Python is unable to allocate memory for a numpy.array of such dimensions.