Keraflow
Deep Learning for Python.
 All Classes Namespaces Functions Pages
keraflow.utils.generic_utils Namespace Reference

Generic utils for keraflow. More...

Functions

def dict_unify
 Merge dicts so that the resulting dict contains all the keys of the input dicts. More...
 
def average_dicts
 Average the values for each key in the dicts. More...
 
def get_from_module
 Return class (or instance of the class) from keraflow's module with identifier (str). More...
 
def pack_init_param
 Keraflow's default __init__ packer. More...
 
def serialize
 Serialize an object by memorizing its class, and its data members listed in its __init__. More...
 
def unserialize
 The reverse procedure of serialize. More...
 

Detailed Description

Generic utils for keraflow.

Function Documentation

def keraflow.utils.generic_utils.average_dicts (   dicts)

Average the values for each key in the dicts.

Parameters
dictslist of dicts.
def keraflow.utils.generic_utils.dict_unify (   dicts)

Merge dicts so that the resulting dict contains all the keys of the input dicts.

Parameters
dictslist of dicts.
def keraflow.utils.generic_utils.get_from_module (   module_name,
  identifier,
  call_constructor = True,
  kwargs 
)

Return class (or instance of the class) from keraflow's module with identifier (str).

Parameters
module_namestr. The module name where the target class is located. If a keraflow module, keraflow. can be omitted, e.g. keraflow.activations could simply be activations.
identifierstr/object. The name of the target class. If an object is passed, we simply returned it.
call_constructorboolean. If True, call the target class' constructor with kwargs
kwargskeyword arguments. Arguments for instantiating the class.
def keraflow.utils.generic_utils.pack_init_param (   obj,
  include_kwargs = [] 
)

Keraflow's default __init__ packer.

Pack the values of arguments of obj's __init__ by calling serialize on each argument.

Parameters
objobject to be packed.
include_kwargslist of str. Names of keyword arguments to be packed. Useful for packing parent class's arguments.
def keraflow.utils.generic_utils.serialize (   obj)

Serialize an object by memorizing its class, and its data members listed in its __init__.

For complex cases (e.g., the model stucture is not an argument listed in keraflow.models.Model.__init__ ), a class should implement pack_init_param to perform customized behavior.

Parameters
objobject.
Returns
dict. The init config including keys of class_name and params.
See Also
pack_init_param, keraflow.models.model.pack_init_param, keraflow.layers.base.Layer.pack_init_param
def keraflow.utils.generic_utils.unserialize (   init_config)

The reverse procedure of serialize.

To deal with complicated cases, a class should implement unpack_init_param.

Parameters
init_configdict. Results generated by serialize.
See Also
unserialize, keraflow.models.model.unpack_init_param, keraflow.layers.base.Layer.unpack_init_param