Keraflow
Deep Learning for Python.
|
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... | |
Generic utils for keraflow.
def keraflow.utils.generic_utils.average_dicts | ( | dicts | ) |
Average the values for each key in the dicts.
dicts | list 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.
dicts | list 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).
module_name | str. 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 . |
identifier | str/object. The name of the target class. If an object is passed, we simply returned it. |
call_constructor | boolean. If True, call the target class' constructor with kwargs |
kwargs | keyword 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.
obj | object to be packed. |
include_kwargs | list 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.
obj | object. |
class_name
and params
. 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
.
init_config | dict. Results generated by serialize. |