def make_input_pipeline_from_def(def_dict, mode, **kwargs):
"""Creates an InputPipeline object from a dictionary definition.
Args:
def_dict: A dictionary defining the input pipeline.
It must have "class" and "params" that correspond to the class
name and constructor parameters of an InputPipeline, respectively.
mode: A value in tf.contrib.learn.ModeKeys
Returns:
A new InputPipeline object
"""
if not "class" in def_dict:
raise ValueError("Input Pipeline definition must have a class property.")
class_ = def_dict["class"]
if not hasattr(sys.modules[__name__], class_):
raise ValueError("Invalid Input Pipeline class: {}".format(class_))
pipeline_class = getattr(sys.modules[__name__], class_)
# Constructor arguments
params = {}
if "params" in def_dict:
params.update(def_dict["params"])
params.update(kwargs)
return pipeline_class(params=params, mode=mode)
评论列表
文章目录