Operator Definition¶
From Tutorial 1, we know that the preprocessing in Pipeline
and the training in Network
can be divided into several sub-tasks:
- Pipeline:
Expand_dim
->Minmax
- Network:
ModelOp
->CrossEntropy
->UpdateOp
Each sub-task is a modular unit that takes inputs, performs an operation, and then produces outputs. We therefore call these sub-tasks Operator
s, and they form the building blocks of the FastEstimator Pipeline
and Network
APIs.
Operator Structure¶
An Operator has 3 main components:
- inputs: the key(s) of input data
- outputs: the key(s) of output data
- forward function: the transformation to be applied
The base class constructor also takes a mode
argument, but for now we will ignore it since mode
will be discussed extensively in Tutorial 9.
class Op:
def __init__(self, inputs=None, outputs=None, mode=None):
self.inputs = inputs
self.outputs = outputs
self.mode = mode
def forward(self, data, state):
return data
Operator Expression¶
In this section, we will demonstrate how different tasks can be concisely expressed in operators.
Single Operator¶
If the task only requires taking one feature as input and transforming it to overwrite the old feature (e.g, Minmax
), it can be expressed as:
If the task involves taking multiple features and overwriting them respectively (e.g, rotation of both an image and its mask), it can be expressed as:
Multiple Operators¶
If there are two Operator
s executing in a sequential manner (e.g, Minmax
followed by Transpose
), it can be expressed as:
`Operator`s can also easily handle more complicated data flows:
Deep Learning Examples using Operators¶
In this section, we will show you how deep learning tasks can be modularized into combinations of Operator
s. Please note that the Operator
expressions we provide in this section are essentially pseudo-code. Links to full python examples are also provided.
Image Classification:¶
DC-GAN:¶
Adversarial Hardening:¶