mil-tokyo / webdnn

The Fastest DNN Running Framework on Web Browser
https://mil-tokyo.github.io/webdnn
Other
1.98k stars 146 forks source link

Convert Dense layer for Keras and with backend fallback failed. #658

Open lygstate opened 6 years ago

lygstate commented 6 years ago
66 <keras.layers.core.Dense object at 0x0000018C985A6D68>
Using TensorFlow backend.
[convert_keras.py] Generating feedforward graph
2017-12-04 14:14:46.043447: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-12-04 14:14:46.043620: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-12-04 14:14:46.456242: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 860M
major: 5 minor: 0 memoryClockRate (GHz) 0.54
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.65GiB
2017-12-04 14:14:46.456353: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 0
2017-12-04 14:14:46.457797: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0:   Y
2017-12-04 14:14:46.458198: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 860M, pci bus id: 0000:01:00.0)
E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\util\console.py:30: Warning: [Pooling2D] Performing pooling with parameters which causes edge is ignored. Which edge (left / right) is ignored is different on frameworks, so slightly different result will be generated.
  warnings.warn(message, category)
Traceback (most recent call last):
  File "./webdnn/bin/convert_keras.py", line 117, in <module>
    main()
  File "./webdnn/bin/convert_keras.py", line 67, in main
    graph = converter.convert(model)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\frontend\keras\converter.py", line 112, in convert
    return self._convert_fallback(model)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\frontend\keras\converter.py", line 126, in _convert_fallback
    self._convert_operator(node.outbound_layer)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\frontend\keras\converter.py", line 159, in _convert_operator
    return super(KerasConverter, self)._convert_operator(k_op)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\frontend\converter.py", line 117, in _convert_operator
    self._handler_map[self.__class__.__name__][operator_key](self, operator)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\frontend\keras\layers\core.py", line 37, in _convert_dense
    y, = Tensordot(None, axes=[x.order.axes[-1], w.order.axes[0]])(x, w)
  File "E:\CI-Cor-Ready\ai\face-demo-work\webdnn\webdnn\src\graph_transpiler\webdnn\graph\operators\tensordot.py", line 119, in __call__
    """
AssertionError:
[Tensordot] Reduction size of "A" and "B" must be same:
    (A) = <Variable Variable106 shape=(1, 2048), order=[N, C]>
    (B) = <ConstantVariable ConstantVariable182 shape=(512, 10574), order=[?175, ?176]>
    (axes) = ((<Axis C>,), (<Axis ?175>,))
    (reduction size of A) = 2048
    (reduction size of B) = 512
Kiikurage commented 6 years ago

Error message said that invalid size matrix multiplication ( [1, 2048] * [512 10574] ) was performed. Could you give me your model structure information (ex. model.summary() in keras) ?

lygstate commented 6 years ago
Using TensorFlow backend.
2017-12-04 17:38:51.004583: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-12-04 17:38:51.004718: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-12-04 17:38:51.927643: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 860M
major: 5 minor: 0 memoryClockRate (GHz) 0.54
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.65GiB
2017-12-04 17:38:51.927791: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 0
2017-12-04 17:38:51.928786: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0:   Y
2017-12-04 17:38:51.929183: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 860M, pci bus id: 0000:01:00.0)
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to
====================================================================================================
input_1 (InputLayer)             (None, 96, 96, 1)     0
____________________________________________________________________________________________________
conv2d_1 (Conv2D)                (None, 48, 48, 64)    3200        input_1[0][0]
____________________________________________________________________________________________________
batch_normalization_1 (BatchNorm (None, 48, 48, 64)    256         conv2d_1[0][0]
____________________________________________________________________________________________________
activation_1 (Activation)        (None, 48, 48, 64)    0           batch_normalization_1[0][0]
____________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D)   (None, 24, 24, 64)    0           activation_1[0][0]
____________________________________________________________________________________________________
conv2d_2 (Conv2D)                (None, 24, 24, 64)    36928       max_pooling2d_1[0][0]
____________________________________________________________________________________________________
batch_normalization_2 (BatchNorm (None, 24, 24, 64)    256         conv2d_2[0][0]
____________________________________________________________________________________________________
activation_2 (Activation)        (None, 24, 24, 64)    0           batch_normalization_2[0][0]
____________________________________________________________________________________________________
conv2d_3 (Conv2D)                (None, 24, 24, 64)    36928       activation_2[0][0]
____________________________________________________________________________________________________
add_1 (Add)                      (None, 24, 24, 64)    0           max_pooling2d_1[0][0]
                                                                   conv2d_3[0][0]
____________________________________________________________________________________________________
batch_normalization_3 (BatchNorm (None, 24, 24, 64)    256         add_1[0][0]
____________________________________________________________________________________________________
activation_3 (Activation)        (None, 24, 24, 64)    0           batch_normalization_3[0][0]
____________________________________________________________________________________________________
conv2d_4 (Conv2D)                (None, 24, 24, 64)    36928       activation_3[0][0]
____________________________________________________________________________________________________
batch_normalization_4 (BatchNorm (None, 24, 24, 64)    256         conv2d_4[0][0]
____________________________________________________________________________________________________
activation_4 (Activation)        (None, 24, 24, 64)    0           batch_normalization_4[0][0]
____________________________________________________________________________________________________
conv2d_5 (Conv2D)                (None, 24, 24, 64)    36928       activation_4[0][0]
____________________________________________________________________________________________________
add_2 (Add)                      (None, 24, 24, 64)    0           add_1[0][0]
                                                                   conv2d_5[0][0]
____________________________________________________________________________________________________
batch_normalization_5 (BatchNorm (None, 24, 24, 64)    256         add_2[0][0]
____________________________________________________________________________________________________
activation_5 (Activation)        (None, 24, 24, 64)    0           batch_normalization_5[0][0]
____________________________________________________________________________________________________
conv2d_6 (Conv2D)                (None, 12, 12, 128)   73856       activation_5[0][0]
____________________________________________________________________________________________________
batch_normalization_6 (BatchNorm (None, 12, 12, 128)   512         conv2d_6[0][0]
____________________________________________________________________________________________________
activation_6 (Activation)        (None, 12, 12, 128)   0           batch_normalization_6[0][0]
____________________________________________________________________________________________________
conv2d_8 (Conv2D)                (None, 12, 12, 128)   8320        add_2[0][0]
____________________________________________________________________________________________________
conv2d_7 (Conv2D)                (None, 12, 12, 128)   147584      activation_6[0][0]
____________________________________________________________________________________________________
add_3 (Add)                      (None, 12, 12, 128)   0           conv2d_8[0][0]
                                                                   conv2d_7[0][0]
____________________________________________________________________________________________________
batch_normalization_7 (BatchNorm (None, 12, 12, 128)   512         add_3[0][0]
____________________________________________________________________________________________________
activation_7 (Activation)        (None, 12, 12, 128)   0           batch_normalization_7[0][0]
____________________________________________________________________________________________________
conv2d_9 (Conv2D)                (None, 12, 12, 128)   147584      activation_7[0][0]
____________________________________________________________________________________________________
batch_normalization_8 (BatchNorm (None, 12, 12, 128)   512         conv2d_9[0][0]
____________________________________________________________________________________________________
activation_8 (Activation)        (None, 12, 12, 128)   0           batch_normalization_8[0][0]
____________________________________________________________________________________________________
conv2d_10 (Conv2D)               (None, 12, 12, 128)   147584      activation_8[0][0]
____________________________________________________________________________________________________
add_4 (Add)                      (None, 12, 12, 128)   0           add_3[0][0]
                                                                   conv2d_10[0][0]
____________________________________________________________________________________________________
batch_normalization_9 (BatchNorm (None, 12, 12, 128)   512         add_4[0][0]
____________________________________________________________________________________________________
activation_9 (Activation)        (None, 12, 12, 128)   0           batch_normalization_9[0][0]
____________________________________________________________________________________________________
conv2d_11 (Conv2D)               (None, 6, 6, 256)     295168      activation_9[0][0]
____________________________________________________________________________________________________
batch_normalization_10 (BatchNor (None, 6, 6, 256)     1024        conv2d_11[0][0]
____________________________________________________________________________________________________
activation_10 (Activation)       (None, 6, 6, 256)     0           batch_normalization_10[0][0]
____________________________________________________________________________________________________
conv2d_13 (Conv2D)               (None, 6, 6, 256)     33024       add_4[0][0]
____________________________________________________________________________________________________
conv2d_12 (Conv2D)               (None, 6, 6, 256)     590080      activation_10[0][0]
____________________________________________________________________________________________________
add_5 (Add)                      (None, 6, 6, 256)     0           conv2d_13[0][0]
                                                                   conv2d_12[0][0]
____________________________________________________________________________________________________
batch_normalization_11 (BatchNor (None, 6, 6, 256)     1024        add_5[0][0]
____________________________________________________________________________________________________
activation_11 (Activation)       (None, 6, 6, 256)     0           batch_normalization_11[0][0]
____________________________________________________________________________________________________
conv2d_14 (Conv2D)               (None, 6, 6, 256)     590080      activation_11[0][0]
____________________________________________________________________________________________________
batch_normalization_12 (BatchNor (None, 6, 6, 256)     1024        conv2d_14[0][0]
____________________________________________________________________________________________________
activation_12 (Activation)       (None, 6, 6, 256)     0           batch_normalization_12[0][0]
____________________________________________________________________________________________________
conv2d_15 (Conv2D)               (None, 6, 6, 256)     590080      activation_12[0][0]
____________________________________________________________________________________________________
add_6 (Add)                      (None, 6, 6, 256)     0           add_5[0][0]
                                                                   conv2d_15[0][0]
____________________________________________________________________________________________________
batch_normalization_13 (BatchNor (None, 6, 6, 256)     1024        add_6[0][0]
____________________________________________________________________________________________________
activation_13 (Activation)       (None, 6, 6, 256)     0           batch_normalization_13[0][0]
____________________________________________________________________________________________________
conv2d_16 (Conv2D)               (None, 3, 3, 512)     1180160     activation_13[0][0]
____________________________________________________________________________________________________
batch_normalization_14 (BatchNor (None, 3, 3, 512)     2048        conv2d_16[0][0]
____________________________________________________________________________________________________
activation_14 (Activation)       (None, 3, 3, 512)     0           batch_normalization_14[0][0]
____________________________________________________________________________________________________
conv2d_18 (Conv2D)               (None, 3, 3, 512)     131584      add_6[0][0]
____________________________________________________________________________________________________
conv2d_17 (Conv2D)               (None, 3, 3, 512)     2359808     activation_14[0][0]
____________________________________________________________________________________________________
add_7 (Add)                      (None, 3, 3, 512)     0           conv2d_18[0][0]
                                                                   conv2d_17[0][0]
____________________________________________________________________________________________________
batch_normalization_15 (BatchNor (None, 3, 3, 512)     2048        add_7[0][0]
____________________________________________________________________________________________________
activation_15 (Activation)       (None, 3, 3, 512)     0           batch_normalization_15[0][0]
____________________________________________________________________________________________________
conv2d_19 (Conv2D)               (None, 3, 3, 512)     2359808     activation_15[0][0]
____________________________________________________________________________________________________
batch_normalization_16 (BatchNor (None, 3, 3, 512)     2048        conv2d_19[0][0]
____________________________________________________________________________________________________
activation_16 (Activation)       (None, 3, 3, 512)     0           batch_normalization_16[0][0]
____________________________________________________________________________________________________
conv2d_20 (Conv2D)               (None, 3, 3, 512)     2359808     activation_16[0][0]
____________________________________________________________________________________________________
add_8 (Add)                      (None, 3, 3, 512)     0           add_7[0][0]
                                                                   conv2d_20[0][0]
____________________________________________________________________________________________________
batch_normalization_17 (BatchNor (None, 3, 3, 512)     2048        add_8[0][0]
____________________________________________________________________________________________________
activation_17 (Activation)       (None, 3, 3, 512)     0           batch_normalization_17[0][0]
____________________________________________________________________________________________________
average_pooling2d_1 (AveragePool (None, 1, 1, 512)     0           activation_17[0][0]
____________________________________________________________________________________________________
flatten_1 (Flatten)              (None, 512)           0           average_pooling2d_1[0][0]
____________________________________________________________________________________________________
dense_1 (Dense)                  (None, 10574)         5424462     flatten_1[0][0]
====================================================================================================
Total params: 16,605,518
Trainable params: 16,597,710
Non-trainable params: 7,808
____________________________________________________________________________________________________
lygstate commented 6 years ago

There is a thing, webdnn on wegbl & webgpu backend are valid.