Python question calling the week 1

Hi in the programing assignment for week 1 the encoder is invoked
encoder = Encoder(VOCAB_SIZE, UNITS)

Pass a batch of sentences to translate from english to portuguese

encoder_output = encoder(to_translate)
why were we able to do so without having to say
encoder_output = encoder.call(to_translate). whether using call or not u get the same result. this is not true if I use random word. However, “call” alone without call is not a key word. if i use a random word, lets say “monkey”, i have to use encoder. monkey ( context)not just encoder.

what allowed us to use encoder ( context) without having to use encoder.call?
Thank you in advance

Hi @Fares_Bagh

In TensorFlow, when you create a custom layer by subclassing tf.keras.layers.Layer and implement a call method, you can invoke the layer directly (e.g., encoder(to_translate)) without explicitly calling call because the __call__ method in Keras automatically invokes the call method. This helps us to code easily allowing your custom layer to be used like built-in layers!

Hope this helps!

1 Like

It does. what a service. what a service!!! :slight_smile: amazing responsiveness. Thank you.

1 Like

You’re welcome, Happy to help :raised_hands: