Example #1
0
    def toKerasOptimizer(value):
        """
        Check if a value is a valid name of Keras optimizer and return it.
        Otherwise raise an error.
        """
        if not kmutil.is_valid_optimizer(value):
            err_msg = "Named optimizer not supported in Keras: [type {}] {}"
            raise TypeError(err_msg.format(type(value), value))

        return value
    def toKerasOptimizer(value):
        """
        Check if a value is a valid name of Keras optimizer and return it.
        Otherwise raise an error.
        """
        if not kmutil.is_valid_optimizer(value):
            err_msg = "Named optimizer not supported in Keras: [type {}] {}"
            raise TypeError(err_msg.format(type(value), value))

        return value
Example #3
0
 def toKerasOptimizer(value):
     if kmutil.is_valid_optimizer(value):
         return value
     raise TypeError(
         "Named optimizer not supported in Keras: {} type({})".format(
             value, type(value)))
 def test_keras_training_utils(self):
     self.assertTrue(kmutil.is_valid_optimizer('adam'))
     self.assertFalse(kmutil.is_valid_optimizer('noSuchOptimizer'))
     self.assertTrue(kmutil.is_valid_loss_function('mse'))
     self.assertFalse(kmutil.is_valid_loss_function('noSuchLossFunction'))