How I can start training alexnet from scratch on the imagenet?

Can anyone help me with training a network (e.g. alexnet) from scratch on a dataset (e.g. imagenet, or
CIFAR10)?
I read the transfer learning tutorial but it was for finetuning

The finetuning example is enough.

You just need to set pretrained =False and send all params to your optimizer.

From scratch

models.resnet18()

Pretrained:

models.resnet18(pretrained=True)