Confused between optimizer and loss function I always thought the SGD was a loss function then I read this on a notebook
model.compile(loss=&quot;sparse_categorical_crossentropy&quot;, optimizer=keras.optimizers.SGD(lr=1e-3), metrics=[&quot;accuracy&quot;])

now I am confused what's the difference between loss and optimizer ? are they both used at the output layer to calculate the loss?
or is the optimizer something used in each layer?
Think of loss function what to minimize and optimizer how to minimize the loss.
loss could be mean absolute error and in order to reduce it, weights and biases are updated after each epoch. optimizer is used to calculate and update them.