Exercise 4 - initialize parameters Week3

Hi, I can't get it right and have tried different alternatives. May you please help me out? Thanks

W1 = tf.Variable("W1",[25,12288],tf.keras.initializers.GlorotNormal(seed=1))
b1 = tf.Variable("b1",[25,1],tf.keras.initializers.GlorotNormal(seed=1))
W2 = tf.Variable("W2",[12,25],tf.keras.initializers.GlorotNormal(seed=1))
b2 = tf.Variable("b2",[12,1],tf.keras.initializers.GlorotNormal(seed=1))
W3 = tf.Variable("W3",[6,12],tf.keras.initializers.GlorotNormal(seed=1))
b3 = tf.Variable("b3",[6,1],tf.keras.initializers.GlorotNormal(seed=1))

It might be the case that you are technically using different initializers for each variable, instead of just one.

try this:

# This line should already be there for you.
initializer = tf.keras.initializers.GlorotNormal(seed=1)

The use the variable initializer for the variables:

W1 = tf.Variable(initializer(shape=(25, 12288)))

Similarly for the rest.

Edit: Added a closing parens. Thanks @Zoooeee for the fix!


You missed a right bracket in the end. It should be W1 = tf.Variable(initializer(shape=(25, 12288)))


Thanks for the fix :slight_smile: