I trained a 3-hidden layer NN (3-HL) using Keras (with good results, and I wanted to extract the weights from its first layer (inputs to its first-hidden layer) and use them in a single-hidden layer NN (inputs to its single hidden layer), to train. The 3-HL model summary along with its extracted (hopefully first layer) weight dimensions is as follows:
And here are the same info for the single-hidden layer which I aim to train using the extracted first-layer weights from the above model:
As you can see. both weights seem to have similar shape and size and dimensions. But when I put this line to set the single-hidden layer model weights, I get a valueError as follows:
Any idea how I could solve this?
Instead of getting weights and the biases separately you should get them together and input that into
set_weights() function. Try following: