class_docstr: Trains post-hoc detection SVMs for all classes using the algorithm
  and hyper-parameters of traditional R-CNN.
class_docstr_tok: ["Trains","post-hoc","detection","SVMs","for","all","classes","using","the","algorithm","and","hyper-parameters","of","traditional","R-CNN","."]
code: def train_with_hard_negatives(self):
      _t = Timer()
      roidb = self.imdb.roidb
      num_images = len(roidb)
  
      for epoch in range(0, self.svm_nrEpochs):
          # num_images = 100
          for i in range(num_images):
              print("*** EPOCH = %d, IMAGE = %d *** " % (epoch, i))
              # im = cv2.imread(self.imdb.image_path_at(i))
              # if roidb[i]['flipped']:
              #    im = im[:, ::-1, :]
              # im = self.imdb.image_path_at(i)
              _t.tic()
              scores, boxes, feat = self.im_detect(
                  self.net, i, roidb[i]["boxes"], self.feature_scale
              )
              _t.toc()
              # feat = self.net.blobs[self.layer].data
              for j in range(1, self.imdb.num_classes):
                  hard_inds = np.where(
                      (scores[:, j] > self.hard_thresh)
                      & (
                          roidb[i]["gt_overlaps"][:, j]
                          .toarray()
                          .ravel()
                          < self.neg_iou_thresh
                      )
                  )[0]
                  if len(hard_inds) > 0:
                      hard_feat = feat[hard_inds, :].copy()
                      new_w_b = self.trainers[j].append_neg_and_retrain(
                          feat=hard_feat
                      )
                      if new_w_b is not None:
                          self.update_net(j, new_w_b[0], new_w_b[1])
                          np.savetxt(
                              self.svmWeightsPath[:-4]
                              + "_epoch"
                              + str(epoch)
                              + ".txt",
                              self.net.params["cls_score"][0].data,
                          )
                          np.savetxt(
                              self.svmBiasPath[:-4]
                              + "_epoch"
                              + str(epoch)
                              + ".txt",
                              self.net.params["cls_score"][1].data,
                          )
                          np.savetxt(
                              self.svmFeatScalePath[:-4]
                              + "_epoch"
                              + str(epoch)
                              + ".txt",
                              [self.feature_scale],
                          )
  
          print(
              (
                  "train_with_hard_negatives: " "{:d}/{:d} {:.3f}s"
              ).format(i + 1, len(roidb), _t.average_time)
          )
  
imports: from timer import Timer
  from sklearn import svm
  import numpy
label_desc: Use image node_id 7 for calling the SVMTrainer obj's underlying member method code with example usage: obj.train_with_hard_negatives() without return types