【PyTorch】ドキュメントリンク集

PyTorchのドキュメントを毎回探してしまっているので、よく見るリンク集です。

 

【PyTorch】MNISTのサンプルプログラム

ここでは、ある程度Deep Learningの概要やPythonについて勉強し、実際にPyTorchを使ってプログラムを組みたい人向けを想定しています。(ほぼ自分用、備忘録です)

MNISTの0~9の手書き文字画像の分類は、DeepLearningにおけるHellow World的な存在ですが、DeepLearningの画像データや正解ラベルも簡単に入手できるので、最初にプログラムを行うのには、とても便利です。

DeepLearningのプログラムを1つ作っておけば、他に流用できる部分も多いので、まずは、このMNISTをやってみたいと思います。

ここでは、Deep Learning処理の概念的な理解を重視して、ニューラルネットワーク部分はシンプルにしました。

サンプルプログラム

まずは、いきなりMNISTの0~9の手書き文字画像分類のサンプルプログラムです。

import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import datasets, transforms

#----------------------------------------------------------
# ハイパーパラメータなどの設定値
num_epochs = 10         # 学習を繰り返す回数
num_batch = 100         # 一度に処理する画像の枚数
learning_rate = 0.001   # 学習率
image_size = 28*28      # 画像の画素数(幅x高さ)

# GPU(CUDA)が使えるかどうか?
device = 'cuda' if torch.cuda.is_available() else 'cpu'

#----------------------------------------------------------
# 学習用/評価用のデータセットの作成

# 変換方法の指定
transform = transforms.Compose([
    transforms.ToTensor()
    ])

# MNISTデータの取得
# https://pytorch.org/vision/stable/generated/torchvision.datasets.MNIST.html#torchvision.datasets.MNIST
# 学習用
train_dataset = datasets.MNIST(
    './data',               # データの保存先
    train = True,           # 学習用データを取得する
    download = True,        # データが無い時にダウンロードする
    transform = transform   # テンソルへの変換など
    )
# 評価用
test_dataset = datasets.MNIST(
    './data', 
    train = False,
    transform = transform
    )

# データローダー
train_dataloader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size = num_batch,
    shuffle = True)
test_dataloader = torch.utils.data.DataLoader(
    test_dataset,     
    batch_size = num_batch,
    shuffle = True)

#----------------------------------------------------------
# ニューラルネットワークモデルの定義
class Net(nn.Module):
    def __init__(self, input_size, output_size):
        super(Net, self).__init__()

        # 各クラスのインスタンス(入出力サイズなどの設定)
        self.fc1 = nn.Linear(input_size, 100)
        self.fc2 = nn.Linear(100, output_size)

    def forward(self, x):
        # 順伝播の設定(インスタンスしたクラスの特殊メソッド(__call__)を実行)
        x = self.fc1(x)
        x = torch.sigmoid(x)
        x = self.fc2(x)
        return F.log_softmax(x, dim=1)

#----------------------------------------------------------
# ニューラルネットワークの生成
model = Net(image_size, 10).to(device)

#----------------------------------------------------------
# 損失関数の設定
criterion = nn.CrossEntropyLoss() 

#----------------------------------------------------------
# 最適化手法の設定
optimizer = torch.optim.Adam(model.parameters(), lr = learning_rate) 

#----------------------------------------------------------
# 学習
model.train()  # モデルを訓練モードにする

for epoch in range(num_epochs): # 学習を繰り返し行う
    loss_sum = 0

    for inputs, labels in train_dataloader:

        # GPUが使えるならGPUにデータを送る
        inputs = inputs.to(device)
        labels = labels.to(device)

        # optimizerを初期化
        optimizer.zero_grad()

        # ニューラルネットワークの処理を行う
        inputs = inputs.view(-1, image_size) # 画像データ部分を一次元へ並び変える
        outputs = model(inputs)

        # 損失(出力とラベルとの誤差)の計算
        loss = criterion(outputs, labels)
        loss_sum += loss

        # 勾配の計算
        loss.backward()

        # 重みの更新
        optimizer.step()

    # 学習状況の表示
    print(f"Epoch: {epoch+1}/{num_epochs}, Loss: {loss_sum.item() / len(train_dataloader)}")

    # モデルの重みの保存
    torch.save(model.state_dict(), 'model_weights.pth')

#----------------------------------------------------------
# 評価
model.eval()  # モデルを評価モードにする

loss_sum = 0
correct = 0

with torch.no_grad():
    for inputs, labels in test_dataloader:

        # GPUが使えるならGPUにデータを送る
        inputs = inputs.to(device)
        labels = labels.to(device)

        # ニューラルネットワークの処理を行う
        inputs = inputs.view(-1, image_size) # 画像データ部分を一次元へ並び変える
        outputs = model(inputs)

        # 損失(出力とラベルとの誤差)の計算
        loss_sum += criterion(outputs, labels)

        # 正解の値を取得
        pred = outputs.argmax(1)
        # 正解数をカウント
        correct += pred.eq(labels.view_as(pred)).sum().item()

print(f"Loss: {loss_sum.item() / len(test_dataloader)}, Accuracy: {100*correct/len(test_dataset)}% ({correct}/{len(test_dataset)})")

実行結果

 

使用モジュールの定義

import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import datasets, transforms

torchは、もちろんPyTorch用のモジュールです。

torchvisionはPyTorchの画像を使ったDeepLearning処理のための補助モジュールで、データセットの作成や、画像データからテンソルへの変換、画像の水増しなどを行います。

パラメータの設定

#----------------------------------------------------------
# ハイパーパラメータなどの設定値
num_epochs = 10         # 学習を繰り返す回数
num_batch = 100         # 一度に処理する画像の枚数
learning_rate = 0.001   # 学習率
image_size = 28*28      # 画像の画素数(幅x高さ)

# GPU(CUDA)が使えるかどうか?
device = 'cuda' if torch.cuda.is_available() else 'cpu'

エポック数(繰り返し回数)、学習率など、設定を変更するパラメータは、一か所にまとめておくと変更しやすいので便利です。

データセット、データローダーの作成

#----------------------------------------------------------
# 学習用/評価用のデータセットの作成

# 変換方法の指定
transform = transforms.Compose([
    transforms.ToTensor()
    ])

# MNISTデータの取得
# https://pytorch.org/vision/stable/generated/torchvision.datasets.MNIST.html#torchvision.datasets.MNIST
# 学習用
train_dataset = datasets.MNIST(
    './data',               # データの保存先
    train = True,           # 学習用データを取得する
    download = True,        # データが無い時にダウンロードする
    transform = transform   # テンソルへの変換など
    )
# 評価用
test_dataset = datasets.MNIST(
    './data', 
    train = False,
    transform = transform
    )

# データローダー
train_dataloader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size = num_batch,
    shuffle = True)
test_dataloader = torch.utils.data.DataLoader(
    test_dataset,     
    batch_size = num_batch,
    shuffle = True)

データセットとは、推論を行うためのデータとラベル(正解データ)のセットの集まりです。

学習時に用いる画像と評価時に用いる画像を別の画像にするため、学習用のデータセットは train = True
評価用のデータセットは train = False に設定します。

データローダーは、学習時にデータセットの中からbatch_size個分だけ、まとめてデータを取り出します。

後述する学習時のfor分の部分で、以下のように書いている部分が、データローダーの中からデータとラベルをbatch_size個ずつ取り出している部分となります。

for inputs, labels in train_dataloader:
       :

このデータを取り出す際に、データを拡大、縮小、移動などを行い、見かけ上のデータ数を増やす水増しと言われる処理や、データを並び替えて値を0~1の値に収まるように変換し、テンソルと呼ばれるデータ形式に変更します。

”テンソル”という言葉が出てくると、いきなり難しくも感じるのですが、プログラム的に言うと、ただの多次元配列となります。

画像データの場合、幅(W)、高さ(H)、色(C)と置くと、モノクロ画像の場合[H、W]の2次元配列となり、カラーの場合は[H, W, C]の3次元配列となりますが、これにバッチ数のNを追加し、
[N, C, H, W]の順番の4次元配列に格納されたデータがテンソルとなります。

今回は、手書き文字のデータセットを用いましたが、他にも既存のデータセットがいろいろあるので、こちらを参照ください。

https://pytorch.org/vision/stable/datasets.html

また、既存のデータセットではなく、自作のデータセットを作成することも可能ですが、これについては、別途記事にしたいと思います。

ニューラルネットワークの作成

#----------------------------------------------------------
# ニューラルネットワークモデルの定義
class Net(nn.Module):
    def __init__(self, input_size, output_size):
        super(Net, self).__init__()

        # 各クラスのインスタンス(入出力サイズなどの設定)
        self.fc1 = nn.Linear(input_size, 100)
        self.fc2 = nn.Linear(100, output_size)

    def forward(self, x):
        # 順伝播の設定(インスタンスしたクラスの特殊メソッド(__call__)を実行)
        x = self.fc1(x)
        x = torch.sigmoid(x)
        x = self.fc2(x)
        return F.log_softmax(x, dim=1)

#----------------------------------------------------------
# ニューラルネットワークの生成
model = Net(image_size, 10).to(device)

今回は入力に画像データ全画素数(28×28)の784個入力で、全結合(出力100個)→シグモイド→全結合(出力10個)→ログソフトマックス というとてもシンプルな物にしました。

ニューラルネットワークを作成するには、nn.Moduleクラスを継承し、ニューラルネットワークのクラスを作成します。ここではクラス名を Net としましたが、クラス名についての制限はありません。

通常、作成するクラスのコンストラクタ(__init__)の部分で、各層で使われる処理(ここでは全結合のLinear)のクラスのインスタンスにより、入力サイズや出力サイズ、各種オプション設定を行います。

順伝播される処理の流れは forwardメソッド(メソッド名はforwardであること)により定義します。

例えば

x = self.fc1(x)

の部分では、コンストラクタの部分で定義したLinearクラスのインスタンス(self.fc1)にカッコ() を付けて、入力データである x を引数のように渡していますが、この書き方はPython特有で、実際には Linearクラスの
__call__メソッドが呼ばれます。

このような書き方を特殊メソッドというのですが、詳細は下記ページを参照ください。

(参考)

【Python】特殊メソッド

 

損失関数の定義

#----------------------------------------------------------
# 損失関数の設定
criterion = nn.CrossEntropyLoss() 

#----------------------------------------------------------
# 学習中にて
# 損失(出力とラベルとの誤差)の計算
loss = criterion(outputs, labels)

損失関数は、ニューラルネットワークの出力と、ラベルとの誤差を計算します。

今回、損失関数に用いているCrossEntropyLossは損失関数の中では少し特殊で、複数の出力の値とラベル1つの値との誤差を計算しています。

よくあるのは、出力の数とラベルの数は同じ数で、下図のようなイメージとなります。

学習の工程では、この誤差が小さくなるよう、各層の重みの調整を繰り返し行います。

(参考)

https://pytorch.org/docs/stable/nn.html#loss-functions

 

最適化手法の定義

#----------------------------------------------------------
# 最適化手法の設定
optimizer = torch.optim.Adam(model.parameters(), lr = learning_rate) 

最適化関数は、損失関数から求めた勾配(損失関数を求める重みで偏微分し、現時点の重みを代入した値)を元に、最適値へ近づけるための手法です。

下図は、重みの値が最適値に更新されるときのイメージですが、現時点の重みが最適値から離れている場合は勾配(接線の傾き)は大きくなり、より大きく最適値に近づくように重みの値が更新されます。

逆に、重みの値が最適値に近づくと、勾配が小さくなり、重みの更新量も少なくなります。

学習率(lr)は、値が大きいと早く最適値へ近づくようになりますが、大きすぎると逆に最適値から離れてしまうので、注意が必要です。

とりあえずは lr = 0.001 ぐらいから始めてみるといいかも?しれません。

(参考)

https://pytorch.org/docs/stable/optim.html

 

学習

#----------------------------------------------------------
# 学習
model.train()  # モデルを訓練モードにする

for epoch in range(num_epochs): # 学習を繰り返し行う
    loss_sum = 0

    for inputs, labels in train_dataloader:

        # GPUが使えるならGPUにデータを送る
        inputs = inputs.to(device)
        labels = labels.to(device)

        # optimizerを初期化
        optimizer.zero_grad()

        # ニューラルネットワークの処理を行う
        inputs = inputs.view(-1, image_size) # 画像データ部分を一次元へ並び変える
        outputs = model(inputs)

        # 損失(出力とラベルとの誤差)の計算
        loss = criterion(outputs, labels)
        loss_sum += loss

        # 勾配の計算
        loss.backward()

        # 重みの更新
        optimizer.step()

    # 学習状況の表示
    print(f"Epoch: {epoch+1}/{num_epochs}, Loss: {loss_sum.item() / len(train_dataloader)}")

    # モデルの重みの保存
    torch.save(model.state_dict(), 'model_weights.pth')

学習の工程は、各重みを最適値へ近づけるため、for分で繰り返し処理を行うのですが、学習の部分で重要な部分を抜き出すと

# optimizerを初期化
optimizer.zero_grad()

# 損失(出力とラベルとの誤差)の計算
loss = criterion(outputs, labels)

# 勾配の計算
loss.backward()

# 重みの更新
optimizer.step()

の繰り返しとなっています。

この繰り返しのイメージは、こんな感じ↓です。

 

評価

#----------------------------------------------------------
# 評価
model.eval()  # モデルを評価モードにする

loss_sum = 0
correct = 0

with torch.no_grad():
    for inputs, labels in test_dataloader:

        # GPUが使えるならGPUにデータを送る
        inputs = inputs.to(device)
        labels = labels.to(device)

        # ニューラルネットワークの処理を行う
        inputs = inputs.view(-1, image_size) # 画像データ部分を一次元へ並び変える
        outputs = model(inputs)

        # 損失(出力とラベルとの誤差)の計算
        loss_sum += criterion(outputs, labels)

        # 正解の値を取得
        pred = outputs.argmax(1)
        # 正解数をカウント
        correct += pred.eq(labels.view_as(pred)).sum().item()

print(f"Loss: {loss_sum.item() / len(test_dataloader)}, Accuracy: {100*correct/len(test_dataset)}% ({correct}/{len(test_dataset)})")

今回は、0~9までの画像分類を行っているので、出力(output)は10個のテンソルデータとなり、この10個のデータの配列中、値が最大となる値のインデックス番号が、推測された数字の値(0~9)と一致するようになっています。

 

まとめ

ここで紹介しているサンプルは、Deep Learningをするはしめの一歩として、もろもろシンプルにしています。

ニューラルネットワークはシンプルだし、学習中の過学習の評価用に検証データも欲しいし、画像も表示したい。

と、いろいろ不足しているかと思いますが、おいおい記事にしたいと思います。

 

PyTorchそのものは、画像を使ったDeepLearningで行われる、画像の分類、認識、領域分割専用に作られている訳では無いので、最初のハードルが少々高く感じます。

さらに、画像データをニューラルネットワークに流すには、画像データをテンソルに変換して。。

とかいうと、なぜか難しく感じてしまいます。

テンソルも、ただの配列なのに、numpyのndarrayは、比較的容易に受け入れていたのに、なぜ、PyTorchのテンソルは受け入れ難く感じるのか??

 

本記事では、その辺のハードルが少しでも下がって感じてもらえると幸いです。

【PyTorch】既存モデルをONNXに保存しC#で推論する方法

DeepLearningのプログラムは、ほとんどがPythonで書かれる場合が多いのですが、画像入力やGUI部分をプログラムしたいとなると、やっぱりC#で組みたい!

ということで、学習まではPythonで行い、学習結果をONNXに保存し、ONNXをC#から読み込んでC#で推論を行う方針で、いろいろ調べてみたのですが、分からない部分もボロボロと...

とりあえず、出来た事のメモです。

 

作成したプログラムのイメージ

今回は.NET Coreを使って作成していますが、.NET Frameworkでも大丈夫です。

PyTorchで既存モデルをONNXファイルに保存

今回は、画像認識モデル(Object Detection)をONNXファイルに保存するサンプルです。

入力画像サイズや出力の名前を使用するモデルに合わせる必要があります。

import torch
import torchvision

# 入力画像サイズ(N, C, H, W)
x = torch.randn(1, 3, 480, 640)
# 学習済みモデル
# 参考 https://pytorch.org/vision/main/models.html#object-detection-instance-segmentation-and-person-keypoint-detection
model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=True)

# ONNXファイルに保存
# 参考 https://pytorch.org/docs/stable/onnx.html
torch.onnx.export(
    model,                                          # ニューラルネットワークモデル
    x,                                              # 入力データ
    'fasterrcnn_mobilenet_v3_large_320_fpn.onnx',   # ONNXファイル名
    opset_version=11,                               # ONNXバージョン
    input_names = ['input'],                        # 入力の名前
    output_names = ["boxes", "labels", "scores"]    # 出力の名前
    )

input_names と output_names の指定は省略可能です。

C#でONNXファイルを読み込み、推論を行う方法

C#でONNXを扱えるライブラリは、いくつかあるようなのですが、今回は、マイクロソフトのOnnxRuntimeを使いました。

フォームにはボタン(button1)とピクチャボックス(pictureBox1)のみを配置しています。

使用には、NuGetでMicrosoft.ML.OnnxRuntimeを追加する必要があります。

分かっていない部分

以下は、私が分かっていない部分なので、出来るかも?しれません。

  • OnnxRuntimeで読み込めるONNXのバージョンは10まで?らしいのですが、PythonでONNXのバージョンを10で保存できない。
    ニューラルネットワークのモデルにも依存すると思いますが、詳細は分からず...
  • ONNXファイルに保存するとき、ワーニングがいっぱい出てる。
  • 自前でモデルの学習を行うと、C#側で正しく推論できない。
  • C#でGPUを使った推論方法が分からない。
  • C#で画像をテンソル(floatの一次元配列)に変える部分は自作しましたが、下記のページを見ても、いまいちわからず。
    https://docs.microsoft.com/ja-jp/dotnet/machine-learning/tutorials/object-detection-onnx

参考

https://pytorch.org/vision/main/models.html#object-detection-instance-segmentation-and-person-keypoint-detection

https://pytorch.org/docs/stable/onnx.html

https://docs.microsoft.com/ja-jp/windows/ai/windows-ml/tutorials/pytorch-convert-model

