Hello Fikrat!



 Fikrat:

my target is load more weights for colourful pixels,but less weight for black pixel.


I answered this exact question in my reply to your previous post:

  
    
    
    How to implement weighted Cross Entropy Loss for lane marking segmentation 
  
  
    Hi Fikrat! 

If your problem is one a binary segmentation, presumably 
black = background, color = foreground, then you should use 
BCEWithLogitsLoss and the pos_weight argument that you 
pass to its constructor. 
If it’s multi-class segmentation, e.g., black = background, some 
colors or patterns = lane 1, some other colors or patterns = lane 2, 
etc., then you should use CrossEntropyLoss and the weight 
argument passed to its constructor. 
Best. 
K. Frank
  


If this doesn’t work for you or your have further questions, it would
probably make the most sense to move the discussion back to that
earlier thread.
Best.
K. Frank