def deserialize(name, custom_objects=None): '''deserialize Keras Object''' return deserialize_keras_object( name, module_objects=globals(), custom_objects=custom_objects, printable_module_name='activation function')
def get_quantizer(identifier): """Gets the quantizer. Args: identifier: An quantizer, which could be dict, string, or callable function. Returns: A quantizer class or quantization function from this file. For example, Quantizer classes: quantized_bits, quantized_po2, quantized_relu_po2, binary, stochastic_binary, ternary, stochastic_ternary, etc. Quantization functions: binary_sigmoid, hard_sigmoid, soft_sigmoid, etc. Raises: ValueError: An error occurred when quantizer cannot be interpreted. """ if identifier is None: return None if isinstance(identifier, dict): return deserialize_keras_object(identifier, module_objects=globals(), printable_module_name="quantizer") elif isinstance(identifier, six.string_types): return safe_eval(identifier, globals()) elif callable(identifier): return identifier else: raise ValueError("Could not interpret quantizer identifier: " + str(identifier))
def callback_from_config(config): if 'class_name' not in config: raise ValueError('class_name is needed to define callback') if 'config' not in config: # auto add empty config for callback with only class_name config['config'] = {} return deserialize_keras_object(config, module_objects=globals(), custom_objects=Callbacks().callbacks, printable_module_name='callback')
def deserialize(config, custom_objects=None): return deserialize_keras_object( config, module_objects=globals(), custom_objects=custom_objects, printable_module_name="ProtoFlow Initializers")