MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.layers.gpt.TokenizedDataPairsLayer< T > Class Template Reference

The TokenizedDataPairsLayer loads and tokenizes data for a transformer model where data is loaded in the form: data, pos, target(optional) More...

Inheritance diagram for MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >:
MyCaffe.layers.Layer< T >

Public Member Functions

 TokenizedDataPairsLayer (CudaDnn< T > cuda, Log log, LayerParameter p, IXDatabaseBase db, CancelEvent evtCancel)
 The TokenizedDataPairsLayer constructor. More...
 
override void LayerSetUp (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Setup the layer. More...
 
override void Reshape (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Reshape the top based on the parameter batch and block size. More...
 
List< int > Tokenize (string str, VOCABULARY vocab)
 Tokenize an input string using the internal vocabulary. More...
 
string Detokenize (float[] rg, int nStartIdx, int nCount, VOCABULARY vocab)
 Detokenize a set of tokens from the data specified. More...
 
uint GetVocabuarySize (VOCABULARY src)
 Get the vocabulary size for the specified vocabulary source. More...
 
override BlobCollection< T > PreProcessInput (PropertySet customInput, out int nSeqLen, BlobCollection< T > colBottom=null)
 Preproces the input and return as a set of bottom blobs. More...
 
override bool PreProcessInput (string str, int? nTokIdx, BlobCollection< T > colBottom=null)
 Preproces the input and return as a set of bottom blobs. More...
 
override List< Tuple< string, int, double > > PostProcessLogitsOutput (int nCurIdx, Blob< T > blobLogits, Layer< T > softmax, int nAxis, int nK=1)
 Allows post processing the logits output data by converting the logits to and selecting from the probability distribution produced and detokenizing the results to the string character. More...
 
override string PostProcessFullOutput (Blob< T > blobSoftmax)
 The PostProcessFullOutput allows derivative data layers to post-process the results, usually be detokenizing the data in the blobSoftmax. More...
 
- Public Member Functions inherited from MyCaffe.layers.Layer< T >
 Layer (CudaDnn< T > cuda, Log log, LayerParameter p)
 The Layer constructor. More...
 
void Dispose ()
 Releases all GPU and host resources used by the Layer. More...
 
virtual void ConnectLoss (LossLayer< T > layer)
 Called to connect the loss OnLoss event to a specified layer (typically the data layer). More...
 
virtual List< Tuple< string, int, double > > PostProcessOutput (Blob< T > blobSofmtax, int nK=1)
 The PostProcessOutput allows derivative data layers to post-process the results, converting them back into text results (e.g., detokenizing). More...
 
virtual string PostProcessOutput (int nIdx)
 Convert the index to the word. More...
 
virtual void SetOnDebug (EventHandler< GetWorkBlobArgs< T > > fn)
 Set the OnDebug event. More...
 
virtual void ResetOnDebug (EventHandler< GetWorkBlobArgs< T > > fn)
 Reset the OnDebug event, disabling it. More...
 
virtual bool ReInitializeParameters (WEIGHT_TARGET target)
 Re-initialize the parameters of the layer. More...
 
void SetNetReshapeRequest ()
 Called by the Net when requesting a reshape. More...
 
void SetPhase (Phase phase)
 Changes the layer's Phase to the one specified. More...
 
void Setup (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Implements common Layer setup functionality. More...
 
virtual void SetNetParameterUsed (NetParameter np)
 This function allows other layers to gather needed information from the NetParameters if any, and is called when initialzing the Net. More...
 
void ConvertToBase (BlobCollection< T > col)
 ConvertToBase converts any blobs in a collection that are in half size to the base size. More...
 
double Forward (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Given the bottom (input) Blobs, this function computes the top (output) Blobs and the loss. More...
 
void Backward (BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
 Given the top Blob error gradients, compute the bottom Blob error gradients. More...
 
double loss (int nTopIdx)
 Returns the scalar loss associated with the top Blob at a given index. More...
 
void set_loss (int nTopIdx, double dfLoss)
 Sets the loss associated with a top Blob at a given index. More...
 
virtual bool AllowForceBackward (int nBottomIdx)
 Return whether to allow More...
 
bool param_propagate_down (int nParamIdx)
 Returns whether or not the Layer should compute gradients w.r.t. a parameter at a particular index given by a parameter index. More...
 
void set_param_propagate_down (int nParamIdx, bool bPropagate)
 Sets whether or not the Layer should compute gradients w.r.t. a parameter at a particular index given by a parameter index. More...
 
void SetEnablePassthrough (bool bEnable)
 Enables/disables the pass-through mode. More...
 

Protected Member Functions

override void dispose ()
 Release all internal blobs. More...
 
override void setup_internal_blobs (BlobCollection< T > col)
 Add all internal blobs. More...
 
override void forward (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Run the Forward computation, which fills the data into the top (output) Blobs. More...
 
override void backward (BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
 Not implemented - data Layers do not perform backward.. More...
 
- Protected Member Functions inherited from MyCaffe.layers.Layer< T >
void dispose (ref Layer< T > l)
 Helper method used to dispose internal layers. More...
 
void dispose (ref Blob< T > b)
 Helper method used to dispose internal blobs. More...
 
void dispose (ref BlobCollection< T > rg, bool bSetToNull=true)
 Dispose the blob collection. More...
 
GetIterationArgs getCurrentIteration ()
 Fires the OnGetIteration event to query the current iteration. More...
 
long convert_to_full (int nCount, long hMem)
 Convert half memory to full memory. More...
 
void convert (BlobCollection< T > col)
 Convert a collection of blobs from / to half size. More...
 
virtual bool reshapeNeeded (BlobCollection< T > colBottom, BlobCollection< T > colTop, bool bReset=true)
 Tests the shapes of both the bottom and top blobs and if they are the same as the previous sizing, returns false indicating that no reshape is needed. More...
 
bool compareShapes (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Compare the shapes of the top and bottom and if the same, return true, otherwise false. More...
 
void setShapes (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Set the internal shape sizes - used when determining if a Reshape is necessary. More...
 
void CheckBlobCounts (BlobCollection< T > colBottom, BlobCollection< T > colTop)
 Called by the Layer::Setup function to check the number of bottom (input) and top (output) Blobs provided match the expected number of blobs expected via the {EactNum,Min,Max}{Bottom,Top}Blobs functions. More...
 
void SetLossWeights (BlobCollection< T > colTop)
 Called by Layer::Setup to initialize the weights associated with any top (output) Blobs in the loss function ans store non-zero loss weights in the diff Blob. More...
 
LayerParameter convertLayerParam (LayerParameter pChild, LayerParameter pParent)
 Called to convert a parent LayerParameterEx, used in blob sharing, with a child layer parameter. More...
 
bool shareParameter (Blob< T > b, List< int > rgMinShape, bool bAllowEndsWithComparison=false)
 Attempts to share a parameter Blob if another parameter Blob with the same name and accpetable size is found. More...
 
bool shareLayerBlob (Blob< T > b, List< int > rgMinShape)
 Attempts to share a Layer Blob if another parameter Blob with the same name and acceptable size is found. More...
 
bool shareLayerBlobs (Layer< T > layer)
 Attempts to share the Layer blobs and internal_blobs with matching names and sizes with those in another matching layer. More...
 
virtual WorkspaceArgs getWorkspace ()
 Returns the WorkspaceArgs used to share a workspace between Layers. More...
 
virtual bool setWorkspace (ulong lSizeInBytes)
 Sets the workspace size (in items) and returns true if set, false otherwise. More...
 
void check_nan (Blob< T > b)
 Checks a Blob for NaNs and throws an exception if found. More...
 
convert (double df)
 Converts a double to a generic. More...
 
convert (float f)
 Converts a float to a generic. More...
 
double convertD (T df)
 Converts a generic to a double value. More...
 
float convertF (T df)
 Converts a generic to a float value. More...
 
double[] convertD (T[] rg)
 Converts an array of generic values into an array of double values. More...
 
T[] convert (double[] rg)
 Converts an array of double values into an array of generic values. More...
 
float[] convertF (T[] rg)
 Converts an array of float values into an array of generic values. More...
 
T[] convert (float[] rg)
 Converts an array of float values into an array of generic values. More...
 
int val_at (T[] rg, int nIdx)
 Returns the integer value at a given index in a generic array. More...
 
Size size_at (Blob< T > b)
 Returns the Size of a given two element Blob, such as one that stores Blob size information. More...
 

Properties

override int? ExactNumBottomBlobs [get]
 Specifies the exact number of bottom blobs (TRAIN|TEST: 0, RUN:2 encin, decin) More...
 
override int ExactNumTopBlobs [get]
 Returns the minimum number of required top (output) Blobs: enc_in, dec_in, dec_out, e_mask, d_mask More...
 
override bool SupportsPreProcessing [get]
 Specifies that this layer supports preprocessing. More...
 
override bool SupportsPostProcessingLogits [get]
 Specifies that this layer supports post processing the logits. More...
 
- Properties inherited from MyCaffe.layers.Layer< T >
LayerParameter.? LayerType parent_layer_type [get]
 Optionally, specifies the parent layer type (e.g. LOSS, etc.) More...
 
virtual bool SupportsPreProcessing [get]
 Should return true when PreProcessing methods are overriden. More...
 
virtual bool SupportsPostProcessing [get]
 Should return true when pre PostProcessing methods are overriden. More...
 
virtual bool SupportsPostProcessingLogits [get]
 Should return true when pre PostProcessingLogits methods are overriden. More...
 
virtual bool SupportsPostProcessingFullOutput [get]
 Should return true when PostProcessingFullOutput is supported. More...
 
BlobCollection< T > blobs [get]
 Returns the collection of learnable parameter Blobs for the Layer. More...
 
BlobCollection< T > internal_blobs [get]
 Returns the collection of internal Blobs used by the Layer. More...
 
LayerParameter layer_param [get]
 Returns the LayerParameter for this Layer. More...
 
LayerParameter.LayerType type [get]
 Returns the LayerType of this Layer. More...
 
virtual int ExactNumBottomBlobs [get]
 Returns the exact number of bottom (input) Blobs required by the Layer, or -1 if no exact number is required. More...
 
virtual int MinBottomBlobs [get]
 Returns the minimum number of bottom (input) Blobs required by the Layer, or -1 if no minimum number is required. More...
 
virtual int MaxBottomBlobs [get]
 Returns the maximum number of bottom (input) Blobs required by the Layer, or -1 if no maximum number is required. More...
 
virtual int ExactNumTopBlobs [get]
 Returns the exact number of top (output) Blobs required by the Layer, or -1 if no exact number is required. More...
 
virtual int MinTopBlobs [get]
 Returns the minimum number of top (output) Blobs required by the Layer, or -1 if no minimum number is required. More...
 
virtual int MaxTopBlobs [get]
 Returns the maximum number of top (output) Blobs required by the Layer, or -1 if no maximum number is required. More...
 
virtual bool EqualNumBottomTopBlobs [get]
 Returns true if the Layer requires and equal number of bottom (input) and top (output) Blobs. More...
 
virtual bool AutoTopBlobs [get]
 Return whether "anonymous" top (output) Blobs are created automatically by the Layer. More...
 
double forward_timing [get]
 Returns the timing of the last forward pass in milliseconds. More...
 
double forward_timing_average [get]
 Returns the average timing of the forward passes in milliseconds. More...
 
double backward_timing [get]
 Returns the timing of the last backward pass in milliseconds. More...
 
double backward_timing_average [get]
 Returns the average timing of the backward passes in milliseconds. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MyCaffe.layers.Layer< T >
static Layer< T > Create (CudaDnn< T > cuda, Log log, LayerParameter p, CancelEvent evtCancel, IXDatabaseBase db=null, TransferInput trxinput=null)
 Create a new Layer based on the LayerParameter. More...
 
- Protected Attributes inherited from MyCaffe.layers.Layer< T >
LayerParameter.LayerType m_type = LayerParameter.LayerType._MAX
 Specifies the Layer type. More...
 
CudaDnn< T > m_cuda
 Specifies the CudaDnn connection to Cuda. More...
 
Log m_log
 Specifies the Log for output. More...
 
LayerParameter m_param
 Specifies the LayerParameter describing the Layer. More...
 
Phase m_phase
 Specifies the Phase under which the Layer is run. More...
 
BlobCollection< T > m_colBlobs
 Specifies the learnable parameter Blobs of the Layer. More...
 
BlobCollection< T > m_colInternalBlobs = new BlobCollection<T>()
 Specifies internal blobs used by the layer. More...
 
DictionaryMap< bool > m_rgbParamPropagateDown
 Specifies whether or not to compute the learnable diff of each parameter Blob. More...
 
DictionaryMap< double > m_rgLoss
 Specifies the loss values that indeicate whether each top (output) Blob has a non-zero weight in the objective function.. More...
 
m_tOne
 Specifies a generic type equal to 1.0. More...
 
m_tZero
 Specifies a generic type equal to 0.0. More...
 
bool m_bEnablePassthrough = false
 Enables/disables the pass-through mode for the layer. Default = false. More...
 
bool m_bUseHalfSize = false
 Specifies that the half size of the top (if any) should be converted to the base size. More...
 
bool m_bConvertTopOnFwd = false
 Specifies whether or not the layer should convert the top on the forward pass when using half sized memory (typically only done with input data). More...
 
bool m_bConvertTopOnBwd = true
 Specifies whether or not to convert the top on the backward pass when using half sized memory (typically not done on loss layers). More...
 
bool m_bConvertBottom = true
 Specifies whether or not the layer should convert the bottom when using half sized memory. More...
 
bool m_bReshapeOnForwardNeeded = true
 Specifies whether or not the reshape on forward is needed or not. More...
 
bool m_bNetReshapeRequest = false
 Specifies whether the reshape is requested from a Net.Reshape call or not. More...
 
LayerParameter.? LayerType m_parentLayerType = null
 Specifies the layer type of the parent. More...
 
- Events inherited from MyCaffe.layers.Layer< T >
EventHandler< WorkspaceArgsOnGetWorkspace
 Specifies the OnGetWorkspace event that fires when the getWorkspace() function is called by a layer to get a shareable workspace to conserve GPU memory. More...
 
EventHandler< WorkspaceArgsOnSetWorkspace
 Specifies the OnSetWorkspace event that fires when the setWorkspace() function is called by a layer to get a shareable workspace to conserve GPU memory. More...
 
EventHandler< GetIterationArgsOnGetIteration
 Specifies the OnGetIteration event that fires when a layer needs to get the current iteration from the solver. More...
 
EventHandler< GetWorkBlobArgs< T > > OnDebug
 Specifies the OnGetWorkBlob event that is only supported when debugging to get a work blob from the primary Net holding this layer. More...
 

Detailed Description

The TokenizedDataPairsLayer loads and tokenizes data for a transformer model where data is loaded in the form: data, pos, target(optional)

Template Parameters
TSpecifies the base type float or double. Using float is recommended to conserve GPU memory.

Definition at line 27 of file TokenizedDataPairsLayer.cs.

Constructor & Destructor Documentation

◆ TokenizedDataPairsLayer()

The TokenizedDataPairsLayer constructor.

Parameters
cudaSpecifies the CudaDnn connection to Cuda.
logSpecifies the Log for output.
pProvides TokenizedDataPairsParameter model_data_param with options:
  • source. The encoder input data source.
  • target. The decoder input/output data source.
  • batch_size. The batch size
  • time_steps. The maximum number of time steps.
  • input_dim. The input dimension of the encoder input.
  • sample_size. The number of samples to load for training.
  • shuffle. Whether or not to shuffle the data.
dbSpecifies the external database to use.
evtCancelSpecifies the CancelEvent used to cancel any pre-fetching operations.

Definition at line 82 of file TokenizedDataPairsLayer.cs.

Member Function Documentation

◆ backward()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.backward ( BlobCollection< T >  colTop,
List< bool >  rgbPropagateDown,
BlobCollection< T >  colBottom 
)
protectedvirtual

Not implemented - data Layers do not perform backward..

Implements MyCaffe.layers.Layer< T >.

Definition at line 384 of file TokenizedDataPairsLayer.cs.

◆ Detokenize()

string MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.Detokenize ( float[]  rg,
int  nStartIdx,
int  nCount,
VOCABULARY  vocab 
)

Detokenize a set of tokens from the data specified.

Parameters
rgSpecifies an array of tokens.
nStartIdxSpecifies the start index.
nCountSpecifies the number of tokens to detokenize.
vocabSpecifies the vocabulary to use: ENCODER or DECODER.
Returns
The detokenized string is returned.

Definition at line 426 of file TokenizedDataPairsLayer.cs.

◆ dispose()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.dispose ( )
protectedvirtual

Release all internal blobs.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 95 of file TokenizedDataPairsLayer.cs.

◆ forward()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.forward ( BlobCollection< T >  colBottom,
BlobCollection< T >  colTop 
)
protectedvirtual

Run the Forward computation, which fills the data into the top (output) Blobs.

Parameters
colBottomNot used.
colToptop output blob vector (length 2-5)
  1. $ (N \times C \times 1 \times 1) $ (TEXT input) the data outputs.
  2. $ (N \times C \times 1 \times 1) $ the position outputs.
  3. $ (N \times C \times 1 \times 1) $ (TEXT input, only on training and testing) the target outputs ENCODER mask
  4. $ (N \times C \times 1 \times 1) $ (1's on each input, otherwise 0's) the encoder mask. DECODER mask
  5. $ (N \times C \times C \times 1) $ (1's on each input, otherwise 0's. Duplicated across C channels, overlaid with triangle mask - see remarks.) the encoder mask.

The encoder and decoder masks use the following formats.

Encoder Mask: shape = (batch, seq_len, 1) The sequence length is filled with 1 where data exists in each sequence, and 0 otherwise. For example, when using a sequence length of 4 and batch = 3, the following input:

encoder input encoder mask
shape = (3,4) (3,4)
[33, 44, 22, 55] [ 1, 1, 1, 1]
[44, 33, 0, 0 ] has mask -> [ 1, 1, 0, 0]
[88, 99, 22, 0 ] [ 1, 1, 1, 0]

Decoder Mask: shape (batch, seq_len, seq_len) The decoder mask is first filled with a mask similar to the encoder mask, whre each sequence for each entry is duplicated for the number of sequences high to create an initial mask like the following. Next a triangular mask is anded to avoid right side info.

decoder input encoder like mask triangular mask final decoder mask
shape = (3,4) (3,4,4) (3,4,4) (3,4,4)
[33, 44, 22, 55] [ 1, 1, 1, 1] [ 1, 0, 0, 0] [ 1, 0, 0, 0]
[ 1, 1, 1, 1] [ 1, 1, 0, 0] [ 1, 1, 0, 0]
[ 1, 1, 1, 1] -and-> [ 1, 1, 1, 0] = [ 1, 1, 1, 0]
[ 1, 1, 1, 1] [ 1, 1, 1, 1] [ 1, 1, 1, 1]
[44, 33, 0, 0 ] has mask -> [ 1, 1, 0, 0] [ 1, 0, 0, 0] [ 1, 0, 0, 0]
[ 1, 1, 0, 0] [ 1, 1, 0, 0] [ 1, 1, 0, 0]
[ 1, 1, 0, 0] -and-> [ 1, 1, 1, 0] = [ 1, 1, 0, 0]
[ 1, 1, 0, 0] [ 1, 1, 1, 1] [ 1, 1, 0, 0]
[88, 99, 22, 0 ] [ 1, 1, 1, 0] [ 1, 0, 0, 0] [ 1, 0, 0, 0]
[ 1, 1, 1, 0] [ 1, 1, 0, 0] [ 1, 1, 0, 0]
[ 1, 1, 1, 0] -and-> [ 1, 1, 1, 0] = [ 1, 1, 1, 0]
[ 1, 1, 1, 0] [ 1, 1, 1, 1] [ 1, 1, 1, 0]


Implements MyCaffe.layers.Layer< T >.

Definition at line 355 of file TokenizedDataPairsLayer.cs.

◆ GetVocabuarySize()

uint MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.GetVocabuarySize ( VOCABULARY  src)

Get the vocabulary size for the specified vocabulary source.

Parameters
srcSpecifies the vocabulary source (ENCODER or DECODER).
Returns
The vocabulary size is returned.

Definition at line 437 of file TokenizedDataPairsLayer.cs.

◆ LayerSetUp()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.LayerSetUp ( BlobCollection< T >  colBottom,
BlobCollection< T >  colTop 
)
virtual

Setup the layer.

Parameters
colBottomNot used.
colTopSpecifies the collection of top (output) Blobs.

Implements MyCaffe.layers.Layer< T >.

Definition at line 138 of file TokenizedDataPairsLayer.cs.

◆ PostProcessFullOutput()

override string MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.PostProcessFullOutput ( Blob< T >  blobSoftmax)
virtual

The PostProcessFullOutput allows derivative data layers to post-process the results, usually be detokenizing the data in the blobSoftmax.

Parameters
blobSoftmaxSpecifies the data to be post processed.
Returns
A string of the post processed data is returned.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 588 of file TokenizedDataPairsLayer.cs.

◆ PostProcessLogitsOutput()

override List< Tuple< string, int, double > > MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.PostProcessLogitsOutput ( int  nCurIdx,
Blob< T >  blobLogits,
Layer< T >  softmax,
int  nAxis,
int  nK = 1 
)
virtual

Allows post processing the logits output data by converting the logits to and selecting from the probability distribution produced and detokenizing the results to the string character.

Parameters
nCurIdxSpecifies the current index being processed, or -1 for the last index.
blobLogitsSpecifies the output of the last inner product layer.
softmaxSpecifies the softmax layer.
nAxisSpecifies the axis of the softmax layer.
nKSpecifies the TopK max items of the logits to use, or 0 to ignore.
Returns
The detokenized data is returned.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 528 of file TokenizedDataPairsLayer.cs.

◆ PreProcessInput() [1/2]

override BlobCollection< T > MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.PreProcessInput ( PropertySet  customInput,
out int  nSeqLen,
BlobCollection< T >  colBottom = null 
)
virtual

Preproces the input and return as a set of bottom blobs.

Parameters
customInputSpecifies the custom text input.
nSeqLenSpecifies the sequence length.
colBottomThe output is placed in the bottom blobs as: tokidx, pos
Returns
The bottom blob collection is returned.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 450 of file TokenizedDataPairsLayer.cs.

◆ PreProcessInput() [2/2]

override bool MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.PreProcessInput ( string  str,
int?  nTokIdx,
BlobCollection< T >  colBottom = null 
)
virtual

Preproces the input and return as a set of bottom blobs.

Parameters
strSpecifies the string input, can be null.
nTokIdxSpecifies the token input.
colBottomThe output is placed in the bottom blobs as: tokidx, pos
Returns
The bottom blob collection is returned.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 494 of file TokenizedDataPairsLayer.cs.

◆ Reshape()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.Reshape ( BlobCollection< T >  colBottom,
BlobCollection< T >  colTop 
)
virtual

Reshape the top based on the parameter batch and block size.

Parameters
colBottomSpecifies the collection of bottom (input) Blobs - Used only during RUN phase.
colTopSpecifies the collection of top (output) Blobs.

Implements MyCaffe.layers.Layer< T >.

Definition at line 240 of file TokenizedDataPairsLayer.cs.

◆ setup_internal_blobs()

override void MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.setup_internal_blobs ( BlobCollection< T >  col)
protectedvirtual

Add all internal blobs.

Parameters
colSpecifies the internal blob array.

Reimplemented from MyCaffe.layers.Layer< T >.

Definition at line 112 of file TokenizedDataPairsLayer.cs.

◆ Tokenize()

List< int > MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.Tokenize ( string  str,
VOCABULARY  vocab 
)

Tokenize an input string using the internal vocabulary.

Parameters
strSpecifies the string to tokenize.
vocabSpecifies the vocabulary to use, ENCODER or DECODER.
Returns
A list of tokens corresponding to the input is returned.

Definition at line 410 of file TokenizedDataPairsLayer.cs.

Property Documentation

◆ ExactNumBottomBlobs

override int? MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.ExactNumBottomBlobs
get

Specifies the exact number of bottom blobs (TRAIN|TEST: 0, RUN:2 encin, decin)

Definition at line 120 of file TokenizedDataPairsLayer.cs.

◆ ExactNumTopBlobs

override int MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.ExactNumTopBlobs
get

Returns the minimum number of required top (output) Blobs: enc_in, dec_in, dec_out, e_mask, d_mask

Definition at line 128 of file TokenizedDataPairsLayer.cs.

◆ SupportsPostProcessingLogits

override bool MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.SupportsPostProcessingLogits
get

Specifies that this layer supports post processing the logits.

Definition at line 399 of file TokenizedDataPairsLayer.cs.

◆ SupportsPreProcessing

override bool MyCaffe.layers.gpt.TokenizedDataPairsLayer< T >.SupportsPreProcessing
get

Specifies that this layer supports preprocessing.

Definition at line 391 of file TokenizedDataPairsLayer.cs.


The documentation for this class was generated from the following file: