Implementing your own Loss in TF JS

Hi,

I am thinking of implementing YOLO in Node JS for learning purposes. I can see how the tfjs.layers will help, but I cant quite see how would you create a custom loss, or if it is possible.

Would this be using an Optimizer where the loss is my fn ?

Any help here?