Question: 3 . 3 Padding the labels In this section, you will pad the labels. TextVectorization already padded the sentences, so you must ensure that the
Padding the labels
In this section, you will pad the labels. TextVectorization already padded the sentences, so you must ensure that the labels are properly padded as well. This is
not a hard task for two main reasons:
Tensorflow has builtin functions for padding
Padding will be performed uniformly per dataset train validation and test using the maximum sentence length in each dataset and the size of each
sentence is exactly the same as the size of their respective labels.
You will pad the vectorized labels with the value You will not use to simplify loss masking and evaluation in further steps. This is because to properly
classify one token, a log softmax transformation will be performed and the index with greater value will be the index label. Since index starts at it is better to
keep the label as a valid index, even though it is possible to also use as a mask value for labels, but it would require some tweaks in the model architecture
or in the loss computation.
An array with the labels.
padding : The position where padding will take place, the standard is pre, meaning the sequences will be padded at the beginning. You need to pass
the argument post
value: Padding value. The default value is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
