Given the following model, how to print all layers values ?
To print layers, one needs to define the layers to output in the model configuration, using, outputs
property. Using destructuring assignement on model.predict()
one could retrieve the intermediate layers to output
const input = tf.input({shape: [5]});
const denseLayer1 = tf.layers.dense({units: 10, activation: 'relu'});
const denseLayer2 = tf.layers.dense({units: 2, activation: 'softmax'});
const output1 = denseLayer1.apply(input);
const output2 = denseLayer2.apply(output1);
const model = tf.model({inputs: input, outputs: [output1, output2]});
const [firstLayer, secondLayer] = model.predict(tf.ones([2, 5]));
firstLayer.print();
secondLayer.print()