Skip to content

Commit

Permalink
fix None.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinlei Chen committed Aug 10, 2017
1 parent 5ed25ab commit e533d5a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/nets/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _add_gt_image(self):

def _add_gt_image_summary(self):
# use a customized visualization function to visualize the boxes
if not self._gt_image:
if self._gt_image is None:
self._add_gt_image()
image = tf.py_func(draw_bounding_boxes,
[self._gt_image, self._gt_boxes, self._im_info],
Expand Down Expand Up @@ -80,7 +80,7 @@ def _reshape_layer(self, bottom, num_dim, name):
return to_tf

def _softmax_layer(self, bottom, name):
if name == 'rpn_cls_prob_reshape':
if name.startswith('rpn_cls_prob_reshape'):
input_shape = tf.shape(bottom)
bottom_reshaped = tf.reshape(bottom, [-1, input_shape[-1]])
reshaped_score = tf.nn.softmax(bottom_reshaped, name=name)
Expand Down Expand Up @@ -260,24 +260,19 @@ def _add_losses(self, sigma_rpn=3.0):
rpn_bbox_targets = self._anchor_targets['rpn_bbox_targets']
rpn_bbox_inside_weights = self._anchor_targets['rpn_bbox_inside_weights']
rpn_bbox_outside_weights = self._anchor_targets['rpn_bbox_outside_weights']

rpn_loss_box = self._smooth_l1_loss(rpn_bbox_pred, rpn_bbox_targets, rpn_bbox_inside_weights,
rpn_bbox_outside_weights, sigma=sigma_rpn, dim=[1, 2, 3])

# RCNN, class loss
cls_score = self._predictions["cls_score"]
label = tf.reshape(self._proposal_targets["labels"], [-1])

cross_entropy = tf.reduce_mean(
tf.nn.sparse_softmax_cross_entropy_with_logits(
logits=tf.reshape(cls_score, [-1, self._num_classes]), labels=label))
cross_entropy = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=cls_score, labels=label))

# RCNN, bbox loss
bbox_pred = self._predictions['bbox_pred']
bbox_targets = self._proposal_targets['bbox_targets']
bbox_inside_weights = self._proposal_targets['bbox_inside_weights']
bbox_outside_weights = self._proposal_targets['bbox_outside_weights']

loss_box = self._smooth_l1_loss(bbox_pred, bbox_targets, bbox_inside_weights, bbox_outside_weights)

self._losses['cross_entropy'] = cross_entropy
Expand Down

0 comments on commit e533d5a

Please sign in to comment.