def test_serializing_loss_class(): orig_loss_class = MSE_MAE_loss(0.3) with custom_object_scope({'MSE_MAE_loss': MSE_MAE_loss}): serialized = losses.serialize(orig_loss_class) with custom_object_scope({'MSE_MAE_loss': MSE_MAE_loss}): deserialized = losses.deserialize(serialized) assert isinstance(deserialized, MSE_MAE_loss) assert deserialized.mse_fraction == 0.3