C3W1 Excercise 4

I got a bit confused with the forward() function and it is not clear to me where should I take the weights input from. I tried several things also passing the weights from the function self.init_weights_and_state.weights but nothing works. I appreciate if someone could explain me what I am misunderstanding here.
I get this output

Dense layer has weights member variable. Use self.weights to access it inside the forward method.

Thank you. Could you please specify where the Dense layer has weights variable? I cannot find it. Also, after changing to self.weights I get the following error

See init_weights_and_state. There is a line self.weights = w.

Incompatible shapes means that you have access to weights. Please brush up on matrix multiplication to solve the exercise.

@Maja_Zofia_Kiszka Thanks for the notebook.
The problem lies in 2 places:

  1. In init_weights_and_state method, input_signature.shape is a tuple of size 2. They are of the form (num_rows, num_features). self.weights matrix should have shape (num_features, num_units). Look inside the __init__ method on how to get num_units.
  2. Once you fix that, please go back to forward method and fix the dot product.
2 Likes

Amazing! Thank you so much for your help!