def test_get_from_module_uses_custom_object(): get_custom_objects().clear() assert (get_from_module("CustomObject", globals(), "test_generic_utils") == CustomObject) with pytest.raises(ValueError): get_from_module("TestObject", globals(), "test_generic_utils") with custom_object_scope({"TestObject": CustomObject}): assert (get_from_module("TestObject", globals(), "test_generic_utils") == CustomObject)
def test_get_from_module_uses_custom_object(): get_custom_objects().clear() assert (get_from_module("CustomObject", globals(), "test_generic_utils") == CustomObject) with pytest.raises(ValueError): get_from_module("TestObject", globals(), "test_generic_utils") with custom_object_scope({"TestObject": CustomObject}): assert (get_from_module("TestObject", globals(), "test_generic_utils") == CustomObject)
def get(identifier, kwargs=None): if K.backend() == 'tensorflow': # Wrap TF optimizer instances if isinstance(identifier, tf.train.Optimizer): return TFOptimizer(identifier) # Instantiate a Keras optimizer return get_from_module(identifier, globals(), 'optimizer', instantiate=True, kwargs=kwargs)
def get(identifier, kwargs=None): return get_from_module(identifier, globals(), 'similarity', instantiate=False, kwargs=kwargs)
def get(identifier, kwargs=None): return get_from_module(identifier, globals(), 'regularizer', instantiate=True, kwargs=kwargs)
def get(identifier, **kwargs): return get_from_module(identifier, globals(), 'initialization', kwargs=kwargs)
def get(identifier, kwargs=None): return get_from_module(identifier, globals(), 'optimizer', instantiate=True, kwargs=kwargs)
def get(identifier): return get_from_module(identifier, globals(), 'fusions')
def get(identifier, **kwargs): return get_from_module(identifier, globals(), 'initialization', kwargs=kwargs)
def get(identifier): return get_from_module(identifier, globals(), 'objective')
def get(identifier): return get_from_module(identifier, globals(), 'metric')
def get(identifier): return get_from_module(identifier, globals(), 'policy', instantiate=True)
def get(identifier): return get_from_module(identifier, globals(), 'policy', instantiate=True)