Thank you K. Frank!
When I set zero as a weight for the ‘0’ (backgroud) label, my network stopped dying after a few epochs and gives at least some results.
This is a huge step forward. Now I should probably carefully adjust the weights for the remaining classes, based on the frequency of their appearance.
Thanks so much for clarifying that.