C4W1_Assigment_Exercise 4 - Translator

Hello!

In def init Encoder and Decoder must be with 2 arguments (vocab_size, units)?

In part “call”
context, target = to_translate, sr_translation -?

TypeError: Exception encountered when calling layer ‘translator_18’ (type Translator).

Encoder.init() missing 1 required positional argument: ‘units’

Call arguments received by layer ‘translator_18’ (type Translator):
• inputs=(‘tf.Tensor(shape=(64, 14), dtype=int64)’, ‘tf.Tensor(shape=(64, 15), dtype=int64)’)

This is right!

This you should refer to this comment:

    Args:
        inputs (tuple(tf.Tensor, tf.Tensor)): Tuple containing the context (sentence to translate) and the target (shifted-to-the-right
1 Like

I am not sure that I understand this right…
To convert “to_translate” ( now <tf.Tensor: shape=(64, 14), dtype=int64…) in other format as variables?

Inputs is a tuple with 2 values inputs = (value1, value2)

Hello!
with “context, target = inputs(tuple(to_translate)), inputs(tuple(sr_translation))”
also with 'context, target = inputs(tuple(to_translate),tuple(sr_translation))"
Type error
Type error
What else may be wrong?

—> 38 context, target = inputs(tuple(to_translate)), inputs(tuple(sr_translation)) # In this case inputs is a tuple consisting of the context and the target, unpack it into single variables
39
40 # Pass the context through the encoder

TypeError: Exception encountered when calling layer ‘translator_7’ (type Translator).

‘tuple’ object is not callable

Call arguments received by layer ‘translator_7’ (type Translator):
• inputs=(‘tf.Tensor(shape=(64, 14), dtype=int64)’, ‘tf.Tensor(shape=(64, 15), dtype=int64)’)

TypeError: Exception encountered when calling layer ‘translator_8’ (type Translator).

‘tuple’ object is not callable

Call arguments received by layer ‘translator_8’ (type Translator):
• inputs=(‘tf.Tensor(shape=(64, 14), dtype=int64)’, ‘tf.Tensor(shape=(64, 15), dtype=int64)’)

Hi @Maria_Petrovskaya

You’re overthinking, it’s simpler:
context, target = inputs

Note the docstring:

    Args:
        inputs (tuple(tf.Tensor, tf.Tensor)): Tuple containing the context (sentence to translate) and the target (shifted-to-the-right translation)

Cheers

1 Like

Thank you! You saved me :))) :smiling_face_with_three_hearts: