C5W4A1 - UNQC4 - EncoderLayer - ValueError: The first argument to `Layer.call` must always be passed

Hi.
The instruction point no. 1 says:
" 1. You will pass the Q, V, K matrices and a boolean mask to a multi-head attention layer. Remember that to compute self-attention Q, V and K should be the same. Let the default values for return_attention_scores and training. You will also perform Dropout in this multi-head attention layer during training."
So I need to pass only Q,V,K and mask.

In the init method, self.mha is initialized as a layer:
self.mha = MultiHeadAttention(num_heads=num_heads,
key_dim=embedding_dim,
dropout=dropout_rate)

Therefore, it looks like we do not have to pass anything to the layer creation process, but rather just call a layer with the parameters like so…

self.mha()(x,x,x,mask)

But this is throwing up an error and Ive been stuck here. Can someone help me with this error?
ValueError: The first argument to Layer.call must always be passed.

Can you please post the entire error stack?

I believe you have an extra empty set of parenthesis there.

ohh that’s it! Good eyes, @TMosh !

Thanks… I did figure this out by looking at a few other posts… :slight_smile:
I was initially under the impression of using these with syntax similar to a regular tf layer. It took me a while to get that self.____ is already a layer and I just have to pass parameters to it :smiley:

1 Like