https://docs.microsoft.com/ja-jp/windows/ai/windows-ml/get-started-uwp

https://docs.microsoft.com/ja-jp/dotnet/machine-learning/tutorials/object-detection-onnx

 

【PyTorch】Visual Studioでインストールする方法

私はC#をメインで使っているので、Pythonのプログラムを組む時も慣れたVisual Studioで行っています。

さらに、Visual Studio 2019であればPythonの環境(バージョン)ごとにインストールするのも簡単なのですが、PyTorchをインストールするときは、少々、ハマったので、そのメモです。。

 

PythonモジュールのインストールはPython環境で、インストールしたい環境(バージョン)を選択し、 PyPIとインストールされたパッケージの検索 の部分に torch と入力して、Enterを押せば、インストールできるかも?知れないのですが、インストールされるPyTorchのバージョンやGPUの対応などに不安があったので、別の方法でインストールを行いました。

 

まず、PyTorchのページへ移動し、少し下に表示されているバージョンやOSの選択表示部分で、自分のインストールしたい環境を選択します。

私の場合は以下のように選択しました。

 

すると、Run this Commandの部分に

 

pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

 

と表示されているので、この torch以降の部分を選択し、コピー(Ctrl+C)します。

コピーしたテキストを、 PyPIとインストールされたパッケージの検索 の部分に貼り付け(Ctrl+V)ると、 次のコマンドを実行する のリンクが表示されるので、この部分をクリックすると、PyTorchのインストールが始まります。

 

 

これで、特に問題が無かった人は以下のように torch, torchaudio, torchvision の3つがインストールされると思います。

 

しかし、私はそう簡単にはいきませんでした。。

 

そもそも自分のPCにインストールされているCUDAのバージョンがわからなかったのですが、CUDAのバージョンを調べるにはコマンドプロンプトから、

nvcc -V

と入力すると、CUDAのバージョンを調べることができます。

 

私の場合、CUDAのバージョンが古かったので、CUDAもインストールしました。

(参考)

CUDAの入手、ダウンロード、インストール方法

 

さらに、pip install 中に、このような↓メッセージが表示されたのですが、

 

ここで今すぐ昇格をクリックして、インストールを続けても、下記のようなエラーが表示されて、インストールできませんでした。

----- 'torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html' をインストールしています -----
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.8.1+cu111
  Using cached https://download.pytorch.org/whl/cu111/torch-1.8.1%2Bcu111-cp39-cp39-win_amd64.whl (3055.6 MB)
Collecting torchvision==0.9.1+cu111
  Using cached https://download.pytorch.org/whl/cu111/torchvision-0.9.1%2Bcu111-cp39-cp39-win_amd64.whl (1.9 MB)
Collecting torchaudio===0.8.1
  Using cached torchaudio-0.8.1-cp39-none-win_amd64.whl (109 kB)
Requirement already satisfied: typing-extensions in c:\users\akira\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torch==1.8.1+cu111) (3.7.4.3)
Requirement already satisfied: numpy in c:\users\akira\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torch==1.8.1+cu111) (1.20.2)
Requirement already satisfied: pillow>=4.1.1 in c:\users\akira\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from torchvision==0.9.1+cu111) (8.2.0)
Installing collected packages: torch, torchvision, torchaudio
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\akira\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\caffe2\\python\\serialized_test\\data\\operator_test\\collect_and_distribute_fpn_rpn_proposals_op_test.test_collect_and_dist.zip'
----- 'torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html' をインストールできませんでした -----

このエラーの

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory:

の部分がいまいち意味が分からず、インストール中に管理者権限のメッセージが表示されていたので、インストール先のフォルダの権限が悪いのか?と思ったのですが、フォルダの権限の変更方法も分からず。。

結局、Pythonをアンインストールして、再インストールすることで、PyTorchもインストールできました。

 

ちなみに、Pythonのインストールは、下記のページ

https://www.python.org/downloads/

より、Windowsの場合であれば Download Python X.X.X の部分をクリックし、ファイルをダウンロードし、ファイルをダブルクリックしてインストールします。

インストール時に Add Python 3.9 to PATH にチェックを入れ  Customize installation をクリックしてインストールします。

次に表示されたウィンドウでインストール先のディレクトリが指定できるので、アクセス制限のなさそうな場所を指定して、 install をクリックします。

最終的に以下のようなウィンドウが表示されれば、Pythonのインストールは完了です。

ここまでやって、無事、PyTorchをインストールすることが出来ました!!

LibTorch(C++版PyTorch)の使用方法

[2020.2.5]LibTorch Ver.1.4.0対応版に修正

昨年はPFNがPyTorchへ移行するというビックニュースがありましたが、それもあって、個人的に注目度の増したPyTorch

DeepLearningについては、最終的にはC#から使いたいのですが、C#に正式に対応しているのは、おそらくMicrosoftのCognitive Toolkitだけ?ですが、MicrosoftもCognitive Toolkitは今後、メンテナンスのみ行い、新しくは開発を行わないと言っているので、いつまで続くか?ちょっと不安。

C#がダメなら、ある程度C++で処理を書いて、C#から処理を呼び出す方向にしようと思い、C++に対応しているPyTorchについて調べてみました。

PyTorchのC++版はLibTorchと言うらしい。

 

ただし、PyTorchのC++のページ

https://pytorch.org/cppdocs/

にも、こんな文言↓が書いてあり、今後、変わる可能性も大な状況です。

 

開発環境

Windows10

Visual Studio 2017

LibTorchバージョン 1.4.0 (2020年2月月時点の最新)

となります。

Visual Studio 2015でも試してみましたが、エラーが多発し、VS2017にしました。

 

LibTorchのダウンロード

ビルド済みのLibTorchは下記、ページよりダウンロードできます。

https://pytorch.org/

 

今回は使用方法の評価をしたいので、Windows、C++版のCUDAなしのDebug版をダウンロードします。

実際に使う場合はRelease版を入手してください。

 

 

zipファイル(libtorch-win-shared-with-deps-debug-1.4.0.zip)を解凍すると、ファイル構成は以下のようになっています。

重要な部分を展開して表示しています。

 

└─libtorch
│ build-hash

├─bin

├─cmake

├─include
│ │ clog.h
│ │ cpuinfo.h
│ │ fp16.h
│ │ psimd.h
│ │
│ ├─ATen
│ ├─c10
│ ├─caffe2
│ ├─nomnigraph
│ ├─pybind11
│ ├─TH
│ ├─THCUNN
│ ├─THNN
│ └─torch
│ └─csrc
│ ├─api
│ │ ├─include
│ │ │ └─torch
│ │ │ │ all.h
│ │ │ │ arg.h
│ │ │ │ autograd.h
│ │ │ │ cuda.h
│ │ │ │ data.h
│ │ │ │ enum.h
│ │ │ │ expanding_array.h
│ │ │ │ jit.h
│ │ │ │ nn.h
│ │ │ │ optim.h
│ │ │ │ ordered_dict.h
│ │ │ │ python.h
│ │ │ │ serialize.h
│ │ │ │ torch.h
│ │ │ │ types.h
│ │ │ │ utils.h
│ │ │ │
│ │ │ ├─data
│ │ │ ├─detail
│ │ │ ├─nn
│ │ │ ├─optim
│ │ │ ├─python
│ │ │ │ init.h
│ │ │ │
│ │ │ └─serialize
│ │ │
│ │ └─src
│ ├─autograd
│ ├─cuda
│ ├─distributed
│ ├─generic
│ ├─jit
│ ├─multiprocessing
│ ├─onnx
│ ├─tensor
│ └─utils

├─lib
│ c10.dll
│ c10.lib
│ c10.pdb
│ caffe2_module_test_dynamic.dll
│ caffe2_module_test_dynamic.lib
│ caffe2_module_test_dynamic.pdb
│ clog.lib
│ cpuinfo.lib
│ libiomp5md.dll
│ libiompstubs5md.dll
│ libprotobuf-lited.lib
│ libprotobufd.lib
│ libprotocd.lib
│ torch.dll
│ torch.lib
│ torch.pdb

├─share
└─test

 

使用方法

使用方法については、こちらのページ↓

https://mc.ai/building-pytorch-c-integration-libtorch-with-ms-visual-studio-2017/

を参考にしながら、少し手をいれました。

 

1.  C++プロジェクトの作成

今回はC++のコンソールアプリケーションを作成します。

Visual Studio 2017を起動し、 新しいプロジェクトの作成 をクリックします。

Visual C++ → Windowsデスクトップ → コンソールアプリ と選択し、名前や場所を指定して、OKボタンをクリックします。

すると最小限のコンソールアプリ Hello World! が作成されます。

2.  プラットフォームを64ビット用(x64)に変更

Visual Studioの上部のソリューションプラットフォーム部分を x64 に変更します。

3.  インクルードディレクトリの設定

使用するヘッダファイル(*.h)の場所(ディレクトリ)を設定します。

プロジェクトのプロパティより、 C/C++ → 全般 → 追加のインクルードディレクトリ
の編集をクリックします。

libtorch\include
libtorch\include\torch\csrc\api\include
の2つのディレクトリを指定します。
下図の D:PyTorch140の部分は各自、解凍したファイルを配置した場所に合わせて下さい。

 

4.  ライブラリディレクトリの設定

使用するライブラリファイル(*.lib)の場所(ディレクトリ)を設定します。

プロジェクトのプロパティより、 C/C++ → 全般 → 追加のライブラリディレクトリ
の編集をクリックします。

 

libtorch\lib

のディレクトリを指定します。
下図の D:PyTorch140の部分は各自、解凍したファイルを配置した場所に合わせて下さい。

 

5.  ライブラリファイルの設定

使用するライブラリファイル(*.lib)を設定します。

プロジェクトのプロパティより、 C/C++ → 入力 → 追加の依存ファイル
の編集をクリックします。

 

ここで、使用するライブラリファイル(*.lib)を設定するのですが、参考にしたページのファイル名が少し違っていたので、とりあえず、下記ファイルを追加しました。

c10.lib
caffe2_module_test_dynamic.lib
torch.lib

 

libファイルを追加したらOKボタンをクリックし、戻ったプロパティページの 適用 をクリックします。

 

6.  準拠モードの設定

次に、参考にしたページに従って、 C/C++ → 言語 → 準拠モード

はい から いいえ に変更します。

プロパティページの 適用、OK をクリックし設定画面を閉じます。

 

サンプルプログラムの作成

ここでも参考にしたページにしたがって、Hello World! のプログラムにiniclude

#include “torch/torch.h”

を追加してみます。

 

 

 

 

 

この状態でソリューションをビルドすると、エラーが1つ、警告はたくさん出てきます。

 

警告はあまりに多いので、エラーだけを直します。

 

E1866 属性はどのエンティティにも適用されません

E1866 属性はどのエンティティにも適用されませんの部分をダブルクリックすると、ArrayRef.hファイルへ飛びます。

 

この C10_DEFINE_DEPRECATED_USING の部分が何をしているか?分からないのですが、ヒントに従って、新しいヒントファイル(cpp.hint)を追加してみたものの、修正できず。

とりあえず、コメントに Use IntArrayRef instead! と書いてあったので、コメントアウトして様子見。

 

これで、エラーが出なくなりました! コメントアウトした部分が怪しいけど。。

 

[2020.2.24]追記

C10と付くエラーはCUDA10に関するエラーのようです。

