MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
The VocabularyCharacters class manages the data vocabulary of characters. More...
Public Member Functions | |
VocabularyCharacter (Random random, bool bAddBos, bool bAddEos, bool bEnablePad) | |
The constructor. More... | |
void | Add (char ch) |
Adds a new character to the vocabulary. More... | |
void | Add (string str) |
Add a string of characters to the vocabulary. More... | |
int | Build () |
Builds the vocabulary from all characters added. More... | |
int | BuildFromString (string strData) |
Build the vocabulary from a string. More... | |
int[] | CreateTarget (int[] rgSrc) |
Create a target that is offset from the source by one and ends with a EOS. More... | |
List< int > | Tokenize (string str1, bool bMustExist=true) |
Tokenize a character into its corresponding index token. More... | |
int[] | Tokenize (string str, bool bAddBos, bool bAddEos) |
Tokenize a string of data. More... | |
string | Detokenize (int nIdxToken, bool bIgnoreBos, bool bIgnoreEos) |
Detokenize an index token into its corresponding character. More... | |
string | Detokenize (float[] rgf, bool bIgnoreBos, bool bIgnoreEos) |
Detokenize an array into a string. More... | |
Properties | |
int? | Count [get] |
Returns the size of the vocabulary. More... | |
char | BOS [get] |
Returns the special BOS character. More... | |
char | EOS [get] |
Returns the special EOS character. More... | |
Properties inherited from MyCaffe.layers.gpt.IVocabulary | |
int | Count [get] |
Returns the size of the vocabulary. More... | |
char | BOS [get] |
Returns the special BOS character. More... | |
char | EOS [get] |
Returns the special EOS character. More... | |
The VocabularyCharacters class manages the data vocabulary of characters.
Definition at line 12 of file VocabularyCharacter.cs.
MyCaffe.layers.gpt.VocabularyCharacter.VocabularyCharacter | ( | Random | random, |
bool | bAddBos, | ||
bool | bAddEos, | ||
bool | bEnablePad | ||
) |
The constructor.
random | Specifies the random number generator used. |
bAddBos | Specifies to include the special BOS character in the vocabulary. |
bAddEos | Specifies to include the special EOS character in the vocabulary. |
bEnablePad | Specifies to enable the 0 based padding by adding the 0 pad key to the vocabulary. |
Definition at line 28 of file VocabularyCharacter.cs.
void MyCaffe.layers.gpt.VocabularyCharacter.Add | ( | char | ch | ) |
Adds a new character to the vocabulary.
ch | Specifies the character |
Definition at line 54 of file VocabularyCharacter.cs.
void MyCaffe.layers.gpt.VocabularyCharacter.Add | ( | string | str | ) |
Add a string of characters to the vocabulary.
str | Specifies the string to add. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 64 of file VocabularyCharacter.cs.
int MyCaffe.layers.gpt.VocabularyCharacter.Build | ( | ) |
Builds the vocabulary from all characters added.
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 76 of file VocabularyCharacter.cs.
int MyCaffe.layers.gpt.VocabularyCharacter.BuildFromString | ( | string | strData | ) |
Build the vocabulary from a string.
strData | Specifies the data to build the vocabulary from. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 100 of file VocabularyCharacter.cs.
int[] MyCaffe.layers.gpt.VocabularyCharacter.CreateTarget | ( | int[] | rgSrc | ) |
Create a target that is offset from the source by one and ends with a EOS.
rgSrc | Specifies the source to create the target from. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 131 of file VocabularyCharacter.cs.
string MyCaffe.layers.gpt.VocabularyCharacter.Detokenize | ( | float[] | rgf, |
bool | bIgnoreBos, | ||
bool | bIgnoreEos | ||
) |
Detokenize an array into a string.
rgf | Specifies the array of tokens to detokenize. |
bIgnoreBos | Specifies to ignore the BOS token. |
bIgnoreEos | Specifies to ignore the EOS token. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 235 of file VocabularyCharacter.cs.
string MyCaffe.layers.gpt.VocabularyCharacter.Detokenize | ( | int | nIdxToken, |
bool | bIgnoreBos, | ||
bool | bIgnoreEos | ||
) |
Detokenize an index token into its corresponding character.
nIdxToken | Specifies the token to detokenize. |
bIgnoreBos | Specifies to ignore the BOS token. |
bIgnoreEos | Specifies to ignore the EOS token. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 199 of file VocabularyCharacter.cs.
int[] MyCaffe.layers.gpt.VocabularyCharacter.Tokenize | ( | string | str, |
bool | bAddBos, | ||
bool | bAddEos | ||
) |
Tokenize a string of data.
str | Specifies the string to tokenize. |
bAddBos | Specifies to add the BOS at the start of the tokenized data. |
bAddEos | Specifies to add the EOS to the end of the tokenized data. |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 174 of file VocabularyCharacter.cs.
List< int > MyCaffe.layers.gpt.VocabularyCharacter.Tokenize | ( | string | str1, |
bool | bMustExist = true |
||
) |
Tokenize a character into its corresponding index token.
str1 | Specifies a single element (character or word) to tokenize. |
bMustExist | Optionally, specifies to throw an error if the item is not in the vocabulary (default = true). |
Implements MyCaffe.layers.gpt.IVocabulary.
Definition at line 147 of file VocabularyCharacter.cs.
|
get |
Returns the special BOS character.
Definition at line 113 of file VocabularyCharacter.cs.
|
get |
Returns the size of the vocabulary.
Definition at line 45 of file VocabularyCharacter.cs.
|
get |
Returns the special EOS character.
Definition at line 121 of file VocabularyCharacter.cs.