universe_will:

alculate number of distinct values in a tensor as loss for image generation.
The target gray image should contain only several gray values in range of (0, 255). Large number of distinct values should get high loss.
How can i achieve this loss with torch?


Thanks  for your reply.
Besides, is there any way to approximate this goal?