# VGSL Specs - rapid prototyping of mixed conv/LSTM networks for images |
#VGSL Specs - 画像用の混合conv / LSTMネットワークのラピッドプロトタイピング |
Variable-size Graph Specification Language (VGSL) enables the specification of a |
可変サイズグラフ仕様言語(VGSL)は、 |
neural network, composed of convolutions and LSTMs, that can process |
処理可能なコンボリューションとLSTMで構成されるニューラルネットワーク |
variable-sized images, from a very short definition string. |
非常に短い定義文字列からの可変サイズの画像。 |
## Applications: What is VGSL Specs good for? |
##適用:VGSL Specsは何のために良いですか? |
VGSL Specs are designed specifically to create networks for: |
VGSL仕様は、特に次の目的でネットワークを作成するように設計されています。 |
* Variable size images as the input. (In one or BOTH dimensions!) |
*入力として可変サイズの画像。 (一次元または二次元で!) |
* Output an image (heat map), sequence (like text), or a category. |
*画像(ヒートマップ)、シーケンス(テキストなど)、またはカテゴリを出力します。 |
* Convolutions and LSTMs are the main computing component. |
*コンボリューションとLSTMが主要なコンピューティングコンポーネントです。 |
* Fixed-size images are OK too! |
*固定サイズの画像もOKです! |
### Model string input and output |
###モデル文字列の入出力 |
A neural network model is described by a string that describes the input spec, |
ニューラルネットワークモデルは、入力仕様を記述する文字列によって記述されます。 |
the output spec and the layers spec in between. Example: |
出力仕様とその間のレイヤ仕様例: |
` | ` |
[1,0,0,3 Ct5,5,16 Mp3,3 Lfys64 Lfx128 Lrx128 Lfx256 O1c105] |
[1,0,0,3 Ct 5,5,16 Mp3,3 Lfys64 Lfx128 Lrx128 Lfx256 O1c105] |
` | ` |
The first 4 numbers specify the size and type of the input, and follow the |
最初の4つの数字は、入力のサイズと種類を指定します。 |
TensorFlow convention for an image tensor: [batch, height, width, depth]. Batch |
画像テンソルのTensorFlow規約:[batch、height、width、depth]バッチ |
is currently ignored, but eventually may be used to indicate a training |
現在無視されていますが、最終的にはトレーニングを示すために使用される可能性があります |
mini-batch size. Height and/or width may be zero, allowing them to be variable. |
ミニバッチサイズ。高さや幅はゼロで、可変にすることができます。 |
A non-zero value for height and/or width means that all input images are |
高さおよび/または幅のゼロ以外の値は、すべての入力画像が |
expected to be of that size, and will be bent to fit if needed. Depth needs to |
そのサイズであることが期待され、そして必要ならば合うように曲げられるでしょう。深さが必要 |
be 1 for greyscale and 3 for color. As a special case, a different value of |
グレースケールは1、カラーは3です。特別な場合として、の異なる値 |
depth, and a height of 1 causes the image to be treated from input as a sequence |
depth、およびheightが1の場合、イメージは入力からシーケンスとして処理されます。 |
of vertical pixel strips. **NOTE THAT THROUGHOUT, x and y are REVERSED from |
垂直ピクセルストリップ**注意してください、xとyは逆になっています |
conventional mathematics,** to use the same convention as TensorFlow. The |
従来の数学、** TensorFlowと同じ規則を使用する。の |
reason TF adopts this convention is to eliminate the need to transpose images on |
TFがこの規約を採用しているのは、上に画像を転置する必要性を排除するためです。 |
input, since adjacent memory locations in images increase x and then y, while |
なぜなら、画像内の隣接するメモリ位置はxを増加させ、次にyを増加させるからです。 |
adjacent memory locations in tensors in TF, and NetworkIO in tesseract increase |
TFではテンソルの隣接メモリ位置、tesseractではNetworkIOの増加 |
the rightmost index first, then the next-left and so-on, like C arrays. |
C配列のように、最初に右端のインデックス、次に左から順にインデックスが続きます。 |
The last "word" is the output specification and takes the form: |
最後の「単語」は出力仕様であり、次の形式を取ります。 |
` | ` |
O(2 |
1 |
0)(l |
s |
c)n output layer with n classes. |
n個のクラスをもつO(2 |
1 |
0)(l |
s |
c)n出力層。 |
2 (heatmap) Output is a 2-d vector map of the input (possibly at |
2(heatmap)出力は入力の2次元ベクトルマップです(おそらく |
different scale). (Not yet supported.) |
異なるスケール)。 (まだサポートされていません。) |
1 (sequence) Output is a 1-d sequence of vector values. |
1(sequence)出力は1-dシーケンスのベクトル値です。 |
0 (category) Output is a 0-d single vector value. |
0(カテゴリ)出力は0-d単一ベクトル値です。 |
l uses a logistic non-linearity on the output, allowing multiple |
lは、出力にロジスティック非線形性を使用します。 |
hot elements in any output vector value. (Not yet supported.) |
任意の出力ベクトル値のホット要素(まだサポートされていません。) |
s uses a softmax non-linearity, with one-hot output in each value. |
sは、ソフトマックス非線形性を使用し、各値にワンホット出力があります。 |
c uses a softmax with CTC. Can only be used with s (sequence). |
cはCTCでsoftmaxを使用します。 s(sequence)と一緒にのみ使用できます。 |
NOTE Only O1s and O1c are currently supported. |
注O1とO1cのみが現在サポートされています。 |
` | ` |
The number of classes is ignored (only there for compatibility with TensorFlow) |
クラスの数は無視されます(TensorFlowとの互換性のためだけにあります) |
as the actual number is taken from the unicharset. |
実際の数はユニキャストから取得されます。 |
## Syntax of the Layers in between |
##中間層のシンタックス |
NOTE that all ops input and output the standard TF convention of a 4-d tensor: |
all opsは4次元テンソルの標準TF規則を入出力することに注意してください。 |
[batch, height, width, depth] regardless of any collapsing of dimensions. |
[batch、height、width、depth] 寸法の折りたたみに関係なく |
This greatly simplifies things, and allows the VGSLSpecs class to track changes |
これは物事を非常に単純化し、VGSLSpecsクラスが変更を追跡することを可能にします |
to the values of widths and heights, so they can be correctly passed in to LSTM |
幅と高さの値に変換するので、それらをLSTMに正しく渡すことができます。 |
operations, and used by any downstream CTC operation. |
ダウンストリームCTC操作で使用されます。 |
NOTE: in the descriptions below, is a numeric value, and literals are | 注:以下の説明では、 は数値で、リテラルは |
described using regular expression syntax. |
正規表現の構文を使って記述します。 |
NOTE: Whitespace is allowed between ops. |
注:opsの間には空白が許されます。 |
### Functional ops |
###機能的なオペレーション |
` | ` |
C(s |
t |
r |
l |
m),, Convolves using a y,x window, with no shrinkage, |
C(s |
t |
r |
l |
m)y、x、d収縮のないy、xウィンドウを使用して畳み込み、 |
random infill, d outputs, with s |
t |
r |
l |
m non-linear layer. |
ランダム充填dは、s |
t |
r |
l |
mの非線形層で出力します。 |
F(s |
t |
r |
l |
m) Fully-connected with s |
t |
r |
l |
m non-linearity and d outputs. |
F(s |
t |
r |
l |
m)d s |
t |
r |
l |
mと非線形に完全結合してdを出力する。 |
Reduces height, width to 1. Connects to every y,x,depth position of the input, |
高さ、幅を1に減らします。入力のすべてのy、x、深さ位置に接続します。 |
reducing height, width to 1, producing a single vector as the output. |
高さ、幅を1に減らして、出力として単一のベクトルを生成します。 |
Input height and width must be constant. |
入力の高さと幅は一定でなければなりません。 |
For a sliding-window linear or non-linear map that connects just to the |
に直接接続するスライディングウィンドウの線形または非線形マップの場合 |
input depth, and leaves the input image size as-is, use a 1x1 convolution |
入力深度、および入力画像サイズをそのままにして、1x1畳み込みを使用する |
eg. Cr1,1,64 instead of Fr64. |
例えば。 Fr64の代わりにCr 1,1,64。 |
L(f |
r |
b)(x |
y)[s] LSTM cell with n outputs. |
n個の出力を有するL(f | r | b)(x | y)[s] n LSTMセル。 |
The LSTM must have one of: |
LSTMには、以下のいずれかが必要です。 |
f runs the LSTM forward only. |
fはLSTMを順方向にのみ実行します。 |
r runs the LSTM reversed only. |
rはLSTMを反転してのみ実行します。 |
b runs the LSTM bidirectionally. |
bはLSTMを双方向に実行します。 |
It will operate on either the x- or y-dimension, treating the other dimension |
それはx次元かy次元のどちらかに作用し、他の次元を扱う |
independently (as if part of the batch). |
独立して(あたかもバッチの一部のように)。 |
s (optional) summarizes the output in the requested dimension, outputting |
s(オプション)は、要求されたディメンションの出力を要約して出力します。 |
only the final step, collapsing the dimension to a single element. |
最後のステップのみ、ディメンションを単一の要素に折りたたむ |
LS Forward-only LSTM cell in the x-direction, with built-in Softmax. |
LS x方向の順方向専用LSTMセル、内蔵のSoftmax。 |
LE Forward-only LSTM cell in the x-direction, with built-in softmax, |
LE x方向の順方向専用LSTMセル、内蔵のsoftmax、 |
with binary Encoding. |
バイナリエンコーディング |
` | ` |
In the above, (s|t|r|l|m) specifies the type of the non-linearity: |
上記で、 (s | t | r | l | m) は非線形性のタイプを指定します。 |
` | ` |
s = sigmoid |
s =シグモイド |
t = tanh |
t = tanh |
r = relu |
r = relu |
l = linear (i.e., No non-linearity) |
l =線形(すなわち、非線形性なし) |
m = softmax |
m =ソフトマックス |
` | ` |
Examples: |
例: |
Cr5,5,32 Runs a 5x5 Relu convolution with 32 depth/number of filters. |
Cr5,5,32 32の深さ/数のフィルタで5x5のRelu畳み込みを実行する。 |
Lfx128 runs a forward-only LSTM, in the x-dimension with 128 outputs, treating |
Lfx128 は128個の出力を持つx次元で順方向専用LSTMを実行します。 |
the y dimension independently. |
独立したy次元 |
Lfys64 runs a forward-only LSTM in the y-dimension with 64 outputs, treating |
Lfys64 は64個の出力を持つy次元で順方向専用LSTMを実行します。 |
the x-dimension independently and collapses the y-dimension to 1 element. |
x次元は独立しており、y次元を1つの要素に折りたたみます。 |
### Plumbing ops |
###配管作業 |
The plumbing ops allow the construction of arbitrarily complex graphs. Something |
配管作業は任意に複雑なグラフの構築を可能にする。何か |
currently missing is the ability to define macros for generating say an |
現在欠けているのは、例えばを生成するためのマクロを定義する機能です。 |
inception unit in multiple places. |
複数の場所で開始ユニット。 |
` | ` |
[...] Execute ... networks in series (layers). |
[...] ...ネットワークを直列(レイヤ)に実行します。 |
(...) Execute ... networks in parallel, with their output concatenated in depth. |
(...)...ネットワークを並列に実行し、その出力を詳細に連結します。 |
S, Rescale 2-D input by shrink factor y,x, rearranging the data by |
S 、 2次元入力を縮小率y、xで再スケールし、データを次のように並べ替えます。 |
increasing the depth of the input by factor xy. |
係数xyで入力の深さを増やします。 |
NOTE that the TF implementation of VGSLSpecs has a different S that is |
NOTE VGSLSpecsのTF実装は異なるSを持っていること |
not yet implemented in Tesseract. |
Tesseractにはまだ実装されていません。 |
Mp, Maxpool the input, reducing each (y,x) rectangle to a single value. |
Mp 、入力を最大プールし、各(y、x)長方形を単一の値に縮小します。 |
` | ` |
### Full Example: A 1-D LSTM capable of high quality OCR |
###完全な例:高品質のOCRが可能な1-D LSTM |
[1,1,0,48 Lbx256 O1c105] |
[1,1,0,48 Lbx256 O1c105] |
As layer descriptions: (Input layer is at the bottom, output at the top.) |
レイヤーの説明として:(入力レイヤーは一番下にあり、出力は一番上にあります。) |
` | ` |
O1c105: Output layer produces 1-d (sequence) output, trained with CTC, |
O1c105:出力層はCTCで訓練された1-d(シーケンス)出力を生成します、 |
outputting 105 classes. |
105クラスを出力します。 |
Lbx256: Bi-directional LSTM in x with 256 outputs |
Lbx256:xの双方向LSTM、256出力 |
1,1,0,48: Input is a batch of 1 image of height 48 pixels in greyscale, treated |
1,1,0,48:入力はグレースケールで高さ48ピクセルの1画像のバッチであり、扱われる |
as a 1-dimensional sequence of vertical pixel strips. |
垂直方向のピクセルストリップの1次元シーケンスとして。 |
[]: The network is always expressed as a series of layers. |
[]:ネットワークは常に一連の層として表現されます。 |
` | ` |
This network works well for OCR, as long as the input image is carefully |
入力画像が慎重に保存されている限り、このネットワークはOCRに適しています。 |
normalized in the vertical direction, with the baseline and meanline in constant |
ベースラインと平均ラインを一定にして、垂直方向に正規化 |
places. |
場所です。 |
### Full Example: A multi-layer LSTM capable of high quality OCR |
###完全な例:高品質のOCRが可能な多層LSTM |
[1,0,0,1 Ct5,5,16 Mp3,3 Lfys64 Lfx128 Lrx128 Lfx256 O1c105] |
[[1,0,0,1 Ct 5,5,16 Mp3,3 Lfys64 Lfx128 Lrx128 Lfx256 O1c105] ` |
As layer descriptions: (Input layer is at the bottom, output at the top.) |
レイヤーの説明として:(入力レイヤーは一番下にあり、出力は一番上にあります。) |
` | ` |
O1c105: Output layer produces 1-d (sequence) output, trained with CTC, |
O1c105:出力層はCTCで訓練された1-d(シーケンス)出力を生成します、 |
outputting 105 classes. |
105クラスを出力します。 |
Lfx256: Forward-only LSTM in x with 256 outputs |
Lfx256:256の出力を備えたxの転送専用LSTM |
Lrx128: Reverse-only LSTM in x with 128 outputs |
Lrx 128:128出力のxの逆専用LSTM |
Lfx128: Forward-only LSTM in x with 128 outputs |
Lfx 128:xの転送専用LSTM、128出力 |
Lfys64: Dimension-summarizing LSTM, summarizing the y-dimension with 64 outputs |
Lfys64:次元要約LSTM、64個の出力でy次元を要約 |
Mp3,3: 3 x 3 Maxpool |
Mp3,3:3 x 3マックスプール |
Ct5,5,16: 5 x 5 Convolution with 16 outputs and tanh non-linearity |
Ct5,5,16:16の出力とtanhの非線形性をもつ5 x 5の畳み込み |
1,0,0,1: Input is a batch of 1 image of variable size in greyscale |
1,0,0,1:入力はグレースケールの可変サイズの1画像のバッチです |
[]: The network is always expressed as a series of layers. |
[]:ネットワークは常に一連の層として表現されます。 |
` | ` |
The summarizing LSTM makes this network more resilient to vertical variation in |
LSTMを要約すると、このネットワークは垂直方向の変動に対してより回復力のあるものになります。 |
position of the text. |
テキストの位置 |
## Variable size inputs and summarizing LSTM |
##可変サイズの入力とLSTMの要約 |
NOTE that currently the only way of collapsing a dimension of unknown size to |
現在のところ、未知のサイズのディメンションを折りたたむ唯一の方法は |
known size (1) is through the use of a summarizing LSTM. A single summarizing |
既知のサイズ(1)は要約LSTMの使用によるものです。単一の要約 |
LSTM will collapse one dimension (x or y), leaving a 1-d sequence. The 1-d |
LSTMは1次元(xまたはy)を折りたたみ、1次元のシーケンスを残します。 1-d |
sequence can then be collapsed in the other dimension to make a 0-d categorical |
その後、他の次元でシーケンスを折りたたんで0-dカテゴリカルにすることができます。 |
(softmax) or embedding (logistic) output. |
(softmax)または埋め込み(logistic)出力 |
For OCR purposes then, the height of the input images must either be fixed, and |
その場合、OCRの目的のために、入力画像の高さは固定されていなければなりません、そして |
scaled (using Mp or S) vertically to 1 by the top layer, or to allow |
最上位レイヤによって1に垂直方向に拡大縮小される(MpまたはSを使用)、または |
variable-height images, a summarizing LSTM must be used to collapse the vertical |
高さ可変の画像。要約するLSTMを使用して垂直方向を折りたたむ必要があります。 |
dimension to a single value. The summarizing LSTM can also be used with a fixed |
単一値への次元。要約LSTMは、固定のLSTMと一緒に使用することもできます。 |
height input. |
高さ入力 |