Where can I find the reference on what input should be passed to the model in the evaluation step?

For exercise 5, after defining model=Siamese(), which returns trax.layers.combinators.Parallel, where can I find the reference on what should be passed into model() in the evaluation stage?

More specifically, where can I find the reference saying model((q1, q2)) or model([q1, q2]) being correct, but not model(q1, q2)?

Hi @Eureka

I’m not sure I understand your question. Are you thinking that “evaluation stage” is somehow special compared to “training stage”? If it is the case, then no, model behaves the same way regarding the inputs.

I assume you know that (q1, q2) is one argument as is [q1, q2], but q1, q2 are two arguments?

When we defined Siamese(..) at the end:

    # Run on Q1 and Q2 in parallel.
    model = tl.Parallel(q_processor, q_processor)
    return model

it is indicative that the model will run two q_processor layers (which each is tl.Serial) in parallel so the model needs the input to be fromed that way (made of two “streams” of data).

The links are provided right after “Exercise 02” where you can check the forward methods of tl.Parallel and tl.Serial. Specifically tl.Parallel checks if the number of inputs is the same number as of layers (if len(sublayer_inputs) != n_layers:).

I’m not sure I answered your question :slight_smile:

Cheers!

What I mean, where is the documentation regarding the inputs?

Also I don’t think learning a software needs to read its source codes to understand how it works.

So my question is how to know (q_processor, q_processor) requires tuple/list as inputs as model([q1, q2]), instead of model(q1, q2).

Where can I find the documentation?

You defined your function on your own (and the course staff did it’s part too) and you ask where the documentation is? :slight_smile:

For example:

def some_function(a: list) -> tuple:
    """The documentation."""
    b = np.array([i*2 for i in a])
    return b, b

Would you be asking numpy community where the documentation is why this function requires list as input and tuple as output?

This is the function output

def Siamese(...)
....
model = tl.Parallel(q_processor, q_processor)
return model

which is the Trax output.

Then

model = Siamese()

I simply ask where can I find document on what should be put inside model()

As you can see the course staff chose that the input requires a tuple (each q_processor is Serial layer which requires one input). Trax has nothing to do with it.

The documentation for Parallel is linked in the last line before defining the exercise function.

Trax code is very readable so I personally prefer to look at the code (this is why I linked the code first). For example, PyTorch has a way better documentation, but the code (for the library) is way more complicated and requires more programming knowledge and time to familiarize with it.