Пример #1
0
 def __eq__(self, other):
     if other == None:
         return False
     attrs = dir(self)
     attrs = [
         a for a in attrs
         if not (a.startswith('_')
                 or isinstance(getattr(self, a), types.MethodType)
                 or isinstance(getattr(self, a), types.FunctionType))
     ]
     attrs = set(attrs) - set(('model', 'pool', 'dir_reader', 'classifier'))
     for a in attrs:
         value = getattr(self, a)
         other_value = getattr(other, a)
         if a in ('test_features', 'train_features', 's2_prototypes'):
             test = util.CompareArrayLists(other_value, value)
         elif a in ('test_results', 'train_results'):
             test = all(other_value['predicted_labels'] == value['predicted_labels']) \
                 and all(other_value['decision_values'] == value['decision_values']) \
                 and other_value['accuracy'] == value['accuracy']
         else:
             test = other_value == value
         if not test:
             return False
     return True
Пример #2
0
 def testSetS2Kernels(self):
     model = Model()
     kernels = [
         np.random.random((10, ) + shape).astype(util.ACTIVATION_DTYPE)
         for shape in model.s2_kernel_shapes
     ]
     model.s2_kernels = kernels
     self.assertTrue(util.CompareArrayLists(model.s2_kernels, kernels))