Solved by rvandeghen in post #8 
              
              
                Even if it is not the good way to do it, I will check that output2 is not empty to do: 

such that I’m sure that there is always at least one annotation but i miss the fact that the focal loss should still perform the log-loss where every anchor is considered as background. 
I guess that accumulate …