So right now, much of the data block magic is specialized on supervised learning tasks, e.g. blocklossfn, blockmodel and the visualizations. It would be nice to better support other kinds of tasks as well. The underlying APIs are already pretty general, e.g. encode has no restraints on number of blocks encodings. It's more that right now, BlockMethod assumes a tuple (inputblock, targetblock) and uses that to determine what block the model output is and what blocks are in a batch for visualization.
For the FastAI Q&A @darsnack prepared a variational autoencoder tutorial where the data is really just one image that itself is the target and we ended up having to overwrite some methods to get it to work.
So, the thing that is mostly different for different learning tasks, is how each block of data is used. Below I try to summarize the different kinds of blocks that need to be known to use the block method APIs.
sampleblock i.e. what are the blocks of one sample
outputblock i.e. what block is output by the model
xblock i.e. what block is input to the model
yblock i.e. what block does the loss function compare outputblock to
showpredblocks i.e. what blocks are compared when using showpredictions
showoutputblocks i.e. what blocks are compared when using showoutputs
So right now, much of the data block magic is specialized on supervised learning tasks, e.g.
blocklossfn
,blockmodel
and the visualizations. It would be nice to better support other kinds of tasks as well. The underlying APIs are already pretty general, e.g.encode
has no restraints on number of blocks encodings. It's more that right now,BlockMethod
assumes a tuple(inputblock, targetblock)
and uses that to determine what block the model output is and what blocks are in a batch for visualization.For the FastAI Q&A @darsnack prepared a variational autoencoder tutorial where the data is really just one image that itself is the target and we ended up having to overwrite some methods to get it to work.
So, the thing that is mostly different for different learning tasks, is how each block of data is used. Below I try to summarize the different kinds of blocks that need to be known to use the block method APIs.
sampleblock
i.e. what are the blocks of one sampleoutputblock
i.e. what block is output by the modelxblock
i.e. what block is input to the modelyblock
i.e. what block does the loss function compareoutputblock
toshowpredblocks
i.e. what blocks are compared when usingshowpredictions
showoutputblocks
i.e. what blocks are compared when usingshowoutputs
For a basic supervised learning method, we have
sampleblock = (inputblock, targetblock) = method.blocks
outputblock = yblock
(can be overwritten)xblock, yblock = encode(sampleblock)
predblock = decode(yblock)
(usually same astargetblock
)showoutputblocks = (xblock, yblock, outputblock)
showpredblocks = (inputblock, targetblock, predblock) = decode(showoutputblocks)
For the autoencoder example, we have
sampleblock = inputblock = targetblock = predblock
outputblock = xblock = yblock = encode(sampleblock)
showpredblocks = (inputblock, predblock)
showoutputblocks = (xblock, outputblock)
This is how the blocks are used:
encode() = encode(sampleblock)
encodeinput() = encode(inputblock)
encodetarget() = encode(targetblock)
decodeypred() = decode(outputblock)
decodex() = decode(xblock)
decodey() = decode(yblock)
methodlossfn() = blocklossfn(outputblock, yblock)
methodmodel() = blockmodel(xblock, outputblock, blockbackbone(xblock))
showpredictions() = showblocks(showpredblocks)
showoutputs() = showblocksinterpertable(showoutputblocks)
mocksample() = mockblock(sampleblock)
mockmodel() = mockmodel(xblock, outputblock)