Hello Meir, thank you for your interesting question.
I will try to guide you to find the answers on your own.
Check the TF source code, and if does not help, I would love to explain more.
Expand dims returns a tensor with a length 1 axis inserted at the second index ‘axis’. If you want to know why it is needed, try to remove it, and see for yourself . And the [0] index is used because expand_dims returns a tensor with two elements.
Hope this helps, if not I would be happy to assist more.
Regards,
The code and the documentation suggest the opposite - that the same first elements of the dataset should be chosen each time. In fact, this is what happens when I try their example:
then the images are always the same, no matter how many times you run the image plotting cell. If you set shuffle=True the images are different at every run of the image plotting cell but the order in which they appear is the same. I guess, this means that the 9 images come from the first batch of size 32 if shuffle=False, because the data is shuffled in alphanumeric order. In contrast, if shuffle=True then the data is shuffled at every run of train_dataset.take(1) and we get different batches every time. Nevertheless, in both cases the set of training images is the same - for shuffle=True it is shuffled and for shuffle=False it is not.