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?

Hi @Mah_Neh ,

You can create your own loss function and pass it while compiling the model. The model.compile method accepts a custom loss function as an argument.

Example:

Loss Function
function lossfn(){

}
compile function: 

model.compile({optimizer: 'sgd', loss: lossfn});

Let me know if it helps. Thank You!!