Hi guys
i have questions during the sampling function. from my understanding(pls correct me if i am wrong) sampling is the use of the previous sequence T predicted value to be used as input. For this assignment’s sample function return variable indices is returning a 50 character list. can i ask how is it useful as a sample ? and also how does it help with the next part of sequence T+1 if it is more then 1 character long.
Hi @zheng_xiang1,
I have two simple questions:
-
Is it your understanding the the so-called sequence T is a sequence of characters only?
-
Is it your understanding that “deeplearningspecialization\n” is an example of such sequence (of length 27), when ‘\n’ is the terminating character?
Raymond
1 Like
- yes
- i know that the input would be something like that. but cant really figure out the rest. this is becuz i dont see how the sample function is being use to implement sampling in the model function (despite calling it once every 2000 times to view the indices that are sampled. in fact the first part of the loop where X and Y are set up as such

to be used as inputs for the optimiser look to be more like sampling.
just to add on to some details, at the model function, can i clarify if
1.the optimizer is being used for the whole sequence of characters in the word that is represented by X am i right to say so?
Hello @zheng_xiang1,
To begin with, let’s separate the sample()
function from the model()
function. We can train a model without the sample()
function. As the assignment described,
# Every 2000 Iteration, generate "n" characters thanks to sample() to check if the model is learning properly
I think it has already said clearly the purpose of sample()
is just to check if the model is learning properly. Therefore, with sample()
, we can check the model by “sampling” some names from the model.
Without sample()
, we just cannot check it.
Therefore, it is important that we separate the two functions, know what each of them do, and after we are certain that model()
can live without sample()
, and what added value does sample()
bring to the process of model training, then we add sample()
back to the game. Okay? Don’t mix them up from the beginning.
The X and Y have nothing to do with the sample()
function. X is real data. We use real data to train a model. sample()
draws a sample from a trained model, a sample is NOT a real data. In other words, without X, we can’t train a model. Without a model, we can’t draw any meaningful sample with sample()
. X
does NOT come from sample()
.
The process can be simplified to this:
Yes, the optimize()
function takes the whole word (whole sequence of characters, and represented by X
) as its input.
Raymond
1 Like
my goodness its so clear now. blessed for the explaination ray!!!
You are welcome, @zheng_xiang1
Cheers,
Raymond