1

so there is this piece of code I am trying to understand:

rois, target_class_ids, target_bbox, target_mask =\
                DetectionTargetLayer(config, name="proposal_targets")([
                    target_rois, input_gt_class_ids, gt_boxes, input_gt_masks])

DetectionTargetLayer is a Keras subclass layer. So what does the operator =\ mean? Is it just the same as '='?

Marco Cerliani
  • 21,233
  • 3
  • 49
  • 54
  • That's not an operator. That's an equals sign with a line continuation. The next line is appended to the end. – Tim Roberts Nov 12 '21 at 00:21
  • 2
    This code is a bit misleading because the slash in =\ is actually not related to equal sign at all (and could be any distance from it). It's the line continuation character. – 0x263A Nov 12 '21 at 00:22

3 Answers3

3

That's not an operator, the \ is a line continuation chararacter. It splits the line after the = and allows it continue on the next line. PEP8 standards say to keep lines under 120 characters, and this line is pretty long, so the author broke it after the =.

TomServo
  • 7,248
  • 5
  • 30
  • 47
0

\ is not used as an operator, instead, it is used as an equals sign with a line continuation.

I see where you are confused, the code isn't really clear.

=\ is actually not related to equal sign at all.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
jahantaila
  • 840
  • 5
  • 26
0

This code:

rois, target_class_ids, target_bbox, target_mask =\
                DetectionTargetLayer(config, name="proposal_targets")([
                    target_rois, input_gt_class_ids, gt_boxes, input_gt_masks])

is IDENTICAL to this code:

rois, target_class_ids, target_bbox, target_mask = DetectionTargetLayer(config, name="proposal_targets")([target_rois, input_gt_class_ids, gt_boxes, input_gt_masks])

Because, as others have said, like in C, Bash, and many other languages, \ at the end of a line tells the Python interpreter to treat the next line as the same line, and ignore the \.

This question talks in detail about the usage of the line-continuation token in Python.