Exemplo n.º 1
0
 def test_encode_spatial_bin_l2_max(self):
     result = llc_opt.encode_spatial_bin_numba(self.codebook,
                                               np.array([[3, 0], [-1, -1]]),
                                               self.size,
                                               self.alpha,
                                               self.sigma,
                                               pooling='max')
     expected = np.array([1.11015, 0.22858, 0.98056])
     self.assertArrayAlmostEqual(result, expected)
Exemplo n.º 2
0
 def test_encode_spatial_bin_l1_sum(self):
     result = llc_opt.encode_spatial_bin_numba(self.codebook,
                                               np.array([[3, 0], [-1, -1],
                                                         [1, -1]]),
                                               self.size,
                                               self.alpha,
                                               self.sigma,
                                               pooling='sum')
     expected = np.array([1.25112, -0.260689, 2.00956])
     self.assertArrayAlmostEqual(result, expected)
 def _encode_spatial_bin(self, features, pooling='max'):
     """
     Computes the LLC codes for a set of features and pools them with the
     specified pooling method. In case of an empty set, a zero vector will be
     returned.
     In further versions it is planned to implement another version of
     "encode_spatial_bin", preferably using Tensorflow or Pytorch and this
     method can choose which to call based on set options.
     :author: Joschka Strüber
     """
     return encode_spatial_bin_numba(self._codebook, features, self._size,
                                     self._alpha, self._sigma, pooling)
Exemplo n.º 4
0
 def test_encode_spatial_bin_empty(self):
     result = llc_opt.encode_spatial_bin_numba(self.codebook, np.array([]),
                                               self.size, self.alpha,
                                               self.sigma)
     expected = np.zeros(self.encoder._size)
     self.assertTrue((result == expected).all())