"Characters" (Net Decoder)
NetDecoder["Characters"]
represents a decoder that converts a sequence of probability vectors to a string of ASCII characters.
NetDecoder[{"Characters",table}]
represents a decoder that converts probability vectors into a string composed of characters in the list table.
NetDecoder[{"Characters",table,"param"value,…}]
represents a decoder in which additional parameters have been specified.
Details
- NetDecoder[…][input] applies the decoder to an input to produce an output.
- NetDecoder[…][{input1,input2,…}] applies the decoder to a list of inputs to produce a list of outputs.
- The input to the decoder input is either a vector of probabilities or a sequence of probability vectors. Each probability vector sums to 1. For NetDecoder["Characters"], the length of each probability vector is the number of ASCII characters, 97. For NetDecoder[{"Characters",table}], the length of each probability vector is the number of characters in table.
- NetDecoder[…][input] returns a string.
- The mapping from probability vectors to characters specified by table can have the following forms:
-
"c1c2…" map each character ci to successive available codes "c1c2…"n map all characters ci to code n "c1c2…"Automatic map all characters ci to the next available code n;;mspec map characters between n and m to spec {spec1,spec2,…} assign codes in sequence from the speci - The following symbolic character groups can be used in the table:
-
Automatic all printable ASCII characters, plus space, tab and newline LetterCharacter the letters a through z and A through Z DigitCharacter the digits 0 through 9 WordCharacter the union of LetterCharacter and DigitCharacter PunctuationCharacter all visible ASCII punctuation characters WhitespaceCharacter space, tab and newline StartOfString virtual character that occurs before the beginning of the string EndOfString virtual character that occurs after the end of the string _ any otherwise unassigned character - NetDecoder["Characters"] is suitable for typical English prose and consists of all printable ASCII characters, as well as tab, space and newline.
- NetDecoder["Characters"] is equivalent to NetDecoder[{"Characters",{"\t","\n",FromCharacterCode[Range[32,126]]}}].
- A decoder can be attached to an output port of a net by specifying "port"->NetDecoder[…] when constructing the net.
- NetDecoder[{"Characters",…}][["Alphabet"]] produces a list of the characters recognized by the decoder.
- NetEncoder[NetDecoder[{"Characters",…}]] produces a NetEncoder[{"Characters",…}] with the same encoding as the given decoder.
- NetDecoder[…][data,prop] can be used to calculate a specific property for the input data.
- When a "Characters" decoder is attached to a net, net[data,prop] or net[data,"oport"->prop] can be used to calculate a specific property of the decoded output.
- The "Characters" decoder only supports the bypass property. Setting prop to None bypasses decoding and returns the input to the decoder.
Properties
Examples
open allclose allScope (2)
Create a NumericArray representing a sequence of probability vectors:
Decode the sequence of probabilities:
Properties & Relations (2)
Extract the list of characters recognized by the default "Characters" decoder:
Produce a NetEncoder from a NetDecoder: