コード例 #1
0
 def ignore_inception(self):
     """
     Ignore until Apache Spark provides full support for ML Persistence in 3rd-party Python
     libraries.
     """
     transformer0 = DeepImageFeaturizer(inputCol='image',
                                        modelName="InceptionV3",
                                        outputCol="features0",
                                        scaleHint="SCALE_FAST")
     dst_path = os.path.join(self.tempdir, "featurizer")
     transformer0.save(dst_path)
     transformer1 = DeepImageFeaturizer.load(dst_path)
     self.assertEqual(transformer0.uid, transformer1.uid)
     self.assertEqual(type(transformer0.uid), type(transformer1.uid))
     for x in transformer0._paramMap.keys():
         self.assertEqual(
             transformer1.uid, x.parent,
             "Loaded DeepImageFeaturizer instance uid (%s) did not match Param's uid (%s)"
             % (transformer1.uid, transformer1.scaleHint.parent))
     self.assertEqual(
         transformer0._paramMap, transformer1._paramMap,
         "Loaded DeepImageFeaturizer instance params (%s) did not match " %
         str(transformer1._paramMap) +
         "original values (%s)" % str(transformer0._paramMap))
     self.assertEqual(
         transformer0._defaultParamMap, transformer1._defaultParamMap,
         "Loaded DeepImageFeaturizer instance default params (%s) did not match "
         % str(transformer1._defaultParamMap) +
         "original defaults (%s)" % str(transformer0._defaultParamMap))
コード例 #2
0
 def test_inception(self):
     transformer0 = DeepImageFeaturizer(inputCol='image',
                                        modelName="InceptionV3",
                                        outputCol="features0",
                                        scaleHint="SCALE_FAST")
     dst_path = os.path.join(self.tempdir, "featurizer")
     transformer0.save(dst_path)
     transformer1 = DeepImageFeaturizer.load(dst_path)
     self.assertEqual(transformer0.uid, transformer1.uid)
     self.assertEqual(type(transformer0.uid), type(transformer1.uid))
     for x in transformer0._paramMap.keys():
         self.assertEqual(
             transformer1.uid, x.parent,
             "Loaded DeepImageFeaturizer instance uid (%s) did not match Param's uid (%s)"
             % (transformer1.uid, transformer1.scaleHint.parent))
     self.assertEqual(
         transformer0._paramMap, transformer1._paramMap,
         "Loaded DeepImageFeaturizer instance params (%s) did not match " %
         str(transformer1._paramMap) +
         "original values (%s)" % str(transformer0._paramMap))
     self.assertEqual(
         transformer0._defaultParamMap, transformer1._defaultParamMap,
         "Loaded DeepImageFeaturizer instance default params (%s) did not match "
         % str(transformer1._defaultParamMap) +
         "original defaults (%s)" % str(transformer0._defaultParamMap))