Skip to contents

Represents a model; possibly a complete model, possibly one in the process of being built up.

This model takes input tensors of shapes shapes_in and pipes them through graph. Input shapes get mapped to input channels of graph. Output shapes are named by the output channels of graph; it is also possible to represent no-ops on tensors, in which case names of input and output should be identical.

ModelDescriptor objects typically represent partial models being built up, in which case the pointer slot indicates a specific point in the graph that produces a tensor of shape pointer_shape, on which the graph should be extended. It is allowed for the graph in this structure to be modified by-reference in different parts of the code. However, these modifications may never add edges with elements of the Graph as destination. In particular, no element of graph$input may be removed by reference, e.g. by adding an edge to the Graph that has the input channel of a PipeOp that was previously without parent as its destination.

In most cases it is better to create a specific ModelDescriptor by training a Graph consisting (mostly) of operators PipeOpTorchIngress, PipeOpTorch, PipeOpTorchLoss, PipeOpTorchOptimizer, and PipeOpTorchCallbacks.

A ModelDescriptor can be converted to a nn_graph via model_descriptor_to_module.

Usage

ModelDescriptor(
  graph,
  ingress,
  task,
  optimizer = NULL,
  loss = NULL,
  callbacks = NULL,
  pointer = NULL,
  pointer_shape = NULL
)

Arguments

graph

(Graph)
Graph of PipeOpModule and PipeOpNOP operators.

ingress

(uniquely named list of TorchIngressToken)
List of inputs that go into graph. Names of this must be a subset of graph$input$name.

task

(Task)
(Training)-Task for which the model is being built. May be necessary for for some aspects of what loss to use etc.

optimizer

(TorchOptimizer | NULL)
Additional info: what optimizer to use.

loss

(TorchLoss | NULL)
Additional info: what loss to use.

callbacks

(A list of CallbackSet or NULL)
Additional info: what callbacks to use.

pointer

(character(2) | NULL)
Indicating an element on which a model is. Points to an output channel within graph: Element 1 is the PipeOp's id and element 2 is that PipeOp's output channel.

pointer_shape

(integer | NULL)
Shape of the output indicated by pointer.

Value

(ModelDescriptor)