The third component necessary for building a deep learning model. Models perform some computation given their input variables. Models have three necessary functions to operate at the basic level:

  • get_inputs(): returns the input or list of inputs to the model (theano variables or expressions).
  • get_outputs(): returns the output or list of outputs of the model computation (theano expression).
  • get_params(): returns the dictionary of {string_name: theano variable} representing the model's internal parameters.

Please see the full documentation for all the other methods possible in a Model class.

Connecting models together

Generally, you can connect Models in three ways:

  • inputs: use the inputs= parameter to set the input for the model's computation. Inputs must be a tuple (or list of tuples) that include the shape monad and the input expression. See Variables to learn about the shape monad.
  • hiddens: use the hiddens= parameter to replace the hidden representation for the model (if applicable). This is most often used for generative models where the outputs come from a hidden representation.
  • params: use the params= parameter to replace some or all of the internal model parameters. The parameters will be replaced based on the string key from the input dictionary.

Containers

We have a basic Prototype container to let you easily hook up models sequentially (similar to Torch's Sequential construct). With a Prototype, you can .add(model_class_type, **kwargs) to instantiate a Model with the given class and automatically set its inputs to the previous model's outputs. All of the models are kept in the internal models attribute as a list. Please refer to the documentation linked above to learn more about the Prototype container.