I have the following loss:
loss = loss(y_train_left_noc[:,:,0], soft_argmin).tolist()
where type(loss) is <class 'float'>
However, upon using this loss in the optimizer like so:
train = tf.keras.optimizers.Adam().minimize(loss, [k1, k2, k3])
where k1, k2 and k3 are convolution kernels, I get the following error:
Traceback (most recent call last):
File "train.py", line 277, in <module>
k3
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py", line 385, in minimize
loss, var_list=var_list, grad_loss=grad_loss, tape=tape)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py", line 440, in _compute_gradients
raise ValueError("`tape` is required when a `Tensor` loss is passed.")
ValueError: `tape` is required when a `Tensor` loss is passed.
If the loss is of type float, then why does Tensorflow say that a Tensor loss is passed?