Feature motivation
Let's assume I have an extended model that takes an existing model (both models are zookeeper factories) and adds a bunch of layers on top. The most straightforward way to do this would be as follows:
extended_model: tf.keras.models.Model = ComponentField(
ExtendedModel, base_model=lambda self: self.model
)
However, this raises
TypeError: Keyword arguments passed to `PartialComponent` must be either:
- An immutable value (int, float, bool, string, or None).
- A function or lambda accepting no arguments and returning the
value that should be passed to the component upon instantiation.
- Another `PartialComponent`.Wrapping non-immutable values in a function / lambda allows the values to be lazily evaluated; they won't be created at all if the partial component is never instantiated.
because the lambda function passed to base_model is not allowed to have any arguments. This is problematic, because it simply needs to access the existing model, which is an attribute of the surrounding task. It is also not possible to define this as a property, because ComponentField cannot be used to decorate properties.
For now, I simply have to make the base model a ComponentField in the ExtendModel class, and rely on zookeeper to properly configure it from the surrounding Experiment class, but it looks a bit confusing.
Feature description
It would be very useful if ComponentField detects whether the argument to the lambda function is self, and passes the correct value if this is the case.
Feature motivation
Let's assume I have an extended model that takes an existing model (both models are zookeeper factories) and adds a bunch of layers on top. The most straightforward way to do this would be as follows:
However, this raises
because the lambda function passed to
base_modelis not allowed to have any arguments. This is problematic, because it simply needs to access the existing model, which is an attribute of the surrounding task. It is also not possible to define this as a property, becauseComponentFieldcannot be used to decorate properties.For now, I simply have to make the base model a
ComponentFieldin theExtendModelclass, and rely on zookeeper to properly configure it from the surroundingExperimentclass, but it looks a bit confusing.Feature description
It would be very useful if
ComponentFielddetects whether the argument to the lambda function isself, and passes the correct value if this is the case.