In the context of training some deep Q network, I have to generate clone of a tensorflow model (containing dense neural networks and some activations). This is the syntax I am using.
My question is, why does not it preserve the hash, calculated using
hash(model)? If these are two exact clones of each other, just at two different memory locations, should the hash change? Or is the memory location itself an input to the hash, rather than the objects themselves?
hash of a model is dependent on the
__hash__ function which isn’t overridden in the keras
Model class. Therefore when the deepcopy is made with
clone_model, the id value of the object changes and which means that the value of
hash() also changes.
The answer below explains how the default hash function works.
Answered By – peytoncas