動かすプログラムからCUDAに関連する関数を呼ぶと、C10と付くエラーが表示されるため、本ページではCUDA無しのバイナリを使用していますが、CUDA対応のバイナリを使用した方がいいかも?しれません。

    【キカガク流】人工知能・機械学習 脱ブラックボックス講座 – 初級編 -を受講した

    Udemyの動画による講座は、文字による説明よりも頭に入ってき易いので好きなのですが、たまにやっているキャンペーン期間中に勢いで

     

    【キカガク流】人工知能・機械学習 脱ブラックボックス講座 – 初級編 –

    なる講座を購入しました。

    タイトルこそ、今どきウケの良い感じですが、前半は微分や偏微分などの数学的な説明で、後半はPythonの基礎(四則演算や条件分岐など)から、回帰をPythonで解くような内容です。

     

    なので、内容に素直に私がタイトルを付けるなら、

     

    最小二乗法を一から解いて、Pythonで実装してみよう!

     

    という感じの内容です。

    最小二乗法については、さんざんやって来たので、前半はあまり得る物が無かったのですが、Pythonに関しては、私はド素人なので、そこは参考になりました。

    機械学習を学習する上では、二乗誤差の偏微分やPythonを使ったプログラムは、ほぼ、必須なので、必要な知識ではあるのですが、この講座の中で機械学習についての説明に相当する部分は単回帰分析の部分だけでしょうか。

     

    この内容で、一番気になったポイントとして、最後の部分で入力データを部屋の広さ(平米数)として、出力を家賃を求める単回帰分析の演習問題があったのですが、部屋の広さ(平米数)を入力するとマイナスの家賃が出力されてしまい、これは外挿による推論となってしまうため、外挿とならないように、学習用のデータを増やしましょう!という説明だったのですが、半分あっている気もしますが、一番の問題は、 部屋の広さ⇔家賃 の関係を一次式で近似しちゃってるのが問題なのでは?とも思ったりもしました。

     

    私が散々、最小二乗法でモデル式を作り、偏微分を解きながら、近似式を求めていた時は、誤差関数に変な特性、傾向が残らないか?(2次関数っぽい変化とか。。)や、入力データにあきらかな誤差データは含まれないか?など、気にしながら近似していましたが、機械学習とかになった瞬間、その辺の事が語られる事が少ないような。。

     

    とは言いながらも、ちゃんと受講しましたよ。

    やっぱり動画の講座はいいですね。

    はじめてDeep Learningを勉強するのに役に立った情報

    2年ぐらい前?からDeep Learningの勉強を始めてはいたのですが、仕事としてDeep Learningをする訳でも無く、個人で細々と勉強をしていたのですが、最近は仕事になり始めたので、そろそろ本気を出したいと思う、今日この頃。

     

    初めは、この絵↓が何なのか?も分からない状態で、周りに聞ける人もいない状態から勉強を始めた時に役に立ったと思う情報を紹介したいと思います。

     

    ゼロから作るDeep Learning ―Pythonで学ぶディープラーニングの理論と実装

     

    まずは、ド定番の「ゼロから作るDeep Learning」

    Deep Learningの勉強を始めた人は、ほとんど持っているんじゃないかな?と思われるこの本。

    私にとっては少し難しく感じる部分もあったのですが、とりあえず最初から最後まで読んでみて、また、あとで必要な部分を読み返すような事をしていました。

     

    ソニーのNeural Network Console

    サイトはこちら

    これはGUIだけでニューラルネットワークを構築でき、学習~推論までPythonなどのプログラムの知識なしでDeep Learningが試せる優れもの。

    直観的に、何をどうしたら精度が良くなるのか?を簡単に体感できるのは非常に役に立ちました。

    なにせ、実際の画像を使って分類が出来るのは、単純に楽しい!

     

    また、開発者によるYouTube動画もあり、Neural Network Consoleの使い方はもちろんのこと、Deep Learningとは?みたいな話や、テクニック的な部分も公開されているので、こちら↓もおススメです。

    https://www.youtube.com/channel/UCRTV5p4JsXV3YTdYpTJECRA/videos

     

    (参考)

    ソニーの無償AIソフト Neural Network Consoleの入手ダウンロード、インストール

     

    Udemyの動画講座

    私が見ていたのは、こちら↓

    【NumPy・Python3で】ゼロから作るニューラルネットワーク

    数式とかも出てきますが、動画をちょこちょこ止めながら自分のノートで解き、見ていました。

    この講座をある程度理解すると、ちょっとしたニューラルネットワークのプログラムを自分で作成するぐらいの知識を得る事ができるかと思います。

    〔産業分野における〕AI・ディープラーニングを利用した画像検査・解析の効率化

    〔産業分野における〕AI・ディープラーニングを利用した画像検査・解析の効率化 (月刊画像ラボ別冊)なる本を買ってみました。

     

    この本は産業分野におけるという部分がポイントだと思いますが、産業分野では、Pythonが使われる事は、ほとんどないし(C++,C#が多い)、OSはWindowsだし、PCもローカル(ネットにつながっていない)だしで、一般的に解説されているDeep Learningの世界とは、動作環境が少し異なっています。

     

    産業分野で、Deep Learningを用いた検査を行っている会社の論文集みたいな感じです。

     

    ほとんどの記事は、

    「現状では、まだまだ目視による検査が行われているが、判定基準が人によりバラつき易いし、人手不足だしで、検査をDeep Learningに置き換えると、判定基準が安定するし、人手不足も解消される。そこで、我社では ××ソフト を用い、○○の検査を行っています。」

     

    というな半分宣伝の内容です。

    Deep Learningのテクニック的な部分を期待すると、がっかりされるかもしれません。

     

    ただ、私自身も知らなかったDeep Learningを用いた検査ソフトが掲載されているので、それはそれで、参考になりました。

     

    この手のソフトは、分類/認識が初心者でも簡単にできますよ!というようなコンセプトが多いのですが、場合によってはオーバースペックになってしまうかも?しれません。

    個人的には、そんなに深いニューラルネットワークでなくて、推論時はGPUも使わずに、このくらいまでは出来ますよ!というのが、好みではあるのですが、それをやると手離れが悪くなってしまうでしょうね。。

    Microsoft Cognitive Toolkit Ver2.6が公開されました

    変更の概要についてはこちら↓
    https://docs.microsoft.com/en-us/cognitive-toolkit/releasenotes/cntk_2_6_release_notes

     

    以前のバージョン(Ver2.5.1)ではVisual Studio 2015からも実行できたのですが、今回のVer2.6ではVisual Studio 2017でないとNuGetよりインストールできませんでした。

    さらにVisual Studio 2017も更新しないとダメでした。。

     

    今回のバージョンのでは.NET の変更もあるということで、とりあえずCNTK.CNTKLibの定義をWinMergeを使って比較してみました。

    (詳細についてそのうち。。)

     

    Ver2.6 Ver2.5.1
           public CNTKLib();        public CNTKLib();
           public static bool AreEqual(Axis first, Axis second);        public static bool AreEqual(Axis first, Axis second);
           public static bool AreEqual(DeviceDescriptor first, DeviceDescriptor second);        public static bool AreEqual(DeviceDescriptor first, DeviceDescriptor second);
           public static bool AreEqual(NDShape first, NDShape second);        public static bool AreEqual(NDShape first, NDShape second);
           public static bool AreEqual(Variable first, Variable second);        public static bool AreEqual(Variable first, Variable second);
           public static bool AreNotEqual(Axis first, Axis second);        public static bool AreNotEqual(Axis first, Axis second);
           public static bool AreNotEqual(DeviceDescriptor left, DeviceDescriptor right);        public static bool AreNotEqual(DeviceDescriptor left, DeviceDescriptor right);
           public static bool AreNotEqual(NDShape first, NDShape second);        public static bool AreNotEqual(NDShape first, NDShape second);
           public static bool AreNotEqual(Variable first, Variable second);        public static bool AreNotEqual(Variable first, Variable second);
           public static bool IsRandomSeedFixed();        public static bool IsRandomSeedFixed();
           public static bool IsSparseStorageFormat(StorageFormat storageFormat);        public static bool IsSparseStorageFormat(StorageFormat storageFormat);
    .        public static bool ShouldForceDeterministicAlgorithms();  
           public static bool ShouldUseSparseGradientAggregationInDataParallelSGD();        public static bool ShouldUseSparseGradientAggregationInDataParallelSGD();
           public static CNTKDictionary Base64ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName);        public static CNTKDictionary Base64ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName);
           public static CNTKDictionary Base64ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, DictionaryVector transforms);        public static CNTKDictionary Base64ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, DictionaryVector transforms);
           public static CNTKDictionary BilinearInitializer(uint kernelWidth, uint kernelHeight);        public static CNTKDictionary BilinearInitializer(uint kernelWidth, uint kernelHeight);
           public static CNTKDictionary CBFDeserializer(string fileName);        public static CNTKDictionary CBFDeserializer(string fileName);
           public static CNTKDictionary CBFDeserializer(string fileName, StreamConfigurationVector streams);        public static CNTKDictionary CBFDeserializer(string fileName, StreamConfigurationVector streams);
           public static CNTKDictionary ConstantInitializer();        public static CNTKDictionary ConstantInitializer();
           public static CNTKDictionary ConstantInitializer(double value);        public static CNTKDictionary ConstantInitializer(double value);
           public static CNTKDictionary CTFDeserializer(string fileName, StreamConfigurationVector streams);        public static CNTKDictionary CTFDeserializer(string fileName, StreamConfigurationVector streams);
           public static CNTKDictionary GlorotNormalInitializer();        public static CNTKDictionary GlorotNormalInitializer();
           public static CNTKDictionary GlorotNormalInitializer(double scale);        public static CNTKDictionary GlorotNormalInitializer(double scale);
           public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank);        public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank);
           public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary GlorotNormalInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static CNTKDictionary GlorotUniformInitializer();        public static CNTKDictionary GlorotUniformInitializer();
           public static CNTKDictionary GlorotUniformInitializer(double scale);        public static CNTKDictionary GlorotUniformInitializer(double scale);
           public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank);        public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank);
           public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary GlorotUniformInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static CNTKDictionary HeNormalInitializer();        public static CNTKDictionary HeNormalInitializer();
           public static CNTKDictionary HeNormalInitializer(double scale);        public static CNTKDictionary HeNormalInitializer(double scale);
           public static CNTKDictionary HeNormalInitializer(double scale, int outputRank);        public static CNTKDictionary HeNormalInitializer(double scale, int outputRank);
           public static CNTKDictionary HeNormalInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary HeNormalInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary HeNormalInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary HeNormalInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static CNTKDictionary HeUniformInitializer();        public static CNTKDictionary HeUniformInitializer();
           public static CNTKDictionary HeUniformInitializer(double scale);        public static CNTKDictionary HeUniformInitializer(double scale);
           public static CNTKDictionary HeUniformInitializer(double scale, int outputRank);        public static CNTKDictionary HeUniformInitializer(double scale, int outputRank);
           public static CNTKDictionary HeUniformInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary HeUniformInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary HeUniformInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary HeUniformInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static CNTKDictionary HTKFeatureDeserializer(HTKFeatureConfigurationVector streams);        public static CNTKDictionary HTKFeatureDeserializer(HTKFeatureConfigurationVector streams);
           public static CNTKDictionary HTKMLFDeserializer(string streamName, string labelMappingFile, uint dimension, StringVector mlfFiles);        public static CNTKDictionary HTKMLFDeserializer(string streamName, string labelMappingFile, uint dimension, StringVector mlfFiles);
           public static CNTKDictionary HTKMLFDeserializer(string streamName, string labelMappingFile, uint dimension, StringVector mlfFiles, bool phoneBoundaries);        public static CNTKDictionary HTKMLFDeserializer(string streamName, string labelMappingFile, uint dimension, StringVector mlfFiles, bool phoneBoundaries);
           public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName);        public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName);
           public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, DictionaryVector transforms);        public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, DictionaryVector transforms);
           public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, IList<CNTKDictionary> deserializers);        public static CNTKDictionary ImageDeserializer(string fileName, string labelStreamName, uint numLabels, string imageStreamName, IList<CNTKDictionary> deserializers);
           public static CNTKDictionary LatticeDeserializer(string streamName, string latticeIndexFile);        public static CNTKDictionary LatticeDeserializer(string streamName, string latticeIndexFile);
           public static CNTKDictionary NormalInitializer(double scale);        public static CNTKDictionary NormalInitializer(double scale);
           public static CNTKDictionary NormalInitializer(double scale, int outputRank);        public static CNTKDictionary NormalInitializer(double scale, int outputRank);
           public static CNTKDictionary NormalInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary NormalInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary NormalInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary NormalInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static CNTKDictionary RandomInitializerWithRank(CNTKDictionary initializer, int outputRank, int filterRank);        public static CNTKDictionary RandomInitializerWithRank(CNTKDictionary initializer, int outputRank, int filterRank);
           public static CNTKDictionary ReaderColor();        public static CNTKDictionary ReaderColor();
           public static CNTKDictionary ReaderColor(float brightnessRadius);        public static CNTKDictionary ReaderColor(float brightnessRadius);
           public static CNTKDictionary ReaderColor(float brightnessRadius, float contrastRadius);        public static CNTKDictionary ReaderColor(float brightnessRadius, float contrastRadius);
           public static CNTKDictionary ReaderColor(float brightnessRadius, float contrastRadius, float saturationRadius);        public static CNTKDictionary ReaderColor(float brightnessRadius, float contrastRadius, float saturationRadius);
           public static CNTKDictionary ReaderCrop();        public static CNTKDictionary ReaderCrop();
           public static CNTKDictionary ReaderCrop(string cropType);        public static CNTKDictionary ReaderCrop(string cropType);
           public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize);        public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize);
           public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio);        public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio);
           public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio);        public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio);
           public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio, PairFloatFloat aspectRatio);        public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio, PairFloatFloat aspectRatio);
           public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio, PairFloatFloat aspectRatio, string jitterType);        public static CNTKDictionary ReaderCrop(string cropType, PairIntInt cropSize, PairFloatFloat sideRatio, PairFloatFloat areaRatio, PairFloatFloat aspectRatio, string jitterType);
           public static CNTKDictionary ReaderCrop(string cropType, Tuple<int, int> cropSize, Tuple<float, float> sideRatio, Tuple<float, float> areaRatio, Tuple<float, float> aspectRatio, string jitterType);        public static CNTKDictionary ReaderCrop(string cropType, Tuple<int, int> cropSize, Tuple<float, float> sideRatio, Tuple<float, float> areaRatio, Tuple<float, float> aspectRatio, string jitterType);
           public static CNTKDictionary ReaderMean(string meanFile);        public static CNTKDictionary ReaderMean(string meanFile);
           public static CNTKDictionary ReaderScale(int width, int height, int channels);        public static CNTKDictionary ReaderScale(int width, int height, int channels);
           public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations);        public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations);
           public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations, string scaleMode);        public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations, string scaleMode);
           public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations, string scaleMode, int padValue);        public static CNTKDictionary ReaderScale(int width, int height, int channels, string interpolations, string scaleMode, int padValue);
           public static CNTKDictionary TruncatedNormalInitializer();        public static CNTKDictionary TruncatedNormalInitializer();
           public static CNTKDictionary TruncatedNormalInitializer(double scale);        public static CNTKDictionary TruncatedNormalInitializer(double scale);
           public static CNTKDictionary TruncatedNormalInitializer(double scale, uint seed);        public static CNTKDictionary TruncatedNormalInitializer(double scale, uint seed);
           public static CNTKDictionary UniformInitializer(double scale);        public static CNTKDictionary UniformInitializer(double scale);
           public static CNTKDictionary UniformInitializer(double scale, uint seed);        public static CNTKDictionary UniformInitializer(double scale, uint seed);
           public static CNTKDictionary XavierInitializer();        public static CNTKDictionary XavierInitializer();
           public static CNTKDictionary XavierInitializer(double scale);        public static CNTKDictionary XavierInitializer(double scale);
           public static CNTKDictionary XavierInitializer(double scale, int outputRank);        public static CNTKDictionary XavierInitializer(double scale, int outputRank);
           public static CNTKDictionary XavierInitializer(double scale, int outputRank, int filterRank);        public static CNTKDictionary XavierInitializer(double scale, int outputRank, int filterRank);
           public static CNTKDictionary XavierInitializer(double scale, int outputRank, int filterRank, uint seed);        public static CNTKDictionary XavierInitializer(double scale, int outputRank, int filterRank, uint seed);
           public static double MomentumFromTimeConstant(double momTC);        public static double MomentumFromTimeConstant(double momTC);
           public static Evaluator CreateEvaluator(Function evaluationFunction);        public static Evaluator CreateEvaluator(Function evaluationFunction);
           public static Evaluator CreateEvaluator(Function evaluationFunction, ProgressWriterVector progressWriters);        public static Evaluator CreateEvaluator(Function evaluationFunction, ProgressWriterVector progressWriters);
           public static Function Abs(Variable operand);        public static Function Abs(Variable operand);
           public static Function Abs(Variable operand, string name);        public static Function Abs(Variable operand, string name);
           public static Function Acos(Variable operand);        public static Function Acos(Variable operand);
           public static Function Acos(Variable operand, string name);        public static Function Acos(Variable operand, string name);
           public static Function Alias(Variable operand);        public static Function Alias(Variable operand);
           public static Function Alias(Variable operand, string name);        public static Function Alias(Variable operand, string name);
           public static Function Argmax(Variable operand, Axis axis);        public static Function Argmax(Variable operand, Axis axis);
           public static Function Argmax(Variable operand, Axis axis, string name);        public static Function Argmax(Variable operand, Axis axis, string name);
           public static Function Argmin(Variable operand, Axis axis);        public static Function Argmin(Variable operand, Axis axis);
           public static Function Argmin(Variable operand, Axis axis, string name);        public static Function Argmin(Variable operand, Axis axis, string name);
           public static Function AsComposite(Function rootFunction);        public static Function AsComposite(Function rootFunction);
           public static Function AsComposite(Function rootFunction, string name);        public static Function AsComposite(Function rootFunction, string name);
           public static Function Asin(Variable operand);        public static Function Asin(Variable operand);
           public static Function Asin(Variable operand, string name);        public static Function Asin(Variable operand, string name);
           public static Function Asinh(Variable operand);        public static Function Asinh(Variable operand);
           public static Function Asinh(Variable operand, string name);        public static Function Asinh(Variable operand, string name);
           public static Function Assign(Variable arg0, Variable operand);        public static Function Assign(Variable arg0, Variable operand);
           public static Function Assign(Variable arg0, Variable operand, string name);        public static Function Assign(Variable arg0, Variable operand, string name);
    .        public static Function Atan(Variable operand);  
           public static Function Atan(Variable operand, string name);  
           public static Function Atanh(Variable operand);        public static Function Atanh(Variable operand);
           public static Function Atanh(Variable operand, string name);        public static Function Atanh(Variable operand, string name);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine, bool disableRegularization);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine, bool disableRegularization);
           public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine, bool disableRegularization, string name);        public static Function BatchNormalization(Variable operand, Variable scale, Variable bias, Variable runningMean, Variable runningInvStd, Variable runningCount, bool spatial, double normalizationTimeConstant, double blendTimeConstant, double epsilon, bool useCuDNNEngine, bool disableRegularization, string name);
           public static Function BernoulliRandom(NDShape shape, DataType dataType);        public static Function BernoulliRandom(NDShape shape, DataType dataType);
           public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean);        public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean);
           public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean, uint seed);        public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean, uint seed);
           public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean, uint seed, string name);        public static Function BernoulliRandom(NDShape shape, DataType dataType, double mean, uint seed, string name);
           public static Function BernoulliRandomLike(Variable operand);        public static Function BernoulliRandomLike(Variable operand);
           public static Function BernoulliRandomLike(Variable operand, double mean);        public static Function BernoulliRandomLike(Variable operand, double mean);
           public static Function BernoulliRandomLike(Variable operand, double mean, uint seed);        public static Function BernoulliRandomLike(Variable operand, double mean, uint seed);
           public static Function BernoulliRandomLike(Variable operand, double mean, uint seed, string name);        public static Function BernoulliRandomLike(Variable operand, double mean, uint seed, string name);
           public static Function BinaryCrossEntropy(Variable prediction, Variable targets);        public static Function BinaryCrossEntropy(Variable prediction, Variable targets);
           public static Function BinaryCrossEntropy(Variable prediction, Variable targets, string name);        public static Function BinaryCrossEntropy(Variable prediction, Variable targets, string name);
           public static Function Cast(Variable nodeInput, DataType outputType);        public static Function Cast(Variable nodeInput, DataType outputType);
           public static Function Cast(Variable nodeInput, DataType outputType, string name);        public static Function Cast(Variable nodeInput, DataType outputType, string name);
           public static Function Ceil(Variable operand);        public static Function Ceil(Variable operand);
           public static Function Ceil(Variable operand, string name);        public static Function Ceil(Variable operand, string name);
           public static Function ClassificationError(Variable prediction, Variable labels);        public static Function ClassificationError(Variable prediction, Variable labels);
           public static Function ClassificationError(Variable prediction, Variable labels, Axis axis);        public static Function ClassificationError(Variable prediction, Variable labels, Axis axis);
           public static Function ClassificationError(Variable prediction, Variable labels, Axis axis, string name);        public static Function ClassificationError(Variable prediction, Variable labels, Axis axis, string name);
           public static Function ClassificationError(Variable prediction, Variable labels, string name);        public static Function ClassificationError(Variable prediction, Variable labels, string name);
           public static Function ClassificationError(Variable prediction, Variable labels, uint topN);        public static Function ClassificationError(Variable prediction, Variable labels, uint topN);
           public static Function ClassificationError(Variable prediction, Variable labels, uint topN, Axis axis);        public static Function ClassificationError(Variable prediction, Variable labels, uint topN, Axis axis);
           public static Function ClassificationError(Variable prediction, Variable labels, uint topN, Axis axis, string name);        public static Function ClassificationError(Variable prediction, Variable labels, uint topN, Axis axis, string name);
           public static Function ClassificationError(Variable prediction, Variable labels, uint topN, string name);        public static Function ClassificationError(Variable prediction, Variable labels, uint topN, string name);
           public static Function Clip(Variable operand, Variable min, Variable max);        public static Function Clip(Variable operand, Variable min, Variable max);
           public static Function Clip(Variable operand, Variable min, Variable max, string name);        public static Function Clip(Variable operand, Variable min, Variable max, string name);
           public static Function Combine(VariableVector operands);        public static Function Combine(VariableVector operands);
           public static Function Combine(VariableVector operands, string name);        public static Function Combine(VariableVector operands, string name);
           public static Function Convolution(Variable convolutionMap, Variable operand);        public static Function Convolution(Variable convolutionMap, Variable operand);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups, uint maxTempMemSizeInSamples);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups, uint maxTempMemSizeInSamples);
    .        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups, uint maxTempMemSizeInSamples, bool sequential);         public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups, uint maxTempMemSizeInSamples, string name);
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint reductionRank, uint groups, uint maxTempMemSizeInSamples, bool sequential, string name);  
           public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, IEnumerable<bool> sharing, IEnumerable<bool> autoPadding);        public static Function Convolution(Variable convolutionMap, Variable operand, NDShape strides, IEnumerable<bool> sharing, IEnumerable<bool> autoPadding);
    .        public static Function ConvolutionSequenceShape(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, bool transpose, NDShape outputShape, uint groups, uint maxTempMemSizeInSamples);  
           public static Function ConvolutionSequenceShape(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, bool transpose, NDShape outputShape, uint groups, uint maxTempMemSizeInSamples, string name);  
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank, uint maxTempMemSizeInSamples);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank, uint maxTempMemSizeInSamples);
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank, uint maxTempMemSizeInSamples, string name);        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape outputShape, NDShape dilation, uint reductionRank, uint maxTempMemSizeInSamples, string name);
    .        public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, SizeTVector lowerPad, SizeTVector upperPad, NDShape outputShape, NDShape dilation, uint maxTempMemSizeInSamples);  
           public static Function ConvolutionTranspose(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, SizeTVector lowerPad, SizeTVector upperPad, NDShape outputShape, NDShape dilation, uint maxTempMemSizeInSamples, string name);  
           public static Function Cos(Variable operand);        public static Function Cos(Variable operand);
           public static Function Cos(Variable operand, string name);        public static Function Cos(Variable operand, string name);
           public static Function Cosh(Variable operand);        public static Function Cosh(Variable operand);
           public static Function Cosh(Variable operand, string name);        public static Function Cosh(Variable operand, string name);
           public static Function CosineDistance(Variable leftOperand, Variable rightOperand);        public static Function CosineDistance(Variable leftOperand, Variable rightOperand);
           public static Function CosineDistance(Variable leftOperand, Variable rightOperand, string name);        public static Function CosineDistance(Variable leftOperand, Variable rightOperand, string name);
           public static Function CosineDistanceWithNegativeSamples(Variable leftOperand, Variable rightOperand, uint shiftWindow, uint numberOfNegativeSamples);        public static Function CosineDistanceWithNegativeSamples(Variable leftOperand, Variable rightOperand, uint shiftWindow, uint numberOfNegativeSamples);
           public static Function CosineDistanceWithNegativeSamples(Variable leftOperand, Variable rightOperand, uint shiftWindow, uint numberOfNegativeSamples, string name);        public static Function CosineDistanceWithNegativeSamples(Variable leftOperand, Variable rightOperand, uint shiftWindow, uint numberOfNegativeSamples, string name);
           public static Function Crop(Variable nodeInput, Variable nodeReferent);        public static Function Crop(Variable nodeInput, Variable nodeReferent);
           public static Function Crop(Variable nodeInput, Variable nodeReferent, string name);        public static Function Crop(Variable nodeInput, Variable nodeReferent, string name);
           public static Function Crop(Variable nodeInput, Variable nodeReferent, uint offsetX, uint offsetY);        public static Function Crop(Variable nodeInput, Variable nodeReferent, uint offsetX, uint offsetY);
           public static Function Crop(Variable nodeInput, Variable nodeReferent, uint offsetX, uint offsetY, string name);        public static Function Crop(Variable nodeInput, Variable nodeReferent, uint offsetX, uint offsetY, string name);
           public static Function Crop(Variable nodeInput, Variable nodeReferent, Variable ancestorInput, Variable ancestorReferent);        public static Function Crop(Variable nodeInput, Variable nodeReferent, Variable ancestorInput, Variable ancestorReferent);
           public static Function Crop(Variable nodeInput, Variable nodeReferent, Variable ancestorInput, Variable ancestorReferent, string name);        public static Function Crop(Variable nodeInput, Variable nodeReferent, Variable ancestorInput, Variable ancestorReferent, string name);
           public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels);        public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels);
           public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, Axis axis);        public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, Axis axis);
           public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, Axis axis, string name);        public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, Axis axis, string name);
           public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, string name);        public static Function CrossEntropyWithSoftmax(Variable prediction, Variable labels, string name);
    .        public static Function CustomProxyOp(VariableVector operands, string customOp, NDShape outputShape, DataType outputType);  
           public static Function CustomProxyOp(VariableVector operands, string customOp, NDShape outputShape, DataType outputType, string name);  
           public static Function DepthToSpace(Variable operand, uint blockSize);        public static Function DepthToSpace(Variable operand, uint blockSize);
           public static Function DepthToSpace(Variable operand, uint blockSize, string name);        public static Function DepthToSpace(Variable operand, uint blockSize, string name);
           public static Function Dropout(Variable operand, double dropoutRate);        public static Function Dropout(Variable operand, double dropoutRate);
           public static Function Dropout(Variable operand, double dropoutRate, uint seed);        public static Function Dropout(Variable operand, double dropoutRate, uint seed);
           public static Function Dropout(Variable operand, double dropoutRate, uint seed, string name);        public static Function Dropout(Variable operand, double dropoutRate, uint seed, string name);
           public static Function EditDistanceError(Variable prediction, Variable labels, float substitutionPenalty, float deletionPenalty, float insertionPenalty, bool squashInputs, SizeTVector tokensToIgnore);        public static Function EditDistanceError(Variable prediction, Variable labels, float substitutionPenalty, float deletionPenalty, float insertionPenalty, bool squashInputs, SizeTVector tokensToIgnore);
           public static Function EditDistanceError(Variable prediction, Variable labels, float substitutionPenalty, float deletionPenalty, float insertionPenalty, bool squashInputs, SizeTVector tokensToIgnore, string name);        public static Function EditDistanceError(Variable prediction, Variable labels, float substitutionPenalty, float deletionPenalty, float insertionPenalty, bool squashInputs, SizeTVector tokensToIgnore, string name);
           public static Function ElementAnd(Variable leftOperand, Variable rightOperand);        public static Function ElementAnd(Variable leftOperand, Variable rightOperand);
           public static Function ElementAnd(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementAnd(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementDivide(Variable leftOperand, Variable rightOperand);        public static Function ElementDivide(Variable leftOperand, Variable rightOperand);
           public static Function ElementDivide(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementDivide(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementMax(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementMax(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementMin(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementMin(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementNot(Variable operand);        public static Function ElementNot(Variable operand);
           public static Function ElementNot(Variable operand, string name);        public static Function ElementNot(Variable operand, string name);
           public static Function ElementOr(Variable leftOperand, Variable rightOperand);        public static Function ElementOr(Variable leftOperand, Variable rightOperand);
           public static Function ElementOr(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementOr(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementSelect(Variable condition, Variable thenOperand, Variable elseOperand);        public static Function ElementSelect(Variable condition, Variable thenOperand, Variable elseOperand);
           public static Function ElementSelect(Variable condition, Variable thenOperand, Variable elseOperand, string name);        public static Function ElementSelect(Variable condition, Variable thenOperand, Variable elseOperand, string name);
           public static Function ElementTimes(Variable leftOperand, Variable rightOperand);        public static Function ElementTimes(Variable leftOperand, Variable rightOperand);
           public static Function ElementTimes(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementTimes(Variable leftOperand, Variable rightOperand, string name);
           public static Function ElementXor(Variable leftOperand, Variable rightOperand);        public static Function ElementXor(Variable leftOperand, Variable rightOperand);
           public static Function ElementXor(Variable leftOperand, Variable rightOperand, string name);        public static Function ElementXor(Variable leftOperand, Variable rightOperand, string name);
           public static Function ELU(Variable operand);        public static Function ELU(Variable operand);
    .        public static Function ELU(Variable operand, double alpha);  
           public static Function ELU(Variable operand, double alpha, string name);  
           public static Function ELU(Variable operand, string name);        public static Function ELU(Variable operand, string name);
           public static Function Equal(Variable leftOperand, Variable rightOperand);        public static Function Equal(Variable leftOperand, Variable rightOperand);
           public static Function Equal(Variable leftOperand, Variable rightOperand, string name);        public static Function Equal(Variable leftOperand, Variable rightOperand, string name);
           public static Function Exp(Variable operand);        public static Function Exp(Variable operand);
           public static Function Exp(Variable operand, string name);        public static Function Exp(Variable operand, string name);
           public static Function ExpandDims(Variable operand, Axis axis);        public static Function ExpandDims(Variable operand, Axis axis);
           public static Function ExpandDims(Variable operand, Axis axis, string name);        public static Function ExpandDims(Variable operand, Axis axis, string name);
    .        public static Function EyeLike(Variable operand, bool isOutputSparse);  
           public static Function EyeLike(Variable operand, bool isOutputSparse, string name);  
           public static Function Flatten(Variable operand);        public static Function Flatten(Variable operand);
           public static Function Flatten(Variable operand, Axis axis);        public static Function Flatten(Variable operand, Axis axis);
           public static Function Flatten(Variable operand, Axis axis, string name);        public static Function Flatten(Variable operand, Axis axis, string name);
           public static Function Flatten(Variable operand, string name);        public static Function Flatten(Variable operand, string name);
           public static Function Floor(Variable operand);        public static Function Floor(Variable operand);
           public static Function Floor(Variable operand, string name);        public static Function Floor(Variable operand, string name);
           public static Function ForwardBackward(Variable graph, Variable features, uint blankTokenId, int delayConstraint);        public static Function ForwardBackward(Variable graph, Variable features, uint blankTokenId, int delayConstraint);
           public static Function ForwardBackward(Variable graph, Variable features, uint blankTokenId, int delayConstraint, string name);        public static Function ForwardBackward(Variable graph, Variable features, uint blankTokenId, int delayConstraint, string name);
           public static Function FutureValue(Variable operand);        public static Function FutureValue(Variable operand);
           public static Function FutureValue(Variable operand, uint offset);        public static Function FutureValue(Variable operand, uint offset);
           public static Function FutureValue(Variable operand, uint offset, string name);        public static Function FutureValue(Variable operand, uint offset, string name);
           public static Function FutureValue(Variable operand, Variable initialState);        public static Function FutureValue(Variable operand, Variable initialState);
           public static Function FutureValue(Variable operand, Variable initialState, uint offset);        public static Function FutureValue(Variable operand, Variable initialState, uint offset);
           public static Function FutureValue(Variable operand, Variable initialState, uint offset, string name);        public static Function FutureValue(Variable operand, Variable initialState, uint offset, string name);
           public static Function GatherOp(Variable indices, Variable reference);        public static Function GatherOp(Variable indices, Variable reference);
           public static Function GatherOp(Variable indices, Variable reference, Axis axis);        public static Function GatherOp(Variable indices, Variable reference, Axis axis);
           public static Function GatherOp(Variable indices, Variable reference, Axis axis, string name);        public static Function GatherOp(Variable indices, Variable reference, Axis axis, string name);
           public static Function GatherOp(Variable indices, Variable reference, string name);        public static Function GatherOp(Variable indices, Variable reference, string name);
    .        public static Function Gemm(Variable operandA, Variable operandB, Variable operandC);  
           public static Function Gemm(Variable operandA, Variable operandB, Variable operandC, float alpha);  
           public static Function Gemm(Variable operandA, Variable operandB, Variable operandC, float alpha, float beta);  
           public static Function Gemm(Variable operandA, Variable operandB, Variable operandC, float alpha, float beta, bool transA);  
           public static Function Gemm(Variable operandA, Variable operandB, Variable operandC, float alpha, float beta, bool transA, bool transB);  
           public static Function Gemm(Variable operandA, Variable operandB, Variable operandC, float alpha, float beta, bool transA, bool transB, string name);  
           public static Function Greater(Variable leftOperand, Variable rightOperand);        public static Function Greater(Variable leftOperand, Variable rightOperand);
           public static Function Greater(Variable leftOperand, Variable rightOperand, string name);        public static Function Greater(Variable leftOperand, Variable rightOperand, string name);
           public static Function GreaterEqual(Variable leftOperand, Variable rightOperand);        public static Function GreaterEqual(Variable leftOperand, Variable rightOperand);
           public static Function GreaterEqual(Variable leftOperand, Variable rightOperand, string name);        public static Function GreaterEqual(Variable leftOperand, Variable rightOperand, string name);
    .          public static Function GroupConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint groups, uint maxTempMemSizeInSamples);
             public static Function GroupConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint groups, uint maxTempMemSizeInSamples, string name);
           public static Function GumbelRandom(NDShape shape, DataType dataType);        public static Function GumbelRandom(NDShape shape, DataType dataType);
           public static Function GumbelRandom(NDShape shape, DataType dataType, double loc);        public static Function GumbelRandom(NDShape shape, DataType dataType, double loc);
           public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale);        public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale);
           public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale, uint seed);        public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale, uint seed);
           public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale, uint seed, string name);        public static Function GumbelRandom(NDShape shape, DataType dataType, double loc, double scale, uint seed, string name);
           public static Function GumbelRandomLike(Variable operand);        public static Function GumbelRandomLike(Variable operand);
           public static Function GumbelRandomLike(Variable operand, double loc);        public static Function GumbelRandomLike(Variable operand, double loc);
           public static Function GumbelRandomLike(Variable operand, double loc, double scale);        public static Function GumbelRandomLike(Variable operand, double loc, double scale);
           public static Function GumbelRandomLike(Variable operand, double loc, double scale, uint seed);        public static Function GumbelRandomLike(Variable operand, double loc, double scale, uint seed);
           public static Function GumbelRandomLike(Variable operand, double loc, double scale, uint seed, string name);        public static Function GumbelRandomLike(Variable operand, double loc, double scale, uint seed, string name);
           public static Function Hardmax(Variable operand);        public static Function Hardmax(Variable operand);
           public static Function Hardmax(Variable operand, string name);        public static Function Hardmax(Variable operand, string name);
           public static Function HardSigmoid(Variable operand, float alpha, float beta);        public static Function HardSigmoid(Variable operand, float alpha, float beta);
           public static Function HardSigmoid(Variable operand, float alpha, float beta, string name);        public static Function HardSigmoid(Variable operand, float alpha, float beta, string name);
           public static Function ImageScaler(Variable operand, float scaler, FloatVector biases, string name);        public static Function ImageScaler(Variable operand, float scaler, FloatVector biases, string name);
           public static Function LabelsToGraph(Variable labels);        public static Function LabelsToGraph(Variable labels);
           public static Function LabelsToGraph(Variable labels, string name);        public static Function LabelsToGraph(Variable labels, string name);
           public static Function LambdaRank(Variable prediction, Variable gains, Variable groupId);        public static Function LambdaRank(Variable prediction, Variable gains, Variable groupId);
           public static Function LambdaRank(Variable prediction, Variable gains, Variable groupId, string name);        public static Function LambdaRank(Variable prediction, Variable gains, Variable groupId, string name);
           public static Function LatticeSequenceWithSoftmax(Variable labels, Variable prediction, Variable scaledLogLikelihood, Variable lattice, string symbolListPath, string phonePath, string stateListPath, string transitionProbabilityPath, string configFilePath, float smoothingWeight, float frameDropThreshold, bool doReferenceAlign, bool gammarUsesMBR, float gammarAMF, float gammarLMF, float gammarBMMIFactor, float gammarWordPenalty);        public static Function LatticeSequenceWithSoftmax(Variable labels, Variable prediction, Variable scaledLogLikelihood, Variable lattice, string symbolListPath, string phonePath, string stateListPath, string transitionProbabilityPath, string configFilePath, float smoothingWeight, float frameDropThreshold, bool doReferenceAlign, bool gammarUsesMBR, float gammarAMF, float gammarLMF, float gammarBMMIFactor, float gammarWordPenalty);
           public static Function LatticeSequenceWithSoftmax(Variable labels, Variable prediction, Variable scaledLogLikelihood, Variable lattice, string symbolListPath, string phonePath, string stateListPath, string transitionProbabilityPath, string configFilePath, float smoothingWeight, float frameDropThreshold, bool doReferenceAlign, bool gammarUsesMBR, float gammarAMF, float gammarLMF, float gammarBMMIFactor, float gammarWordPenalty, string name);        public static Function LatticeSequenceWithSoftmax(Variable labels, Variable prediction, Variable scaledLogLikelihood, Variable lattice, string symbolListPath, string phonePath, string stateListPath, string transitionProbabilityPath, string configFilePath, float smoothingWeight, float frameDropThreshold, bool doReferenceAlign, bool gammarUsesMBR, float gammarAMF, float gammarLMF, float gammarBMMIFactor, float gammarWordPenalty, string name);
           public static Function LeakyReLU(Variable operand, double alpha);        public static Function LeakyReLU(Variable operand, double alpha);
           public static Function LeakyReLU(Variable operand, double alpha, string name);        public static Function LeakyReLU(Variable operand, double alpha, string name);
           public static Function Less(Variable leftOperand, Variable rightOperand);        public static Function Less(Variable leftOperand, Variable rightOperand);
           public static Function Less(Variable leftOperand, Variable rightOperand, string name);        public static Function Less(Variable leftOperand, Variable rightOperand, string name);
           public static Function LessEqual(Variable leftOperand, Variable rightOperand);        public static Function LessEqual(Variable leftOperand, Variable rightOperand);
           public static Function LessEqual(Variable leftOperand, Variable rightOperand, string name);        public static Function LessEqual(Variable leftOperand, Variable rightOperand, string name);
           public static Function LocalResponseNormalization(Variable operand, uint depthRadius, double bias, double alpha, double beta);        public static Function LocalResponseNormalization(Variable operand, uint depthRadius, double bias, double alpha, double beta);
           public static Function LocalResponseNormalization(Variable operand, uint depthRadius, double bias, double alpha, double beta, string name);        public static Function LocalResponseNormalization(Variable operand, uint depthRadius, double bias, double alpha, double beta, string name);
           public static Function Log(Variable operand);        public static Function Log(Variable operand);
           public static Function Log(Variable operand, string name);        public static Function Log(Variable operand, string name);
           public static Function LogAddExp(Variable leftOperand, Variable rightOperand);        public static Function LogAddExp(Variable leftOperand, Variable rightOperand);
           public static Function LogAddExp(Variable leftOperand, Variable rightOperand, string name);        public static Function LogAddExp(Variable leftOperand, Variable rightOperand, string name);
           public static Function LogSoftmax(Variable operand);        public static Function LogSoftmax(Variable operand);
           public static Function LogSoftmax(Variable operand, Axis axis);        public static Function LogSoftmax(Variable operand, Axis axis);
           public static Function LogSoftmax(Variable operand, Axis axis, string name);        public static Function LogSoftmax(Variable operand, Axis axis, string name);
           public static Function LogSoftmax(Variable operand, string name);        public static Function LogSoftmax(Variable operand, string name);
    .        public static Function MatMul(Variable leftOperand, Variable rightOperand);  
           public static Function MatMul(Variable leftOperand, Variable rightOperand, string name);  
           public static Function Mean(VariableVector operands);        public static Function Mean(VariableVector operands);
           public static Function Mean(VariableVector operands, string name);        public static Function Mean(VariableVector operands, string name);
           public static Function MeanVarianceNormalization(Variable operand);        public static Function MeanVarianceNormalization(Variable operand);
           public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels);        public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels);
           public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels, bool doVarianceScaling);        public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels, bool doVarianceScaling);
           public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels, bool doVarianceScaling, string name);        public static Function MeanVarianceNormalization(Variable operand, bool useStatsAcrossChannels, bool doVarianceScaling, string name);
           public static Function MeanVarianceNormalization(Variable operand, double epsilon);        public static Function MeanVarianceNormalization(Variable operand, double epsilon);
           public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels);        public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels);
           public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels, bool doVarianceScaling);        public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels, bool doVarianceScaling);
           public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels, bool doVarianceScaling, string name);        public static Function MeanVarianceNormalization(Variable operand, double epsilon, bool useStatsAcrossChannels, bool doVarianceScaling, string name);
           public static Function Minus(Variable leftOperand, Variable rightOperand);        public static Function Minus(Variable leftOperand, Variable rightOperand);
           public static Function Minus(Variable leftOperand, Variable rightOperand, string name);        public static Function Minus(Variable leftOperand, Variable rightOperand, string name);
           public static Function NDCGAt1(Variable prediction, Variable gains, Variable groupId);        public static Function NDCGAt1(Variable prediction, Variable gains, Variable groupId);
           public static Function NDCGAt1(Variable prediction, Variable gains, Variable groupId, string name);        public static Function NDCGAt1(Variable prediction, Variable gains, Variable groupId, string name);
           public static Function Negate(Variable operand);        public static Function Negate(Variable operand);
           public static Function Negate(Variable operand, string name);        public static Function Negate(Variable operand, string name);
           public static Function NormalRandom(NDShape shape, DataType dataType);        public static Function NormalRandom(NDShape shape, DataType dataType);
           public static Function NormalRandom(NDShape shape, DataType dataType, double mean);        public static Function NormalRandom(NDShape shape, DataType dataType, double mean);
           public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale);        public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale);
           public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale, uint seed);        public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale, uint seed);
           public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale, uint seed, string name);        public static Function NormalRandom(NDShape shape, DataType dataType, double mean, double scale, uint seed, string name);
           public static Function NormalRandomLike(Variable operand);        public static Function NormalRandomLike(Variable operand);
           public static Function NormalRandomLike(Variable operand, double mean);        public static Function NormalRandomLike(Variable operand, double mean);
           public static Function NormalRandomLike(Variable operand, double mean, double scale);        public static Function NormalRandomLike(Variable operand, double mean, double scale);
           public static Function NormalRandomLike(Variable operand, double mean, double scale, uint seed);        public static Function NormalRandomLike(Variable operand, double mean, double scale, uint seed);
           public static Function NormalRandomLike(Variable operand, double mean, double scale, uint seed, string name);        public static Function NormalRandomLike(Variable operand, double mean, double scale, uint seed, string name);
           public static Function NotEqual(Variable leftOperand, Variable rightOperand);        public static Function NotEqual(Variable leftOperand, Variable rightOperand);
           public static Function NotEqual(Variable leftOperand, Variable rightOperand, string name);        public static Function NotEqual(Variable leftOperand, Variable rightOperand, string name);
           public static Function OneHotOp(Variable operand, uint numClass, bool outputSparse, Axis axis);        public static Function OneHotOp(Variable operand, uint numClass, bool outputSparse, Axis axis);
           public static Function OneHotOp(Variable operand, uint numClass, bool outputSparse, Axis axis, string name);        public static Function OneHotOp(Variable operand, uint numClass, bool outputSparse, Axis axis, string name);
           public static Function OnesLike(Variable operand);        public static Function OnesLike(Variable operand);
           public static Function OnesLike(Variable operand, string name);        public static Function OnesLike(Variable operand, string name);
           public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers);        public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers);
           public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional);        public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional);
           public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional, string recurrentOp);        public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional, string recurrentOp);
           public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional, string recurrentOp, string name);        public static Function OptimizedRNNStack(Variable operand, Variable weights, uint hiddenSize, uint numLayers, bool bidirectional, string recurrentOp, string name);
           public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot);        public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot);
           public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot, double constantValue);        public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot, double constantValue);
           public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot, double constantValue, string name);        public static Function Pad(Variable operand, PaddingMode mode, SizeTVector head, SizeTVector foot, double constantValue, string name);
           public static Function PastValue(Variable operand);        public static Function PastValue(Variable operand);
           public static Function PastValue(Variable operand, uint offset);        public static Function PastValue(Variable operand, uint offset);
           public static Function PastValue(Variable operand, uint offset, string name);        public static Function PastValue(Variable operand, uint offset, string name);
           public static Function PastValue(Variable operand, Variable initialState);        public static Function PastValue(Variable operand, Variable initialState);
           public static Function PastValue(Variable operand, Variable initialState, uint offset);        public static Function PastValue(Variable operand, Variable initialState, uint offset);
           public static Function PastValue(Variable operand, Variable initialState, uint offset, string name);        public static Function PastValue(Variable operand, Variable initialState, uint offset, string name);
           public static Function PerDimMeanVarianceNormalize(Variable operand, NDArrayView mean, NDArrayView invStdDev);        public static Function PerDimMeanVarianceNormalize(Variable operand, NDArrayView mean, NDArrayView invStdDev);
           public static Function PerDimMeanVarianceNormalize(Variable operand, NDArrayView mean, NDArrayView invStdDev, string name);        public static Function PerDimMeanVarianceNormalize(Variable operand, NDArrayView mean, NDArrayView invStdDev, string name);
           public static Function PerDimMeanVarianceNormalize(Variable operand, Variable mean, Variable invStdDev);        public static Function PerDimMeanVarianceNormalize(Variable operand, Variable mean, Variable invStdDev);
           public static Function PerDimMeanVarianceNormalize(Variable operand, Variable mean, Variable invStdDev, string name);        public static Function PerDimMeanVarianceNormalize(Variable operand, Variable mean, Variable invStdDev, string name);
           public static Function Plus(Variable leftOperand, Variable rightOperand);        public static Function Plus(Variable leftOperand, Variable rightOperand);
           public static Function Plus(Variable leftOperand, Variable rightOperand, string name);        public static Function Plus(Variable leftOperand, Variable rightOperand, string name);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim, bool includePad);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim, bool includePad);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim, bool includePad, string name);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, BoolVector autoPadding, bool ceilOutDim, bool includePad, string name);
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, IEnumerable<bool> autoPadding);        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, IEnumerable<bool> autoPadding);
    .        public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, SizeTVector lowerPad, SizeTVector upperPad);  
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, SizeTVector lowerPad, SizeTVector upperPad, bool ceilOutDim);  
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, SizeTVector lowerPad, SizeTVector upperPad, bool ceilOutDim, bool includePad);  
           public static Function Pooling(Variable operand, PoolingType poolingType, NDShape poolingWindowShape, NDShape strides, SizeTVector lowerPad, SizeTVector upperPad, bool ceilOutDim, bool includePad, string name);  
           public static Function Pow(Variable leftOperand, Variable rightOperand);        public static Function Pow(Variable leftOperand, Variable rightOperand);
           public static Function Pow(Variable leftOperand, Variable rightOperand, string name);        public static Function Pow(Variable leftOperand, Variable rightOperand, string name);
           public static Function PReLU(Variable alpha, Variable operand);        public static Function PReLU(Variable alpha, Variable operand);
           public static Function PReLU(Variable alpha, Variable operand, string name);        public static Function PReLU(Variable alpha, Variable operand, string name);
           public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates);        public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates);
           public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates, uint seed);        public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates, uint seed);
           public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates, uint seed, string name);        public static Function RandomSample(Variable operand, uint numSamples, bool allowDuplicates, uint seed, string name);
           public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates);        public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates);
           public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates, uint seed);        public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates, uint seed);
           public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates, uint seed, string name);        public static Function RandomSampleInclusionFrequency(Variable operand, uint numSamples, bool allowDuplicates, uint seed, string name);
           public static Function Reciprocal(Variable operand);        public static Function Reciprocal(Variable operand);
           public static Function Reciprocal(Variable operand, string name);        public static Function Reciprocal(Variable operand, string name);
           public static Function ReconcileDynamicAxes(Variable operand, Variable axesAsOperand);        public static Function ReconcileDynamicAxes(Variable operand, Variable axesAsOperand);
           public static Function ReconcileDynamicAxes(Variable operand, Variable axesAsOperand, string name);        public static Function ReconcileDynamicAxes(Variable operand, Variable axesAsOperand, string name);
           public static Function ReduceL1(Variable operand, AxisVector axes);        public static Function ReduceL1(Variable operand, AxisVector axes);
           public static Function ReduceL1(Variable operand, AxisVector axes, bool keepDims);        public static Function ReduceL1(Variable operand, AxisVector axes, bool keepDims);
           public static Function ReduceL1(Variable operand, AxisVector axes, bool keepDims, string name);        public static Function ReduceL1(Variable operand, AxisVector axes, bool keepDims, string name);
           public static Function ReduceL2(Variable operand, AxisVector axes);        public static Function ReduceL2(Variable operand, AxisVector axes);
           public static Function ReduceL2(Variable operand, AxisVector axes, bool keepDims);        public static Function ReduceL2(Variable operand, AxisVector axes, bool keepDims);
           public static Function ReduceL2(Variable operand, AxisVector axes, bool keepDims, string name);        public static Function ReduceL2(Variable operand, AxisVector axes, bool keepDims, string name);
           public static Function ReduceLogSum(Variable operand, Axis axis);        public static Function ReduceLogSum(Variable operand, Axis axis);
           public static Function ReduceLogSum(Variable operand, Axis axis, string name);        public static Function ReduceLogSum(Variable operand, Axis axis, string name);
    .        public static Function ReduceLogSum(Variable operand, AxisVector axes);        public static Function ReduceLogSum(Variable operand, AxisVector axis);
           public static Function ReduceLogSum(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceLogSum(Variable operand, AxisVector axis, string name);
           public static Function ReduceLogSum(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceMax(Variable operand, Axis axis);        public static Function ReduceMax(Variable operand, Axis axis);
           public static Function ReduceMax(Variable operand, Axis axis, string name);        public static Function ReduceMax(Variable operand, Axis axis, string name);
    .        public static Function ReduceMax(Variable operand, AxisVector axes);        public static Function ReduceMax(Variable operand, AxisVector axis);
           public static Function ReduceMax(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceMax(Variable operand, AxisVector axis, string name);
           public static Function ReduceMax(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceMean(Variable operand, Axis axis);        public static Function ReduceMean(Variable operand, Axis axis);
           public static Function ReduceMean(Variable operand, Axis axis, string name);        public static Function ReduceMean(Variable operand, Axis axis, string name);
    .        public static Function ReduceMean(Variable operand, AxisVector axes);        public static Function ReduceMean(Variable operand, AxisVector axis);
           public static Function ReduceMean(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceMean(Variable operand, AxisVector axis, string name);
           public static Function ReduceMean(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceMin(Variable operand, Axis axis);        public static Function ReduceMin(Variable operand, Axis axis);
           public static Function ReduceMin(Variable operand, Axis axis, string name);        public static Function ReduceMin(Variable operand, Axis axis, string name);
    .        public static Function ReduceMin(Variable operand, AxisVector axes);        public static Function ReduceMin(Variable operand, AxisVector axis);
           public static Function ReduceMin(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceMin(Variable operand, AxisVector axis, string name);
           public static Function ReduceMin(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceProd(Variable operand, Axis axis);        public static Function ReduceProd(Variable operand, Axis axis);
           public static Function ReduceProd(Variable operand, Axis axis, string name);        public static Function ReduceProd(Variable operand, Axis axis, string name);
    .        public static Function ReduceProd(Variable operand, AxisVector axes);        public static Function ReduceProd(Variable operand, AxisVector axis);
           public static Function ReduceProd(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceProd(Variable operand, AxisVector axis, string name);
           public static Function ReduceProd(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceSum(Variable operand, Axis axis);        public static Function ReduceSum(Variable operand, Axis axis);
           public static Function ReduceSum(Variable operand, Axis axis, string name);        public static Function ReduceSum(Variable operand, Axis axis, string name);
    .        public static Function ReduceSum(Variable operand, AxisVector axes);        public static Function ReduceSum(Variable operand, AxisVector axis);
           public static Function ReduceSum(Variable operand, AxisVector axes, bool keepDims);         public static Function ReduceSum(Variable operand, AxisVector axis, string name);
           public static Function ReduceSum(Variable operand, AxisVector axes, bool keepDims, string name);  
           public static Function ReduceSumSquare(Variable operand, AxisVector axes);        public static Function ReduceSumSquare(Variable operand, AxisVector axes);
           public static Function ReduceSumSquare(Variable operand, AxisVector axes, bool keepDims);        public static Function ReduceSumSquare(Variable operand, AxisVector axes, bool keepDims);
           public static Function ReduceSumSquare(Variable operand, AxisVector axes, bool keepDims, string name);        public static Function ReduceSumSquare(Variable operand, AxisVector axes, bool keepDims, string name);
           public static Function ReLU(Variable operand);        public static Function ReLU(Variable operand);
           public static Function ReLU(Variable operand, string name);        public static Function ReLU(Variable operand, string name);
           public static Function Reshape(Variable operand, NDShape newShape);        public static Function Reshape(Variable operand, NDShape newShape);
           public static Function Reshape(Variable operand, NDShape newShape, string name);        public static Function Reshape(Variable operand, NDShape newShape, string name);
           public static Function Reshape(Variable operand, NDShape replacementShape, Axis beginAxis, Axis endAxis);        public static Function Reshape(Variable operand, NDShape replacementShape, Axis beginAxis, Axis endAxis);
           public static Function Reshape(Variable operand, NDShape replacementShape, Axis beginAxis, Axis endAxis, string name);        public static Function Reshape(Variable operand, NDShape replacementShape, Axis beginAxis, Axis endAxis, string name);
           public static Function ROIPooling(Variable operand, Variable rois, PoolingType poolingType, NDShape roiOutputShape, double spatialScale, string name);        public static Function ROIPooling(Variable operand, Variable rois, PoolingType poolingType, NDShape roiOutputShape, double spatialScale, string name);
           public static Function Round(Variable operand);        public static Function Round(Variable operand);
           public static Function Round(Variable operand, string name);        public static Function Round(Variable operand, string name);
           public static Function SELU(Variable operand);        public static Function SELU(Variable operand);
           public static Function SELU(Variable operand, double gamma);        public static Function SELU(Variable operand, double gamma);
           public static Function SELU(Variable operand, double gamma, double alpha);        public static Function SELU(Variable operand, double gamma, double alpha);
           public static Function SELU(Variable operand, double gamma, double alpha, string name);        public static Function SELU(Variable operand, double gamma, double alpha, string name);
           public static Function SequenceBroadcastAs(Variable operand, Variable broadcastAs);        public static Function SequenceBroadcastAs(Variable operand, Variable broadcastAs);
           public static Function SequenceBroadcastAs(Variable operand, Variable broadcastAs, string name);        public static Function SequenceBroadcastAs(Variable operand, Variable broadcastAs, string name);
           public static Function SequenceFirst(Variable operand);        public static Function SequenceFirst(Variable operand);
           public static Function SequenceFirst(Variable operand, string name);        public static Function SequenceFirst(Variable operand, string name);
           public static Function SequenceGather(Variable operand, Variable condition);        public static Function SequenceGather(Variable operand, Variable condition);
           public static Function SequenceGather(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor);        public static Function SequenceGather(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor);
           public static Function SequenceGather(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor, string name);        public static Function SequenceGather(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor, string name);
           public static Function SequenceGather(Variable operand, Variable condition, string name);        public static Function SequenceGather(Variable operand, Variable condition, string name);
           public static Function SequenceIsFirst(Variable operand);        public static Function SequenceIsFirst(Variable operand);
           public static Function SequenceIsFirst(Variable operand, string name);        public static Function SequenceIsFirst(Variable operand, string name);
           public static Function SequenceIsLast(Variable operand);        public static Function SequenceIsLast(Variable operand);
           public static Function SequenceIsLast(Variable operand, string name);        public static Function SequenceIsLast(Variable operand, string name);
           public static Function SequenceLast(Variable operand);        public static Function SequenceLast(Variable operand);
           public static Function SequenceLast(Variable operand, string name);        public static Function SequenceLast(Variable operand, string name);
           public static Function SequenceReduceMax(Variable operand);        public static Function SequenceReduceMax(Variable operand);
           public static Function SequenceReduceMax(Variable operand, string name);        public static Function SequenceReduceMax(Variable operand, string name);
           public static Function SequenceReduceSum(Variable operand);        public static Function SequenceReduceSum(Variable operand);
           public static Function SequenceReduceSum(Variable operand, string name);        public static Function SequenceReduceSum(Variable operand, string name);
           public static Function SequenceScatter(Variable operand, Variable condition);        public static Function SequenceScatter(Variable operand, Variable condition);
           public static Function SequenceScatter(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor);        public static Function SequenceScatter(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor);
           public static Function SequenceScatter(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor, string name);        public static Function SequenceScatter(Variable operand, Variable condition, PairSizeTInt newDerivedSequenceAxisScalingAndAdditiveFactor, string name);
           public static Function SequenceScatter(Variable operand, Variable condition, string name);        public static Function SequenceScatter(Variable operand, Variable condition, string name);
           public static Function SequenceSlice(Variable operand, int beginIndex, int endIndex);        public static Function SequenceSlice(Variable operand, int beginIndex, int endIndex);
           public static Function SequenceSlice(Variable operand, int beginIndex, int endIndex, string name);        public static Function SequenceSlice(Variable operand, int beginIndex, int endIndex, string name);
           public static Function SequenceSoftmax(Variable operand);        public static Function SequenceSoftmax(Variable operand);
           public static Function SequenceSoftmax(Variable operand, string name);        public static Function SequenceSoftmax(Variable operand, string name);
           public static Function SequenceUnpack(Variable operand, double paddingValue, bool supressMaskOutput);        public static Function SequenceUnpack(Variable operand, double paddingValue, bool supressMaskOutput);
           public static Function SequenceUnpack(Variable operand, double paddingValue, bool supressMaskOutput, string name);        public static Function SequenceUnpack(Variable operand, double paddingValue, bool supressMaskOutput, string name);
           public static Function SequenceWhere(Variable condition);        public static Function SequenceWhere(Variable condition);
           public static Function SequenceWhere(Variable condition, string name);        public static Function SequenceWhere(Variable condition, string name);
           public static Function Sigmoid(Variable operand);        public static Function Sigmoid(Variable operand);
           public static Function Sigmoid(Variable operand, string name);        public static Function Sigmoid(Variable operand, string name);
           public static Function Sin(Variable operand);        public static Function Sin(Variable operand);
           public static Function Sin(Variable operand, string name);        public static Function Sin(Variable operand, string name);
           public static Function Sinh(Variable operand);        public static Function Sinh(Variable operand);
           public static Function Sinh(Variable operand, string name);        public static Function Sinh(Variable operand, string name);
           public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex);        public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex);
           public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, IntVector strides);        public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, IntVector strides);
           public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, IntVector strides, string name);        public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, IntVector strides, string name);
           public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, string name);        public static Function Slice(Variable operand, AxisVector axis, IntVector beginIndex, IntVector endIndex, string name);
           public static Function Softmax(Variable operand);        public static Function Softmax(Variable operand);
           public static Function Softmax(Variable operand, Axis axis);        public static Function Softmax(Variable operand, Axis axis);
           public static Function Softmax(Variable operand, Axis axis, string name);        public static Function Softmax(Variable operand, Axis axis, string name);
           public static Function Softmax(Variable operand, string name);        public static Function Softmax(Variable operand, string name);
           public static Function Softplus(Variable operand);        public static Function Softplus(Variable operand);
           public static Function Softplus(Variable operand, string name);        public static Function Softplus(Variable operand, string name);
           public static Function Softsign(Variable operand);        public static Function Softsign(Variable operand);
           public static Function Softsign(Variable operand, string name);        public static Function Softsign(Variable operand, string name);
           public static Function SpaceToDepth(Variable operand, uint blockSize);        public static Function SpaceToDepth(Variable operand, uint blockSize);
           public static Function SpaceToDepth(Variable operand, uint blockSize, string name);        public static Function SpaceToDepth(Variable operand, uint blockSize, string name);
           public static Function SpatialConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples);        public static Function SpatialConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples);
           public static Function SpatialConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples, string name);        public static Function SpatialConvolution(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples, string name);
    .        public static Function SpatialConvolutionSequenceShape(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples);  
           public static Function SpatialConvolutionSequenceShape(Variable convolutionMap, Variable operand, NDShape strides, BoolVector sharing, BoolVector autoPadding, NDShape dilation, uint maxTempMemSizeInSamples, string name);  
           public static Function Splice(VariableVector operands, Axis axis);        public static Function Splice(VariableVector operands, Axis axis);
           public static Function Splice(VariableVector operands, Axis axis, string name);        public static Function Splice(VariableVector operands, Axis axis, string name);
           public static Function Sqrt(Variable operand);        public static Function Sqrt(Variable operand);
           public static Function Sqrt(Variable operand, string name);        public static Function Sqrt(Variable operand, string name);
           public static Function Square(Variable operand);        public static Function Square(Variable operand);
           public static Function Square(Variable operand, string name);        public static Function Square(Variable operand, string name);
           public static Function SquaredError(Variable prediction, Variable targets);        public static Function SquaredError(Variable prediction, Variable targets);
           public static Function SquaredError(Variable prediction, Variable targets, string name);        public static Function SquaredError(Variable prediction, Variable targets, string name);
           public static Function Squeeze(Variable operand);        public static Function Squeeze(Variable operand);
           public static Function Squeeze(Variable operand, AxisVector axis);        public static Function Squeeze(Variable operand, AxisVector axis);
           public static Function Squeeze(Variable operand, AxisVector axis, string name);        public static Function Squeeze(Variable operand, AxisVector axis, string name);
           public static Function Squeeze(Variable operand, string name);        public static Function Squeeze(Variable operand, string name);
           public static Function StopGradient(Variable operand);        public static Function StopGradient(Variable operand);
           public static Function StopGradient(Variable operand, string name);        public static Function StopGradient(Variable operand, string name);
    .        public static Function StraightThrough(Variable operand);  
           public static Function StraightThrough(Variable operand, string name);  
           public static Function Sum(VariableVector operands);        public static Function Sum(VariableVector operands);
           public static Function Sum(VariableVector operands, string name);        public static Function Sum(VariableVector operands, string name);
    .        public static Function Tan(Variable operand);  
           public static Function Tan(Variable operand, string name);  
           public static Function Tanh(Variable operand);        public static Function Tanh(Variable operand);
           public static Function Tanh(Variable operand, string name);        public static Function Tanh(Variable operand, string name);
           public static Function Times(Variable leftOperand, Variable rightOperand);        public static Function Times(Variable leftOperand, Variable rightOperand);
           public static Function Times(Variable leftOperand, Variable rightOperand, string name);        public static Function Times(Variable leftOperand, Variable rightOperand, string name);
           public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank);        public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank);
           public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, int inferInputRankToMap);        public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, int inferInputRankToMap);
           public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, int inferInputRankToMap, string name);        public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, int inferInputRankToMap, string name);
           public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, string name);        public static Function Times(Variable leftOperand, Variable rightOperand, uint outputRank, string name);
           public static Function ToBatch(Variable operand);        public static Function ToBatch(Variable operand);
           public static Function ToBatch(Variable operand, string name);        public static Function ToBatch(Variable operand, string name);
           public static Function TopK(Variable operand, uint k);        public static Function TopK(Variable operand, uint k);
           public static Function TopK(Variable operand, uint k, Axis axis);        public static Function TopK(Variable operand, uint k, Axis axis);
           public static Function TopK(Variable operand, uint k, Axis axis, string name);        public static Function TopK(Variable operand, uint k, Axis axis, string name);
           public static Function TopK(Variable operand, uint k, string name);        public static Function TopK(Variable operand, uint k, string name);
           public static Function ToSequence(Variable operand, string sequenceAxisNamePrefix);        public static Function ToSequence(Variable operand, string sequenceAxisNamePrefix);
           public static Function ToSequence(Variable operand, string sequenceAxisNamePrefix, string name);        public static Function ToSequence(Variable operand, string sequenceAxisNamePrefix, string name);
           public static Function ToSequence(Variable operand, Variable sequenceLengths, string sequenceAxisNamePrefix);        public static Function ToSequence(Variable operand, Variable sequenceLengths, string sequenceAxisNamePrefix);
           public static Function ToSequence(Variable operand, Variable sequenceLengths, string sequenceAxisNamePrefix, string name);        public static Function ToSequence(Variable operand, Variable sequenceLengths, string sequenceAxisNamePrefix, string name);
           public static Function ToSequenceLike(Variable operand, Variable dynamicAxesLike);        public static Function ToSequenceLike(Variable operand, Variable dynamicAxesLike);
           public static Function ToSequenceLike(Variable operand, Variable dynamicAxesLike, string name);        public static Function ToSequenceLike(Variable operand, Variable dynamicAxesLike, string name);
           public static Function Transpose(Variable operand);        public static Function Transpose(Variable operand);
           public static Function Transpose(Variable operand, AxisVector permutation);        public static Function Transpose(Variable operand, AxisVector permutation);
           public static Function Transpose(Variable operand, AxisVector permutation, string name);        public static Function Transpose(Variable operand, AxisVector permutation, string name);
           public static Function Transpose(Variable operand, string name);        public static Function Transpose(Variable operand, string name);
           public static Function TransposeAxes(Variable operand, Axis axis1, Axis axis2);        public static Function TransposeAxes(Variable operand, Axis axis1, Axis axis2);
           public static Function TransposeAxes(Variable operand, Axis axis1, Axis axis2, string name);        public static Function TransposeAxes(Variable operand, Axis axis1, Axis axis2, string name);
           public static Function TransposeTimes(Variable leftOperand, Variable rightOperand);        public static Function TransposeTimes(Variable leftOperand, Variable rightOperand);
           public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, string name);        public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, string name);
           public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, uint outputRank);        public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, uint outputRank);
           public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, uint outputRank, string name);        public static Function TransposeTimes(Variable leftOperand, Variable rightOperand, uint outputRank, string name);
           public static Function UniformRandom(NDShape shape, DataType dataType);        public static Function UniformRandom(NDShape shape, DataType dataType);
           public static Function UniformRandom(NDShape shape, DataType dataType, double low);        public static Function UniformRandom(NDShape shape, DataType dataType, double low);
           public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high);        public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high);
           public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high, uint seed);        public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high, uint seed);
           public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high, uint seed, string name);        public static Function UniformRandom(NDShape shape, DataType dataType, double low, double high, uint seed, string name);
           public static Function UniformRandomLike(Variable operand);        public static Function UniformRandomLike(Variable operand);
           public static Function UniformRandomLike(Variable operand, double low);        public static Function UniformRandomLike(Variable operand, double low);
           public static Function UniformRandomLike(Variable operand, double low, double high);        public static Function UniformRandomLike(Variable operand, double low, double high);
           public static Function UniformRandomLike(Variable operand, double low, double high, uint seed);        public static Function UniformRandomLike(Variable operand, double low, double high, uint seed);
           public static Function UniformRandomLike(Variable operand, double low, double high, uint seed, string name);        public static Function UniformRandomLike(Variable operand, double low, double high, uint seed, string name);
           public static Function UnpackBatch(Variable operand, string name);        public static Function UnpackBatch(Variable operand, string name);
           public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape);        public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape);
           public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides);        public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides);
           public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides, BoolVector autoPadding);        public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides, BoolVector autoPadding);
           public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides, BoolVector autoPadding, string name);        public static Function Unpooling(Variable operand, Variable poolingInput, PoolingType UnpoolingType, NDShape UnpoolingWindowShape, NDShape strides, BoolVector autoPadding, string name);
    .        public static Function Unsqueeze(Variable operand, AxisVector axes);  
           public static Function Unsqueeze(Variable operand, AxisVector axes, string name);  
           public static Function WeightedBinaryCrossEntropy(Variable prediction, Variable targets, Variable weights);        public static Function WeightedBinaryCrossEntropy(Variable prediction, Variable targets, Variable weights);
           public static Function WeightedBinaryCrossEntropy(Variable prediction, Variable targets, Variable weights, string name);        public static Function WeightedBinaryCrossEntropy(Variable prediction, Variable targets, Variable weights, string name);
           public static Function ZerosLike(Variable operand);        public static Function ZerosLike(Variable operand);
           public static Function ZerosLike(Variable operand, string name);        public static Function ZerosLike(Variable operand, string name);
           public static int DefaultParamInitScale { get; }        public static int DefaultParamInitScale { get; }
           public static int SentinelValueForInferParamInitRank { get; }        public static int SentinelValueForInferParamInitRank { get; }
           public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);        public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);
           public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho);        public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho);
           public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho, double epsilon);        public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho, double epsilon);
           public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho, double epsilon, AdditionalLearningOptions additionalOptions);        public static Learner AdaDeltaLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double rho, double epsilon, AdditionalLearningOptions additionalOptions);
           public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);        public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);
           public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, bool needAveMultiplier);        public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, bool needAveMultiplier);
           public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, bool needAveMultiplier, AdditionalLearningOptions additionalOptions);        public static Learner AdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, bool needAveMultiplier, AdditionalLearningOptions additionalOptions);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon, bool adamax);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon, bool adamax);
           public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon, bool adamax, AdditionalLearningOptions additionalOptions);        public static Learner AdamLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, double epsilon, bool adamax, AdditionalLearningOptions additionalOptions);
           public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);        public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);
           public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);        public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);
           public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule);        public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule);
           public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, AdditionalLearningOptions additionalOptions);        public static Learner FSAdaGradLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, TrainingParameterScheduleDouble varianceMomentumSchedule, AdditionalLearningOptions additionalOptions);
           public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);        public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule);
           public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);        public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain);
           public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, AdditionalLearningOptions additionalOptions);        public static Learner MomentumSGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, AdditionalLearningOptions additionalOptions);
           public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min);        public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min);
           public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min, bool needAveMultiplier);        public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min, bool needAveMultiplier);
           public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min, bool needAveMultiplier, AdditionalLearningOptions additionalOptions);        public static Learner RMSPropLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, double gamma, double inc, double dec, double max, double min, bool needAveMultiplier, AdditionalLearningOptions additionalOptions);
           public static Learner SGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);        public static Learner SGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule);
           public static Learner SGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, AdditionalLearningOptions additionalOptions);        public static Learner SGDLearner(ParameterVector parameters, TrainingParameterScheduleDouble learningRateSchedule, AdditionalLearningOptions additionalOptions);
           public static MinibatchSource CreateCompositeMinibatchSource(MinibatchSourceConfig configuration);        public static MinibatchSource CreateCompositeMinibatchSource(MinibatchSourceConfig configuration);
           public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs);        public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs);
           public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize);        public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize);
           public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize);        public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize);
           public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize, uint randomizationWindow);        public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize, uint randomizationWindow);
           public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize, uint randomizationWindow, bool sampleBasedRandomizationWindow);        public static MinibatchSource TextFormatMinibatchSource(string dataFilePath, StreamConfigurationVector streamConfigs, uint epochSize, bool randomize, uint randomizationWindow, bool sampleBasedRandomizationWindow);
           public static string DataTypeName(DataType dataType);        public static string DataTypeName(DataType dataType);
           public static string DeviceKindName(DeviceKind deviceKind);        public static string DeviceKindName(DeviceKind deviceKind);
           public static string VariableKindName(VariableKind variableKind);        public static string VariableKindName(VariableKind variableKind);
           public static TraceLevel GetTraceLevel();        public static TraceLevel GetTraceLevel();
           public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, LearnerVector parameterLearners);        public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, LearnerVector parameterLearners);
           public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, LearnerVector parameterLearners, ProgressWriterVector progressWriters);        public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, LearnerVector parameterLearners, ProgressWriterVector progressWriters);
           public static Trainer CreateTrainer(Function model, Function lossFunction, LearnerVector parameterLearners);        public static Trainer CreateTrainer(Function model, Function lossFunction, LearnerVector parameterLearners);
           public static Trainer CreateTrainer(Function model, Function lossFunction, LearnerVector parameterLearners, ProgressWriterVector progressWriters);        public static Trainer CreateTrainer(Function model, Function lossFunction, LearnerVector parameterLearners, ProgressWriterVector progressWriters);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(double time_constant);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(double time_constant);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(DoubleVector schedule);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(DoubleVector schedule);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(DoubleVector schedule, uint epoch_size);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(DoubleVector schedule, uint epoch_size);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(TrainingParameterScheduleDouble schedule);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(TrainingParameterScheduleDouble schedule);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(VectorPairSizeTDouble schedule);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(VectorPairSizeTDouble schedule);
           public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(VectorPairSizeTDouble schedule, uint epoch_size);        public static TrainingParameterScheduleDouble MomentumAsTimeConstantSchedule(VectorPairSizeTDouble schedule, uint epoch_size);
           public static uint DataTypeSize(DataType dataType);        public static uint DataTypeSize(DataType dataType);
           public static uint GenerateRandomSeed();        public static uint GenerateRandomSeed();
           public static uint GenerateRandomSeed(bool perWorkerLocalValue);        public static uint GenerateRandomSeed(bool perWorkerLocalValue);
           public static uint GetMaxNumCPUThreads();        public static uint GetMaxNumCPUThreads();
           public static uint GetRandomSeed();        public static uint GetRandomSeed();
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType);
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, AxisVector dynamicAxes);
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, bool needsGradient, string name);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, bool needsGradient, string name);
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, bool needsGradient, string name, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, bool needsGradient, string name, AxisVector dynamicAxes);
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, string name);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, string name);
           public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, string name, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, bool isSparse, DataType dataType, string name, AxisVector dynamicAxes);
           public static Variable InputVariable(NDShape shape, DataType dataType);        public static Variable InputVariable(NDShape shape, DataType dataType);
           public static Variable InputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes);
           public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient);        public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient);
           public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient, string name);        public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient, string name);
           public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient, string name, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, DataType dataType, bool needsGradient, string name, AxisVector dynamicAxes);
           public static Variable InputVariable(NDShape shape, DataType dataType, string name);        public static Variable InputVariable(NDShape shape, DataType dataType, string name);
           public static Variable InputVariable(NDShape shape, DataType dataType, string name, AxisVector dynamicAxes);        public static Variable InputVariable(NDShape shape, DataType dataType, string name, AxisVector dynamicAxes);
           public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes);        public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes);
           public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, bool needsGradient);        public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, bool needsGradient);
           public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, bool needsGradient, string name);        public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, bool needsGradient, string name);
           public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, string name);        public static Variable OutputVariable(NDShape shape, DataType dataType, AxisVector dynamicAxes, string name);
           public static Variable PlaceholderVariable();        public static Variable PlaceholderVariable();
           public static Variable PlaceholderVariable(NDShape shape);        public static Variable PlaceholderVariable(NDShape shape);
           public static Variable PlaceholderVariable(NDShape shape, AxisVector dynamicAxes);        public static Variable PlaceholderVariable(NDShape shape, AxisVector dynamicAxes);
           public static Variable PlaceholderVariable(NDShape shape, DataType dataType, string name);        public static Variable PlaceholderVariable(NDShape shape, DataType dataType, string name);
           public static Variable PlaceholderVariable(NDShape shape, DataType dataType, string name, AxisVector dynamicAxes);        public static Variable PlaceholderVariable(NDShape shape, DataType dataType, string name, AxisVector dynamicAxes);
           public static Variable PlaceholderVariable(NDShape shape, string name, AxisVector dynamicAxes);        public static Variable PlaceholderVariable(NDShape shape, string name, AxisVector dynamicAxes);
           public static Variable PlaceholderVariable(string name);        public static Variable PlaceholderVariable(string name);
           public static void ComputeInputPerDimMeansAndInvStdDevs(MinibatchSource minibatchSource, UnorderedMapStreamInformationPairNDArrayViewPtrNDArrayViewPtr computedMeanAndVariances);        public static void ComputeInputPerDimMeansAndInvStdDevs(MinibatchSource minibatchSource, UnorderedMapStreamInformationPairNDArrayViewPtrNDArrayViewPtr computedMeanAndVariances);
           public static void ComputeInputPerDimMeansAndInvStdDevs(MinibatchSource minibatchSource, UnorderedMapStreamInformationPairNDArrayViewPtrNDArrayViewPtr computedMeanAndVariances, DeviceDescriptor device);        public static void ComputeInputPerDimMeansAndInvStdDevs(MinibatchSource minibatchSource, UnorderedMapStreamInformationPairNDArrayViewPtrNDArrayViewPtr computedMeanAndVariances, DeviceDescriptor device);
           public static void DisableCPUEvalOptimization();        public static void DisableCPUEvalOptimization();
           public static void DisableNodeTimeing();        public static void DisableNodeTimeing();
           public static void EnableCPUEvalOptimization();        public static void EnableCPUEvalOptimization();
    .        public static void ForceDeterministicAlgorithms();  
           public static void ResetRandomSeed();        public static void ResetRandomSeed();
           public static void ResetRandomSeed(uint value);        public static void ResetRandomSeed(uint value);
    .        public static void SetFixedRandomSeed(uint value);  
           public static void SetMathLibTraceLevel(int traceLevel);        public static void SetMathLibTraceLevel(int traceLevel);
           public static void SetMaxNumCPUThreads(uint numCPUThreads);        public static void SetMaxNumCPUThreads(uint numCPUThreads);
           public static void SetTraceLevel(TraceLevel value);        public static void SetTraceLevel(TraceLevel value);
           public static void UseSparseGradientAggregationInDataParallelSGD(bool enable);        public static void UseSparseGradientAggregationInDataParallelSGD(bool enable);
       
       
       

     

    Cognitive Toolkitのダウンロード、環境設定【C#編】

    マイクロソフトのCognitive ToolkitをVisual StudioのC#で使用するためのインストール方法、環境構築を紹介します。

     

    結論からすればCognitive Toolkitを動作させるためには、関連するDLLファイルがあればよいだけなのですが、この関連するファイルをNuGetより入手する方法でやりたいと思います。

     

    まず、Visual Studioで何でもいいので、C#のプロジェクトを作成します。

    ソリューションエクスプローラーよりプロジェクト名を右クリックし、NuGetパッケージの管理をクリックします。

     

    表示されたウィンドウの参照を選択し、検索ボックスにCNTKと入力すると各種ライブラリが表示されるので、ここではCNTK.GPUを選択します。

     

     

    画面右側に表示されているインストールをクリックします。

     

     

    あとは画面の流れに沿ってインストールを行います。

     

    OKボタンをクリック

     

    同意するをクリック

     

    すると、プロジェクトの参照に Cntk.Core.Managed-2.5.1 というのが追加されます。

     

    これで、Cognitive Toolkitのインストールは完了です。

     

    しかし、このままでプログラムをビルド、実行しようとすると、以下のようなエラーや警告が表示されます。

     

     

    そもそもCognitive Toolkitは64bit専用のライブラリなので、プロジェクトも64bitに設定する必要があります。

     

    64bitの設定にするには、Visual Studio のソリューションプラットフォームより、構成マネージャーを選択します。

     

    次にアクティブソリューションプラットフォームより、<新規作成>を選択します。

     

    新しいソリューションプラットフォームというウィンドウが表示されるので、下図のような状態(x64が表示されている状態)でOKボタンをクリックします。

     

    構成マネージャーのウィンドウが下図のようになるので、閉じるボタンをクリックします。

     

    この状態で、試しに処理で使用するデバイスを設定するコードをどこかに書いてみてビルドして、エラーが出なければ環境構築は完了です。

     

    var device = CNTK.DeviceDescriptor.CPUDevice;
    

     

    ちなみに、プログラムをビルドすると作成したプログラムの実行ファイルを同じフォルダに下図のように関連するDLLファイルがコピーされて配置されます。

     

     

    Cognitive Toolkitでは、これらのDLLファイルがありさえすれば、動作してくれるので、例えば、プログラムはネットに接続されたPCで作成し、実際の実行用PCはネットに接続されていなくても、exeファイル、exe.configファイル、DLLファイルをコピーすれば動作してくれるので、環境構築が簡単にできるので、Cognitive Toolkitは自分の中ではポイントが高い!

    (実際にはまっさらなPCに移植した事がないので、何か不足する可能性もありますが。。)

     

    C#から使えるDeepLearningライブラリ Microsoft Cognitive Toolkit

    Deep Learningのライブラリといえば、TensorFlowやChainer、Caffeなどが定番とされ、使用する言語はPython!

     

    な訳ですが、私がやりたいのは、工業用のカメラを使って、画像を撮影し、メモリに格納された画像データ(画像ファイルには保存しないで)を用いて、画像の判定を行いたい。

     

    工業用のカメラを制御するSDKはほとんどの場合、C++かC#なので、私がメインで使っている言語のC#でDeep Learningを動かしたい。

     

    【希望の動作環境条件】

    ・Windows7/10 64bit

    ・Visual Studio 2015 C#

    ・スタンドアロンPCで動作する(動作環境構築にネット接続を必要としない)

     

    という事でC#から使えるDeep Learningライブラリを探していたのですが、Microsoftの

    Cognitive Toolkitなるものがこれに該当しそう。

     

    ということで、Microsoft Cognitive Toolkitを動かしてみました。

     

    ライブラリ、サンプルの入手先はこちら↓のCNTK for Windows v.2.5.1 GPUをクリック

    https://github.com/Microsoft/CNTK/releases

     

    ファイル名はGPUになっていますが、CPUでも動くサンプルが同梱されています。

     

    上記リンク先よりファイル(CNTK-2-5-1-Windows-64bit-GPU)をダウンロードし、ファイルを解凍すると、フォルダは以下のような構成になっています。

     

    このうち、C#のサンプルが格納されているのは下図の赤く囲った部分。

     

    試しにTrainingCSharp内のCSTrainingCPUOnlyExamplesのサンプルを動かしてみると、途中まで動作します

     

    が、このようなエラー↓が表示されます。

     

    これはおそらくPythonのサンプルプログラムを動作させて作成したファイルが足りないと言われているっぽい。。

    途中まででも、C#でDeep Learningが動いてくれた事が無かったので、ちょっと嬉しい!!

     

    ですが、サンプルプログラムをよく見ていくと、

    ・コードの書き方に一貫性が無い(少なくとも二人以上で作っている)

    ・C++の定義をラップしただけ?みたいな書き方になっている。(C#っぽくない)

    他にも

    ・ドキュメントがやる気ない

    https://docs.microsoft.com/en-us/cognitive-toolkit/cntk-library-managed-api

     

    など、情報少ないし、なかなか大変なのですが、何となく可能性も感じるこのCognitive Toolkit

    もう少し触ってみようと思います。

    バックプロパゲーション(誤差逆伝搬法)

    Deep Learningを勉強すると、とにかく分からないバックプロパゲーション。

     

    やっていることは、入力の値に重みやバイアスを掛けて構築されるニューラルネットワークの出力値が目標値に近づくように重みやバイアスを調整するいわゆる学習の工程ですが、行列の計算式や∑がつらつら出てくるので、ぜんぜん理解できない。。

     

    しかし、下図のよく出てくるニューラルネットワークの図を見ていると、yの値は入力値xの値と未知数のw、bの値からなっており、出力値と目標値の差の二乗の合計の値が最小になるようにw,bの値を求めてやればいい。

     

     

    この出力値と目標値の差の二乗の合計の値が最小になるにっていう響き、何か聞いたことがあるぞ!  そう最小二乗法!!

     

    最小二乗法では二乗誤差の合計が最小となるように、二乗誤差の合計の式に関して

     未知数の偏微分 = 0

    として、未知数を求めますが、同じようなノリで、二乗誤差の合計の式に関して未知数の偏微分の値が0に近づくように未知数を更新してやる処理がバックプロパゲーションとなります。(この説明だけでは、バック感が無いのですが、バック感が出てくるのは最後のほうの説明で。)

     

    未知数の偏微分の値を0にするのが最小二乗法ですが、未知数の偏微分の値が小さくなるように未知数を更新しながら誤差を小さくする手法が勾配降下法となります。

     

    ここからが本題です。

    通常の最小二乗法と比べ、未知数が多く、特に中間層の重み(w)やバイアス(b)を求める方法が私にはなかなか理解できなかったのですが、基本はやはり二乗誤差の合計が最小となるように二乗誤差の合計を未知数で偏微分し、誤差が最小になるように未知数を更新します。

     

    $$w\leftarrow w-\eta \frac { \partial E }{ \partial w } $$

    $$b\leftarrow b-\eta \frac { \partial E }{ \partial b } $$

    $$\eta は学習率で0.01など$$

     

    ここで、各層の重みやバイアス、活性化関数を表現できるように、定番のニューラルネットワークの図を下図のように書き換えます。

     

     

    上図の記号の意味は

    のように、記号の右上にカッコ付きで層番号、右下に入力ノード番号、出力ノード番号を表します。

     

    aは入力値と重みを掛けて合計した値で、例えば、

     

    $${ a }_{ 1 }^{ (1) }=1 { b }_{ 0,1 }^{ (1) }+{ x }_{ 1 } { w }_{ 1,1 }^{ (1) }+{ x }_{ 2 } { w }_{ 2,1 }^{ (1) }+{ x }_{ 3 } { w }_{ 3,1 }^{ (1) }+{ x }_{ 4 } { w }_{ 4,1 }^{ (1) }$$

    $${ a }_{ 1 }^{ (2) }=1 { b }_{ 0,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right)  { w }_{ 1,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) \ { w }_{ 2,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right)  { w }_{ 3,1 }^{ (2) }$$

     

    その他の記号は

    b:バイアス

    w:重み

    f:各層の活性化関数

     

    とします。

     

    順伝播

    順伝播を少々面倒ですが、すべて書き出してみます。

     

    第1層

    $${ a }_{ 1 }^{ (1) }=1 { b }_{ 0,1 }^{ (1) }+{ x }_{ 1 } { w }_{ 1,1 }^{ (1) }+{ x }_{ 2 } { w }_{ 2,1 }^{ (1) }+{ x }_{ 3 } { w }_{ 3,1 }^{ (1) }+{ x }_{ 4 } { w }_{ 4,1 }^{ (1) }$$

    $${ a }_{ 2 }^{ (1) }=1 { b }_{ 0,2 }^{ (1) }+{ x }_{ 1 } { w }_{ 1,2 }^{ (1) }+{ x }_{ 2 } { w }_{ 2,2 }^{ (1) }+{ x }_{ 3 } { w }_{ 3,2 }^{ (1) }+{ x }_{ 4 } { w }_{ 4,2 }^{ (1) }$$

    $${ a }_{ 3 }^{ (1) }=1 { b }_{ 0,3 }^{ (1) }+{ x }_{ 1 } { w }_{ 1,3 }^{ (1) }+{ x }_{ 2 } { w }_{ 2,3 }^{ (1) }+{ x }_{ 3 } { w }_{ 3,3 }^{ (1) }+{ x }_{ 4 } { w }_{ 4,3 }^{ (1) }$$

    活性化関数後は

    $${ f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right)$$

    $${ f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right)$$

    $${ f }^{ (1) }\left( { a }_{ 3 }^{ (1) } \right)$$

     

    第2層

    $${ a }_{ 1 }^{ (2) }=1{ b }_{ 0,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right) { w }_{ 1,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) { w }_{ 2,1 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 3 }^{ (1) } \right) { w }_{ 3,1 }^{ (2) }$$

    $${ a }_{ 2 }^{ (2) }=1{ b }_{ 0,2 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right) { w }_{ 1,2 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) { w }_{ 2,2 }^{ (2) }+{ f }^{ (1) }\left( { a }_{ 3 }^{ (1) } \right) { w }_{ 3,2 }^{ (2) }$$

    活性化関数後は

    $${ f }^{ (2) }\left( { a }_{ 1 }^{ (2) } \right)$$

    $${ f }^{ (2) }\left( { a }_{ 2 }^{ (2) } \right)$$

     

    第3層

    $${ a }_{ 1 }^{ (3) }=1{ b }_{ 0,1 }^{ (3) }+{ f }^{ (2) }\left( { a }_{ 1 }^{ (2) } \right) { w }_{ 1,1 }^{ (3) }+{ f }^{ (2) }\left( { a }_{ 2 }^{ (2) } \right) { w }_{ 2,1 }^{ (3) }$$

    $${ a }_{ 2 }^{ (3) }=1{ b }_{ 0,2 }^{ (3) }+{ f }^{ (2) }\left( { a }_{ 1 }^{ (2) } \right) { w }_{ 1,2 }^{ (3) }+{ f }^{ (2) }\left( { a }_{ 2 }^{ (2) } \right) { w }_{ 2,2 }^{ (3) }$$

    活性化関数後は

    $${ f }^{ (3) }\left( { a }_{ 1 }^{ (3) } \right)$$

    $${ f }^{ (3) }\left( { a }_{ 2 }^{ (3) } \right)$$

     

    逆伝播

    逆伝播に関しては誤差の関数

    $$E=\frac { 1 }{ 2 } \sum _{ i }^{ }{ { ({ y }_{ i }-{ t }_{ i }) }^{ 2 } } $$

    について、未知数であるwやbで偏微分を行い、次の式のように値を更新すればよいので、未知数の偏微分が求まれば、値も勾配降下法で求めることができます。

     

    $$w\leftarrow w-\eta \frac { \partial E }{ \partial w } $$

    $$b\leftarrow b-\eta \frac { \partial E }{ \partial b } $$

     

    第3層

    とりあえずEを未知数の \({ w }_{ 1,1 }^{ (3) }\) で偏微分してみたいと思います。

    Eを\({ w }_{ 1,1 }^{ (3) }\)で偏微分するという事は、Eの式中の\({ w }_{ 1,1 }^{ (3) }\)が含まれる項に関してだけ微分すればよいので、下図の赤い部分に関してだけ偏微分していきます。

     

     

     

    同様にバイアスの \({ b }_{ 0,1 }^{ (3) }\) で偏微分してみます。

     

    他の未知数もまとめると

    となります。

     

    第2層

    2層目の未知数 \({ w }_{ 1,1 }^{ (2) }\) に関して偏微分するには \({ w }_{ 1,1 }^{ (2) }\) に関連する項は下図の赤い部分となり、少し広範囲になります。

     

     

    バイアスも同様に偏微分すると

     

    となり、まとめると

     

    となります。

     

    第1層は??

    もう大変なので、ここではやめておきます。

     

    今回は計算を理解するためにベタに偏微分を解いてみたのですが、ゴチャゴチャしてよくわからないので、行列を使った表記で少し整理します。

     

    順伝播の行列表記

    順伝播を下図の雰囲気に合わせて行列で表現したいと思います。

     

     

    第1層

    $${ \begin{pmatrix} 1 \\ { x }_{ 1 } \\ { x }_{ 2 } \\ { x }_{ 3 } \\ { x }_{ 4 } \end{pmatrix} }^{ T }\begin{pmatrix} { b }_{ 0,1 }^{ (1) } & { b }_{ 0,2 }^{ (1) } & { b }_{ 0,3 }^{ (1) } \\ { w }_{ 1,1 }^{ (1) } & { w }_{ 1,2 }^{ (1) } & { w }_{ 1,3 }^{ (1) } \\ { w }_{ 2,1 }^{ (1) } & { w }_{ 2,2 }^{ (1) } & { w }_{ 2,3 }^{ (1) } \\ { w }_{ 3,1 }^{ (1) } & { w }_{ 3,2 }^{ (1) } & { w }_{ 3,3 }^{ (1) } \\ { w }_{ 4,1 }^{ (1) } & { w }_{ 4,2 }^{ (1) } & { w }_{ 4,3 }^{ (1) } \end{pmatrix}=\begin{pmatrix} { a }_{ 1 }^{ (1) } \\ { a }_{ 2 }^{ (1) } \\ { a }_{ 3 }^{ (1) } \end{pmatrix}^{ T }\quad \rightarrow \quad \begin{pmatrix} { f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right) \\ { f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) \\ { f }^{ (1) }\left( { a }_{ 3 }^{ (1) } \right) \end{pmatrix}^{ T }$$

     

    第2層

    $${ \begin{pmatrix} 1 \\ { f }^{ (1) }\left( { a }_{ 1 }^{ (1) } \right) \\ { f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) \\ { f }^{ (1) }\left( { a }_{ 2 }^{ (1) } \right) \end{pmatrix} }^{ T }\begin{pmatrix} { b }_{ 0,1 }^{ (2) } & { b }_{ 0,2 }^{ (2) } \\ { w }_{ 1,1 }^{ (2) } & { w }_{ 1,2 }^{ (2) } \\ { w }_{ 2,1 }^{ (2) } & { w }_{ 2,2 }^{ (2) } \\ { w }_{ 3,1 }^{ (2) } & { w }_{ 3,2 }^{ (2) } \end{pmatrix}=\begin{pmatrix} { a }_{ 1 }^{ (2) } \\ { a }_{ 2 }^{ (2) } \end{pmatrix}^{ T }\quad \rightarrow \quad \begin{pmatrix} { f }^{ (2) }\left( { a }_{ 1 }^{ (2) } \right) \\ { f }^{ (2) }\left( { a }_{ 2 }^{ (2) } \right) \end{pmatrix}^{ T }$$

     

    第3層

    $${ \begin{pmatrix} 1 \\ { f }^{ (2) }\left( { a }_{ 1 }^{ (2) } \right) \\ { f }^{ (2) }\left( { a }_{ 2 }^{ (2) } \right) \end{pmatrix} }^{ T }\begin{pmatrix} { b }_{ 0,1 }^{ (3) } & { b }_{ 0,2 }^{ (3) } \\ { w }_{ 1,1 }^{ (3) } & { w }_{ 1,2 }^{ (3) } \\ { w }_{ 2,1 }^{ (3) } & { w }_{ 2,2 }^{ (3) } \end{pmatrix}=\begin{pmatrix} { a }_{ 1 }^{ (3) } \\ { a }_{ 2 }^{ (3) } \end{pmatrix}^{ T }\quad \rightarrow \quad \begin{pmatrix} { f }^{ (3) }\left( { a }_{ 1 }^{ (3) } \right) \\ { f }^{ (3) }\left( { a }_{ 2 }^{ (3) } \right) \end{pmatrix}^{ T }$$

     

    ()T は転置行列で、行と列を入れ替えます。

    転置行列を使っていますが、図の感じと合わせるだけなので、覚えやすいでしょうか??

     

    逆伝播の行列表記

     

    行列で逆伝播を書くと最初の誤差\(\begin{pmatrix} { y }_{ 1 }-{ t }_{ 1 } \\ { y }_{ 2 }-{ t }_{ 2 } \end{pmatrix}\)が層が一つ戻るたびに重みと活性化関数の微分の値が付加され逆へと伝播されていく、最初の言ったバック感が感じられると思います。

     

    逆伝播(学習)の実行

    逆伝播は最後の層(今回の例では第3層)側から計算を行います。

    以下で3層の例で説明します。

     

    まず、第3層目の未知数に関する変数(重みとバイアス)の偏微分の値をそれぞれ求めます。

    偏微分の値を求めたら、偏微分の値に学習率を掛けて、元の変数から引き、変数を更新します。

     

    $$w\leftarrow w-\eta \frac { \partial E }{ \partial w } $$

    $$b\leftarrow b-\eta \frac { \partial E }{ \partial b } $$

     

    さらに第2層、第1層へと偏微分の値を計算し、重みとバイアスを更新します。

    次に更新された重みとバイアスを用いて順伝播を行い出力値(y)を求めます。
    この時点で通常は、前回の出力値よりも誤差が少ない状態(出力値が目標値に近い)となります。

    再度、逆伝播を行い重みとバイアスを更新します。

    この逆伝播→重みとバイアスの更新→順伝播→逆伝播→重みとバイアスの更新→・・・と繰り返し行い出力値と目標値の誤差が小さくなるように繰り返し処理を行います。

    学習率の値については使用するニューラルネットワークなどにも依存ため、どの値が良いか?とは言い切れませんが、私の少ない経験的には0.01ぐらいから初めて、誤差を見ながら調整するようにします。

     

    学習率の値が大きいと、逆伝播を繰り返す行うと、誤差の値が大きくなってしまいます。

    逆に学習率が小さすぎると、逆伝播を繰り返しても誤差はなかなか小さくなないため、程よく学習率を調整する必要があります。

    かといって、学習率を調整して、少ない回数で誤差が小さくなるようにしすぎると、入力データによっては誤差が大きくなってしまう場合もあるので、程よく学習率を調整する必要があります。

     

    だいたいのイメージですが、下図のようになだらかに誤差が小さくなるぐらいの学習率が良いかと思います。

     

    補足説明

    行列の演算で使用した記号の補足です。

    アダマール積

    行列の要素同士を掛け合わせます。

    $$\begin{pmatrix} a & b \\ c & d \end{pmatrix}\circ \begin{pmatrix} e & f \\ g & h \end{pmatrix}=\begin{pmatrix} ae & bf \\ cg & dh \end{pmatrix}$$

     

    転置行列

    行列の行と列を入れ替えます。

    $${ \begin{pmatrix} a & b \\ c & d \\ e & f \end{pmatrix} }^{ T }=\begin{pmatrix} a & c & e \\ b & d & f \end{pmatrix}$$

     

    シグモイド関数

    $$f\left( x \right) =\frac { 1 }{ 1+{ e }^{ -x } } $$

     

     

    シグモイド関数の微分

    $$f’\left( x \right) =(1-f\left( x \right) )f\left( x \right) $$

     

    【C#】正規分布に従う乱数の取得

    .NETでは乱数のクラスにRamdomクラスがあります、どれも一様に分布する乱数しか取得できません。

     

    例えば、NextDoubleメソッドを用いると、0以上、1.0未満の一様に分布した乱数を取得する事ができます。

    var rnd = new Random(); 
    
    for (int i = 0; i < 1000; i++) 
    { 
    	Console.WriteLine(rnd.NextDouble().ToString()); 
    }

    上記プログラムで出力した値をExcelでヒストグラムにしてみると、0~1.0の一様??な乱数が取得させていることが分かります。

     

     

    正規分布に従う乱数を取得するには、今回はボックス=ミュラー法という手法で乱数をしてみます。

    XとYがお互いに独立で、0~1の範囲で一様に分布する乱数のとき

     

    $${ Z }_{ 1 }=\sqrt { -2\log { X } } cos(2\pi Y)\\ { Z }_{ 2 }=\sqrt { -2\log { X } } sin(2\pi Y)$$

     

    のZ1、Z2はそれぞれ標準偏差1.0、平均値0.0の正規分布に従う乱数となります。

    (参考)ボックス=ミュラー法 Wikipedia

    https://ja.m.wikipedia.org/wiki/%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%EF%BC%9D%E3%83%9F%E3%83%A5%E3%83%A9%E3%83%BC%E6%B3%95

     

    これをC#のプログラムにしてみると

    var rnd = new Random(); 
    
    double X, Y; 
    double Z1, Z2; 
    
    for (int i = 0; i < 1000; i++) 
    { 
    	X = rnd.NextDouble(); 
    	Y = rnd.NextDouble(); 
    	
    	Z1 = Math.Sqrt(-2.0 * Math.Log(X)) * Math.Cos(2.0 * Math.PI * Y); 
    	Z2 = Math.Sqrt(-2.0 * Math.Log(X)) * Math.Sin(2.0 * Math.PI * Y); 
    
    	Console.WriteLine(Z1.ToString()); 
    	Console.WriteLine(Z2.ToString()); 
    }

    という感じ。

    コンソールに吐き出された値をExcelでヒストグラムにしてみると

     

    となり、確かに正規分布に従った感じの分布となりました。
    標準偏差1.0、平均値0.0ではなく、標準偏差sigma、平均値ave のときの乱数が欲しい場合は

    Z1 = sigma * Math.Sqrt(-2.0 * Math.Log(X)) * Math.Cos(2.0 * Math.PI * Y) + ave;
    Z2 = sigma * Math.Sqrt(-2.0 * Math.Log(X)) * Math.Sin(2.0 * Math.PI * Y) + ave;

    となります。

     

    ← C#へ戻る

    【Neural Network Console】学習データの出力方法

    Neural Network Consoleは、触っているとすぐに結果がわかる(小さいニューラルネットワークだと。。)ので、楽しいのですが、それもだんだん飽きてきたので、処理の中身を勉強しなきゃ!と思いつつも、Neural Network Consoleで学習させたデータをNeural Network Libraryを使ってプログラムに処理を組み込む方を先に検討しようかと思っています...

    まず、作成したニューラルネットワーク構造を保存するには、どこでもいいので、レイヤーの部分を右クリックします。

     

    すると、Exportの部分があるので、Exportを選択すると、

    ・prototxt(Caffe用のファイル?)

    ・Python Code

    が表示されているので、どちらかを選択します。

     

    prototxtを選択すると、名前を付けて保存ダイアログが表示されるので、ファイルに保存すると、こんな感じ↓の内容のファイルが作成されます。

    layer {
      name: "Input"
      type: "Data"
      top: "Input"
    }
    layer {
      name: "Convolution"
      type: "Convolution"
      convolution_param {
        num_output: 16
        kernel_size: 5
        dilation: 1
      }
      bottom: "Input"
      top: "Convolution"
    }
    layer {
      name: "MaxPooling"
      type: "Pooling"
      pooling_param {
        pool: MAX
        kernel_size: 2
        stride: 2
      }
      bottom: "Convolution"
      top: "MaxPooling"
    }
    layer {
      name: "Tanh"
      type: "TanH"
      bottom: "MaxPooling"
      top: "Tanh"
    }
    layer {
      name: "Convolution_2"
      type: "Convolution"
      convolution_param {
        num_output: 8
        kernel_size: 5
        dilation: 1
      }
      bottom: "Tanh"
      top: "Convolution_2"
    }
    layer {
      name: "MaxPooling_2"
      type: "Pooling"
      pooling_param {
        pool: MAX
        kernel_size: 2
        stride: 2
      }
      bottom: "Convolution_2"
      top: "MaxPooling_2"
    }
    layer {
      name: "Tanh_2"
      type: "TanH"
      bottom: "MaxPooling_2"
      top: "Tanh_2"
    }
    layer {
      name: "Affine"
      type: "InnerProduct"
      inner_product_param {
        num_output: 10
      }
      bottom: "Tanh_2"
      top: "Affine"
    }
    layer {
      name: "Tanh_3"
      type: "TanH"
      bottom: "Affine"
      top: "Tanh_3"
    }
    layer {
      name: "Affine_2"
      type: "InnerProduct"
      inner_product_param {
        num_output: 1
      }
      bottom: "Tanh_3"
      top: "Affine_2"
    }
    layer {
      name: "Sigmoid"
      type: "Sigmoid"
      bottom: "Affine_2"
      top: "Sigmoid"
    }
    
    

     

    Python Codeを選択すると、こちらはファイルではなく、クリップボードにコピーされます。

    def network(x, y, test=False):
      # Input -&gt; 1,28,28
      # Convolution -&gt; 16,24,24
      with parameter_scope('Convolution'):
        h = PF.convolution(x, 16, (5,5), (0,0))
      # MaxPooling -&gt; 16,12,12
      h = F.max_pooling(h, (2,2), (2,2), True)
      # Tanh
      h = F.tanh(h)
      # Convolution_2 -&gt; 8,8,8
      with parameter_scope('Convolution_2'):
        h = PF.convolution(h, 8, (5,5), (0,0))
      # MaxPooling_2 -&gt; 8,4,4
      h = F.max_pooling(h, (2,2), (2,2), True)
      # Tanh_2
      h = F.tanh(h)
      # Affine -&gt; 10
      with parameter_scope('Affine'):
        h = PF.affine(h, (10,))
      # Tanh_3
      h = F.tanh(h)
      # Affine_2 -&gt; 1
      with parameter_scope('Affine_2'):
        h = PF.affine(h, (1,))
      # Sigmoid
      h = F.sigmoid(h)
      # BinaryCrossEntropy
      h = F.binary_cross_entropy(h, y)
      return 
    

     

    ただ、一番知りたかったのは、学習データそのものなのですが、こちらは学習の画面(TRAINING)の左側に表示されている学習のログの部分を右クリック→Open Result Location もしくは ダブルクリックで学習データが保存されているフォルダが表示されます。

     

     

    学習データの保存フォルダ↓

     

    このフォルダには各種ログファイルと、重みやバイアスの値が格納されているファイル(*.h5)が保存されています。

     

    この*.h5ファイルは、個人的には全く馴染みの無いファイルだったのですが、このファイルのビューアソフトは、こちらのページ↓

     

    https://www.hdfgroup.org/downloads/hdfview/

     

    よりダウンロードすることができます。

    ただし、初めての場合はメールを登録しないとダウンロードできません。

    メールを登録後、メールが来るのですが、私の場合は迷惑メールフォルダに振り分けられていたので、しばらくしてもメールが来ない場合は、迷惑メールフォルダも確認するとよいと思います。

     

    私の場合はWindows10 64bitなので、 HDFView – Windows のファイルをダウンロードしました。

    ファイル(HDFView-3.0-win7_64.zip)をダウンロード後、解凍するとセットアップファイル(HDFView-3.0.msi)があるので、このファイルをダブルクリックして実行します。

     

    あとは表示に従って次へ次へ進めていけば、インストールができます。

     

    最後に Launch HDFVie-3.0.0 の部分にチェックを入れ、Finishボタンをクリックすると、ビューアのプログラムが起動します。

     

    これで、先ほどの学習データの保存フォルダに格納されているh5ファイルを開こうとしたら、なぜか?失敗。。。

    試しに 01_logostic_regressionのファイルを開いたら開けたので、再度、 02_binary_cnn 作成されたh5ファイルを開いたら、今度は成功!

     

    そして、こちら↓がファイルを開いた画面

     

    重みっぽいのがいる~!

     

    試しに最初のaffineWの部分をダブルクリックすると、その部分の重みがExcelのような画面で表示されます。

     

    このパラメータはこの↓ニューラルネットの最初の Affine の部分の重みで

     

     

    入力が8 x 4 x 4 = 128個で出力が10個になっているので、確かにつじつまも合う!

     

    このパラメータが分かってしまえば、層の浅いニューラルネットワークであれば、単純に画像のフィルタ処理のノリでプログラムに落とし込めそう!!

     

    とはいっても、次は、出力されたニューラルネットワークと、このh5ファイルを使って、プログラム(できればC++)に落とし込む方法を調べてみようと思っています。

    (詳しい方がいれば、参考になるページ等、教えて下さい!)

    Deep Learning向け学習画像撮り込みソフト公開

    最近はソニーのNeural Network Consoleを触りながらDeep Learningのお勉強をしているのですが、先日書いた記事

     

    【Neural Network Console】新規画像のDataset作成方法

     

    で使ったUSBカメラで撮影し、部分的に画像を切り出し、画像の回転、反転を行うソフトをソースコード付きで公開します。

     

    プログラムはこちら↓からダウンロードしてください。

    TrainingImageCapture100

     

    使っているソフトは様子は、こんな感じ↓です。

     

    プログラムはファイルを解凍後、

    ├ bin
    └ source

     

    となっています。

    プログラムを使うだけなら、binフォルダ内のTrainingImageCapture.exeを実行してください。

    sourceはこのプログラムのソースコードです。

     

    開発環境は

    Windows10 64bit

    Visual Studio 2015

    OpenCvSharp

    開発言語:C#

    ※実行にはUSBカメラが必要です。

     

    使用方法

    USBカメラをあらかじめ接続しておきます。

    プログラム(TrainingImageCapture.exe)を起動後、下記の設定を行います。

     

    Save Folder 画像の保存先フォルダを指定します。
    Prefix ファイル名の先頭の名前を指定します。

    指定した名前に5桁のシリアル番号を付けてファイルに保存します。

    File Type 保存するファイル形式(jpg、bmp、png、Tif)を指定します。
    ROI 切り出す画像サイズの幅と高さを指定します。
    Data Augmentation 画像の回転(90°、180°、270°)、左右・上下反転を行う場合はチェックを入れます。

     

     

    画像上をマウスの左クリックで撮影領域(赤い四角の部分)を指定します。

    画像上をマウスの右クリックで撮影領域内の画像をファイルに保存し、Data Augmentationで指定された画像も同時に保存されます。

     

    トラブルシューティング

    Visual Studio でプログラムを起動後、フォームウィンドウの表示でエラーになる場合があります。

    その場合は、フォームのウィンドウを閉じて、ビルドを行ってみてください。

    【Neural Network Console】新規画像のDataset作成方法

    Deep Learning用の学習データとしては、MNISTの手書きの数字がよく使われますが、そればかりやっていても面白くないので、自分で撮影した画像を使った学習データを作成してみようと思います。

     

    Neural Network Consoleでは、集めた画像から学習データ用のフォーマットを作るのは、Neural Network Consoleがやってくれるので、ユーザーがやるのは画像データを集めるだけ。

     

    今回はInterfaceの8月号に乗っていた きのこの山 と たけのこの里 の画像をChainerを使って分類する!

    という記事の内容をマネして、きのこの山 と たけのこの里 の画像をNeural Network Consoleで分類してみたいと思います。

     

     

    この記事によると、それぞれの画像を約40枚撮影し、さらに画像の回転、上下、左右の反転を行うことで、画像の枚数を水増しすると書いてありましたが、画像をそれぞれ40枚(計80枚)撮影するのも大変なので、C#でWebカメラで撮影した画像から、きのこの山 や たけのこの里 の写っている部分を切り出し、その画像を90°、180°、270°回転したものと、上下、左右を反転した画像の計6枚をマウスの1クリックでファイルに保存するプログラムを、まずは作成しました。

     

    ※このプログラムはこちら↓のページで公開しています。

    Deep Learning向け学習画像撮り込みソフト公開

     

    このプログラムを使って、きのこの山 と たけのこの里 の画像をそれぞれ約1500枚の画像を撮影しました。

     

    撮影した画像は、それぞれの分類ごとのフォルダに分けて保存しておきます。

     

    次にNeural Network ConsoleでHomeDATASETを選択し、+Create Datasetを選択します。

     

    次に学習データの設定を行います。

     

     

    Source Dir 分類ごとのフォルダに分けて画像が保存されているフォルダを指定します。
    Output Dir 学習データを出力するフォルダを指定します。
    (最初は空のフォルダ)
    Shaping Mode 元の画像と出力する画像の縦横比が異なるときの処理方法を指定します。

    ●Triming  画像の幅もしくは高さの短い方を出力サイズに合わせて、余計な部分をカットする

    ●Radding 画像の幅もしくは高さの長い方を出力サイズに合わせて、余白部分を黒(0)で埋める

     Output Color Ch  ●1(モノクロ画像)

    ●3(カラー画像)

     Output Width  出力画像の幅
    Shufle the order of the data 画像データをシャッフルして出力します。
    Output File 1 学習に用いるデータセットのファイル名(*.csv)を指定します。
    Output File 2 学習データの評価用に用いるデータセットのファイル名(*.csv)を指定します。
    Ratio 学習用:評価用に用いる画像の枚数の割合を指定します。

    (足して100にすること)

     

    上記の値を設定し、 Apply ボタンをクリックします。

     

    すると、出力フォルダにリサイズされた画像とデータセットのCSVファイルが作成されます。

     

     

    CSVファイルの中身はこんな↓感じに、学習用の画像画像ファイル名と正解のラベル(今回は0がきのこの山、1がたけのこの里)のペアが各行ごとに記載されいます。

     

     

    これでデータセットの作成は完了です。

    試しに、このデータセットを使って学習と評価を行ってみたいと思います。

     

    今回は、一番シンプルな4と9の分類のサンプルプロジェクト(01_logistic_regression)を使って、データセットの部分を差し替えてみたいと思います。

     

    まず、サンプルプロジェクト(01_logistic_regression)を開いて、別の名前でプロジェクトを保存します。

    保存は右上の Save as より行います。

     

    プロジェクトのDATASETの部分クリックします。

     

     

    すると、作成したデータセットが読み込まれます。

     

     

    次にデータセットがもともとの4と9の識別用のデータセットが設定されたままの状態なので、今回作成したデータセットに変更します。

     

    左側に表示されているTraining と Validation の部分を選択して、右上のOpen datasetをクリックします。

     

     

    今回はTraining に train.csv、Validationにtest.csv ファイルを指定しています。

     

    これで、Datasetの設定も完了。

     

    ニューラルネットワークの部分は一か所だけ変更しています。

    手書き文字の4と9の分類の時は、モノクロ画像だったので、入力(Input)のサイズが

    1,28,28

    でしたが、今回はカラー画像なので

    3,28,28

    と変更しました。

     

     

     

    続いて、Train の下の▶マークをクリックして、データの学習を行った結果がこちら↓

     

    次にEvalutionの下の▶マークをクリックして、評価を行った結果がこちら↓

     

     

    ただ、データセットを入れ替えて試してみただけなのに、分類の精度(Accuracy)が99.85%と表示されています。

     

    まだ、Deep Learningをそんなに理解できていないのに、なんとなくで、これだけの精度が出てしまうのは、やっぱりNeural Network Consoleはすごい!!

     

    適当にやっても、すぐに結果がわかる(見える)のは、大事だな~

    と、つくづく関心させられてしまいます。

     

    とは言っても、まだ、一つ一つの言葉が理解できていないので、Neural Network Consoleを触りながら勉強していこうと思っています。

     

    ※撮影に使用した きのこの山 と たけのこの里 は私がおいしく頂きました。

    ちなみに、私はたけのこの里の方が好きです。

     

    Deep Learningへ戻る