.FastAIAbstractBlockTask

abstract type defined in module FastAI


			abstract type AbstractBlockTask <: LearningTask

Abstract supertype for learning tasks that derive their functionality from Blocks and Encodings.

These learning tasks require you only to specify blocks and encodings by defining which blocks of data show up at which stage of the pipeline. Generally, a subtype will have a field blocks of type NamedTuple that contains this information and a field encodings of encodings that are applied to samples. They can be accessed with getblocks and getencodings respectively. For example, SupervisedTask represents a learning task where each sample consists of an input and a target.


			
			
			
			using
			
			 

	
			FastAI
			,
			
			 
			FastVision
			

			
			task
			 
			=
			 
			

	
			SupervisedTask
			(
			
    
			
			(
			
			

	
			Image
			{
			2
			}
			(
			)
			,
			 
			

	
			Label
			(
			
			[
			
			"
			cat
			"
			,
			 
			
			"
			dog
			"
			]
			)
			)
			,
			
    
			
			(
			

	
			ImagePreprocessing
			(
			)
			,
			 
			

	
			OneHot
			(
			)
			,
			)
			

			)
			

			
			

	
			FastAI
			.
			

	
			getblocks
			(
			task
			)

			(input = Image{2}(), target = Label{String}(["cat", "dog"]), sample = (Image{2}(), Label{String}(["cat", "dog"])), encodedsample = (FastVision.ImageTensor{2}(3), FastAI.OneHotTensor{0, String}(["cat", "dog"])), x = FastVision.ImageTensor{2}(3), y = FastAI.OneHotTensor{0, String}(["cat", "dog"]), ŷ = FastAI.OneHotTensor{0, String}(["cat", "dog"]), pred = Label{String}(["cat", "dog"]))

To implement a new AbstractBlockTask either

  • use the helper BlockTask (simpler)

  • or subtype AbstractBlockTask (allows customization through dispatch)

Blocks and interfaces

To support different learning task interfaces, a AbstractBlockTask's blocks need to contain different blocks. Below we list first block names with descriptions, and afterwards relevant interface functions and which blocks are required to use them.

Blocks

Each name corresponds to a key of the named tuple blocks = getblocks(task)). A block is referred to with blocks.$name and an instance of data from a block is referred to as $name.

  • blocks.sample: The most important block, representing one full observation of unprocessed data. Data containers used with a learning task should have compatible observations, i.e. checkblock(blocks.sample, data[i]).

  • blocks.x: Data that will be fed into the model, i.e. (neglecting batching) model(x) should work

  • blocks.ŷ: Data that is output by the model, i.e. (neglecting batching) checkblock(blocks.ŷ, model(x))

  • blocks.y: Data that is compared to the model output using a loss function, i.e. lossfn(ŷ, y)

  • blocks.encodedsample: An encoded version of blocks.sample. Will usually correspond to encodedblockfilled(getencodings(task), blocks.sample).

Interfaces/functionality and required blocks:

Core:

Training:

Visualization:

Testing: