Skip to content

LayerConfig

source

LayerConfig(
   layer_cls, **kwargs
)

LayerConfig

A Layer configuration is a Callable that captures all the arguments of a layer construction except input layers. This allows us to delay calling the constructor a Layer, thus delaying the creation of it's state. LayerConfig object also validate the constructor arguments of its target Layer type.

Note

Layer subtypes have a class method config() you can use as an alternative to importing LayerConfig as: python import tensorx as tx config = tx.Linear.config(n_units=3)

Layer instances have a config field that returns a configuration with the current object configuration python import tensorx as tx y = tx.Linear(tf.ones([2,2])) config = y.config assert "n_units" in config.arg_dict

Attributes

  • layer_cls (Callable[Layer]) : the current Layer subtype for this configuration
  • arg_spec (inspect.FullArgSpec) : argspec (args, var args, defaults, etc) of the constructor of the target class
  • arg_names (Set[str]) : a set of name for the constructor arguments
  • arg_dict (Dict[str,Any]) : dictionary with current argument values for the configuration

Args

  • layer_cls (Callable[Layer]) : a Layer subtype for which we're trying to build a configuration
  • kwargs (Dict[str,Any]) : a dict mapping arg names to values

Methods:

.filter_args

source

.filter_args(
   **kwargs
)

filter_args

filters a given keyword argument dictionary removing any argument that is not present in the constructor for the current Layer type.

Args

  • kwargs (Dict['str',Any]) : keyword arguments to be filtered

Returns

  • new_kwargs (Dict['str',Any]) : new filtered kwargs

.update

source

.update(
   **kwargs
)

update

Updates the config constructor argument dictionary and validates those parameters.

Args

  • kwargs (Dict['str',Any]) : new values for constructor named arguments to be updated