MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / ObjAttrParam

Class ObjAttrParam

tensorpack/callbacks/param.py:91–112  ·  view source on GitHub ↗

An attribute of an object can be a hyperparam.

Source from the content-addressed store, hash-verified

89
90
91class ObjAttrParam(HyperParam):
92 """ An attribute of an object can be a hyperparam. """
93
94 def __init__(self, obj, attrname, readable_name=None):
95 """
96 Args:
97 obj: the object
98 attrname (str): the attribute
99 readable_name(str): The name to display and set with. Defaults to be ``attrname``.
100 """
101 self.obj = obj
102 self.attrname = attrname
103 if readable_name is None:
104 self._readable_name = attrname
105 else:
106 self._readable_name = readable_name
107
108 def set_value(self, v):
109 setattr(self.obj, self.attrname, v)
110
111 def get_value(self):
112 return getattr(self.obj, self.attrname)
113
114
115class HyperParamSetter(Callback):

Callers 7

testInterpolationMethod · 0.85
testScheduleMethod · 0.85
get_configFunction · 0.85

Calls

no outgoing calls