C3W1 - Unable to understand "mean layer"

Within the Introduction to Neural network and TensorFlow section embedding and mean layers lecture there’s a topic of Mean layer which I am not able to grasp. There’s as example (image uploaded)

How do we end up with just 2 values I know its average of the two columns but I cannot understand how it works as the dimensions of the layer has been changed from (3X2) to (1X2)

1 Like

Hi @Karan_Bari!

It actually can be something as simple as using the numpy mean function, like so:

import numpy as np

a = np.array([[0.020, 0.006], [-0.003, 0.010] , [0.009, 0.010]])

a_mean = np.mean(a, axis=0)

rounded_a_mean = np.round(a_mean, 3) # to get the exact numbers as above

rounded_a_mean_reshaped = rounded_a_mean.reshape(-1, 1) # to reshape into a column vector if that is needed

4 Likes