'Tensorflow Tensor values are not assigned
I'm using a custom loss function as below:model.compile(loss=custom_loss,...)
And the custom loss function is defined as:
def custom_loss(y_actual,y_pred):
custom_loss = loss_function(y_actual,y_pred) + penalty * quantizer.model_size()
return custom_loss
where quantizer is a object of a class and model_size() is a method of this class. In this model_size() method, I'm trying to create some tensors variable with some initial value. But it seems like the value is not assigned. I'm printing using print(tf.constant(1.0, dtype=float)) and print(tf.Variable(1.0, dtype=float)) to see the tensors and the output is like Tensor("custom_loss/Const:0", shape=(), dtype=float32) and <tf.Variable 'custom_loss/Variable:0' shape=() dtype=float32>. What causes this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
