ユーザ用ツール

サイト用ツール


ai:cntk

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
ai:cntk [2018/10/28 20:19] – [Windows] ogaai:cntk [2018/11/03 22:29] (現在) – [keras と channels_last] oga
行 9: 行 9:
 | Windows          | <nowiki>C++</nowiki>, Python, C#    | CUDA        | | Windows          | <nowiki>C++</nowiki>, Python, C#    | CUDA        |
 | Linux            | <nowiki>C++</nowiki>, Python        | CUDA        | | Linux            | <nowiki>C++</nowiki>, Python        | CUDA        |
 +
 +CNTK は TensorFlow 同様 Keras の backend として利用できます。
 +
 +CNTK 自体は channels_first ですが、Keras 上の互換性のために channels_last でも動作するように作られています。
 +keras.json が channels_last の場合は内部で必要に応じて TransposeAxes が挿入されています。
 +TransposeAxes の分だけ、パフォーマンス的には channels_first の方が速いようです。
  
  
行 14: 行 20:
  
 Binary SDK が用意されているので、source から build しなくても <nowiki>C++</nowiki> から利用できます。 Binary SDK が用意されているので、source から build しなくても <nowiki>C++</nowiki> から利用できます。
-TensorFlow 同様 Keras の backend として利用できます。+
  
  
行 21: 行 27:
   - pip3 install cntk-gpu   - pip3 install cntk-gpu
   - pip3 install keras   - pip3 install keras
 +
 +
 +
 +
 +===== keras と channels_last =====
 +
 +CNTK は channels_first の方が高速に実行できるようです。
 +
 +^ keras image_data_format    実行時間 ^
 +| channles_first            |  494.15 sec |
 +| channels_last              771.04 sec |
 +
 +
 +channels_last の場合の例。
 +ところどころ TransposeAxes が挿入されており、5 Layer 余計にかかっていることがわかります。
 +
 +
 +<code>
 +Composite(conv2d_1_input: Tensor[28,28,1]) -> Tensor[10]
 +  Combine              a                              (b:[b*](10,)) -> (b:[b*](10,))
 +  Softmax              c                              (d:[b*](10,)) -> (b:[b*](10,))
 +  Plus                                              (f:[b*](10,), g:(10,)) -> (d:[b*](10,))
 +  Times                h                              (i:[b*](128,), dense_2/kernel:(128, 10)) -> (f:[b*](10,))
 +  Select                                            (_keras_learning_phase:(), k:[b*](128,), l:[b*](128,)) -> (i:[b*](128,))
 +  Constant             _keras_learning_phase           ()
 +  Dropout              m                              (l:[b*](128,)) -> (k:[b*](128,))
 +  ReLU                                              (o:[b*](128,)) -> (l:[b*](128,))
 +  Plus                                              (q:[b*](128,), r:(128,)) -> (o:[b*](128,))
 +  Times                s                              (t:[b*](10816,), dense_1/kernel:(10816, 128)) -> (q:[b*](128,))
 +  Reshape              u                              (v:[b*](13, 13, 64)) -> (t:[b*](10816,))
 +  Select                                            (_keras_learning_phase:(), x:[b*](13, 13, 64), y:[b*](13, 13, 64)) -> (v:[b*](13, 13, 64))
 +  Dropout              z                              (y:[b*](13, 13, 64)) -> (x:[b*](13, 13, 64))
 +  TransposeAxes        ba                             (bb:[b*](64, 13, 13)) -> (y:[b*](13, 13, 64))
 +  Pooling              bc                             (bd:[b*](64, 26, 26)) -> (bb:[b*](64, 13, 13))
 +  TransposeAxes        be                             (bf:[b*](26, 26, 64)) -> (bd:[b*](64, 26, 26))
 +  ReLU                 bg                             (bh:[b*](26, 26, 64)) -> (bf:[b*](26, 26, 64))
 +  Plus                 bi                             (bj:[b*](26, 26, 64), bk:(1, 1, 64)) -> (bh:[b*](26, 26, 64))
 +  TransposeAxes        bl                             (bm:[b*](64, 26, 26)) -> (bj:[b*](26, 26, 64))
 +  Convolution          bn                             (bo:(64, 32, 3, 3), bp:[b*](32, 28, 28)) -> (bm:[b*](64, 26, 26))
 +  TransposeAxes        bq                             (conv2d_2/kernel:(3, 3, 32, 64)) -> (bo:(64, 32, 3, 3))
 +  Parameter            conv2d_2/kernel                 (3, 3, 32, 64)
 +  TransposeAxes        br                             (bs:[b*](28, 28, 32)) -> (bp:[b*](32, 28, 28))
 +  ReLU                 bt                             (bu:[b*](28, 28, 32)) -> (bs:[b*](28, 28, 32))
 +  Plus                 bv                             (bw:[b*](28, 28, 32), bx:(1, 1, 32)) -> (bu:[b*](28, 28, 32))
 +  TransposeAxes        by                             (bz:[b*](32, 28, 28)) -> (bw:[b*](28, 28, 32))
 +  Convolution          ca                             (cb:(32, 1, 3, 3), cc:[b*](1, 28, 28)) -> (bz:[b*](32, 28, 28))
 +  TransposeAxes        cd                             (conv2d_1/kernel:(3, 3, 1, 32)) -> (cb:(32, 1, 3, 3))
 +  Parameter            conv2d_1/kernel                 (3, 3, 1, 32)
 +  TransposeAxes        ce                             (conv2d_1_input:[b*](28, 28, 1)) -> (cc:[b*](1, 28, 28))
 +  Input                conv2d_1_input Input4           [b*](28, 28, 1)
 +  Reshape              cf                             (conv2d_1/bias:(32,)) -> (bx:(1, 1, 32))
 +  Parameter            conv2d_1/bias                   (32,)
 +  Reshape              cg                             (conv2d_2/bias:(64,)) -> (bk:(1, 1, 64))
 +  Parameter            conv2d_2/bias                   (64,)
 +  Parameter            dense_1/kernel                  (10816, 128)
 +  Reshape              ch                             (dense_1/bias:(128,)) -> (r:(128,))
 +  Parameter            dense_1/bias                    (128,)
 +  Parameter            dense_2/kernel                  (128, 10)
 +  Reshape              ci                             (dense_2/bias:(10,)) -> (g:(10,))
 +  Parameter            dense_2/bias                    (10,)
 +</code>
 +
 +channels_first の場合
 +
 +<code>
 +Composite(conv2d_1_input: Tensor[1,28,28]) -> Tensor[10]
 +  Combine              a                              (b:[b*](10,)) -> (b:[b*](10,))
 +  Softmax              c                              (d:[b*](10,)) -> (b:[b*](10,))
 +  Plus                                              (f:[b*](10,), g:(10,)) -> (d:[b*](10,))
 +  Times                h                              (i:[b*](128,), dense_2/kernel:(128, 10)) -> (f:[b*](10,))
 +  Select                                            (_keras_learning_phase:(), k:[b*](128,), l:[b*](128,)) -> (i:[b*](128,))
 +  Constant             _keras_learning_phase           ()
 +  Dropout              m                              (l:[b*](128,)) -> (k:[b*](128,))
 +  ReLU                                              (o:[b*](128,)) -> (l:[b*](128,))
 +  Plus                                              (q:[b*](128,), r:(128,)) -> (o:[b*](128,))
 +  Times                s                              (t:[b*](10816,), dense_1/kernel:(10816, 128)) -> (q:[b*](128,))
 +  Reshape              u                              (v:[b*](13, 13, 64)) -> (t:[b*](10816,))
 +  TransposeAxes        w                              (x:[b*](64, 13, 13)) -> (v:[b*](13, 13, 64))
 +  Select                                            (_keras_learning_phase:(), z:[b*](64, 13, 13), ba:[b*](64, 13, 13)) -> (x:[b*](64, 13, 13))
 +  Dropout              bb                             (ba:[b*](64, 13, 13)) -> (z:[b*](64, 13, 13))
 +  Pooling              bc                             (bd:[b*](64, 26, 26)) -> (ba:[b*](64, 13, 13))
 +  ReLU                 be                             (bf:[b*](64, 26, 26)) -> (bd:[b*](64, 26, 26))
 +  Plus                 bg                             (bh:[b*](64, 26, 26), bi:(64, 1, 1)) -> (bf:[b*](64, 26, 26))
 +  Convolution          bj                             (bk:(64, 32, 3, 3), bl:[b*](32, 28, 28)) -> (bh:[b*](64, 26, 26))
 +  TransposeAxes        bm                             (conv2d_2/kernel:(3, 3, 32, 64)) -> (bk:(64, 32, 3, 3))
 +  Parameter            conv2d_2/kernel                 (3, 3, 32, 64)
 +  ReLU                 bn                             (bo:[b*](32, 28, 28)) -> (bl:[b*](32, 28, 28))
 +  Plus                 bp                             (bq:[b*](32, 28, 28), br:(32, 1, 1)) -> (bo:[b*](32, 28, 28))
 +  Convolution          bs                             (bt:(32, 1, 3, 3), conv2d_1_input:[b*](1, 28, 28)) -> (bq:[b*](32, 28, 28))
 +  TransposeAxes        bu                             (conv2d_1/kernel:(3, 3, 1, 32)) -> (bt:(32, 1, 3, 3))
 +  Parameter            conv2d_1/kernel                 (3, 3, 1, 32)
 +  Input                conv2d_1_input Input4           [b*](1, 28, 28)
 +  Reshape              bv                             (conv2d_1/bias:(32,)) -> (br:(32, 1, 1))
 +  Parameter            conv2d_1/bias                   (32,)
 +  Reshape              bw                             (conv2d_2/bias:(64,)) -> (bi:(64, 1, 1))
 +  Parameter            conv2d_2/bias                   (64,)
 +  Parameter            dense_1/kernel                  (10816, 128)
 +  Reshape              bx                             (dense_1/bias:(128,)) -> (r:(128,))
 +  Parameter            dense_1/bias                    (128,)
 +  Parameter            dense_2/kernel                  (128, 10)
 +  Reshape              by                             (dense_2/bias:(10,)) -> (g:(10,))
 +  Parameter            dense_2/bias                    (10,)
 +</code>
 +
  
  
  
ai/cntk.1540725585.txt.gz · 最終更新: 2018/10/28 20:19 by oga

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki